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,97 @@
|
|
|
1
|
+
import type { Span } from "../plugin.ts";
|
|
2
|
+
import { dayShiftOf, SECONDS_PER_DAY, withoutDayShiftBefore, type Mark, type TimeSpan, type TimeWords } from "../structure/time-marks.ts";
|
|
3
|
+
import { labelOf, mentionsIn, readScopes, within, type TimeLength } from "./time-lengths.ts";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Working hours: the stated total (実働8時間, 8 hours a day) against the end minus the start minus the break
|
|
7
|
+
* (9:00〜17:30、休憩1時間 is 7.5 hours). Read in one line, or in a list whose items say it together, holding exactly one
|
|
8
|
+
* range of two times, one break with its length and one total, and no other length. A range across midnight is read
|
|
9
|
+
* only when the end carries a next-day mark (22:00〜翌7:00). Pure.
|
|
10
|
+
*/
|
|
11
|
+
export type WorkingHoursWords = {
|
|
12
|
+
/** What stands alone between the two times of a range (〜, to, から). */
|
|
13
|
+
readonly joiners: readonly string[];
|
|
14
|
+
readonly dayShifts: readonly Mark[];
|
|
15
|
+
readonly breaks: readonly Mark[];
|
|
16
|
+
readonly totals: readonly Mark[];
|
|
17
|
+
readonly approximate: readonly Mark[];
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export type WorkingHoursMismatch = {
|
|
21
|
+
readonly start: Span;
|
|
22
|
+
readonly end: Span;
|
|
23
|
+
readonly break: Span;
|
|
24
|
+
readonly total: Span;
|
|
25
|
+
/** The total the times and the break give, in minutes. */
|
|
26
|
+
readonly expected: number;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
type ClockRange = Span & { readonly from: Span; readonly to: Span; readonly minutes: number | undefined };
|
|
30
|
+
|
|
31
|
+
const SECONDS_PER_MINUTE = 60;
|
|
32
|
+
|
|
33
|
+
const keyOf = (text: string): string => text.normalize("NFKC").trim().toLowerCase().replace(/\s+/gu, " ");
|
|
34
|
+
|
|
35
|
+
const timeWordsOf = (words: WorkingHoursWords): TimeWords => ({ legs: [], columns: [], dayShifts: words.dayShifts, zones: [] });
|
|
36
|
+
|
|
37
|
+
/** The minutes from one time to the other, the end a day later when it carries a next-day mark. */
|
|
38
|
+
const minutesOf = (text: string, from: TimeSpan, to: TimeSpan, words: TimeWords): number | undefined => {
|
|
39
|
+
const shift = dayShiftOf(text.slice(from.end, to.start), text, to.end, words);
|
|
40
|
+
const seconds = to.seconds + Math.max(0, shift) * SECONDS_PER_DAY - from.seconds;
|
|
41
|
+
return seconds > 0 ? seconds / SECONDS_PER_MINUTE : undefined;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
/** Two times written one after the other with only a joiner between them (9:00〜17:30, 9 a.m. to 5:30 p.m.). */
|
|
45
|
+
export const clockRanges = (text: string, times: readonly TimeSpan[], words: WorkingHoursWords): ClockRange[] => {
|
|
46
|
+
const joiners = new Set(words.joiners.map(keyOf));
|
|
47
|
+
const timeWords = timeWordsOf(words);
|
|
48
|
+
return times.flatMap((from, index): ClockRange[] => {
|
|
49
|
+
const to = times[index + 1];
|
|
50
|
+
if (to === undefined || !joiners.has(keyOf(withoutDayShiftBefore(text.slice(from.end, to.start), timeWords)))) return [];
|
|
51
|
+
return [{ start: from.start, end: to.end, from, to, minutes: minutesOf(text, from, to, timeWords) }];
|
|
52
|
+
});
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const isApproximate = (text: string, length: Span, words: WorkingHoursWords): boolean => labelOf(text, length, words.approximate) !== undefined;
|
|
56
|
+
|
|
57
|
+
type Labeled = { readonly length: TimeLength; readonly label: Span };
|
|
58
|
+
|
|
59
|
+
const labeled = (text: string, lengths: readonly TimeLength[], marks: readonly Mark[]): Labeled[] =>
|
|
60
|
+
lengths.flatMap((length) => {
|
|
61
|
+
const label = labelOf(text, length, marks);
|
|
62
|
+
return label === undefined ? [] : [{ length, label }];
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
/** The one statement in scope, or undefined when the scope does not hold exactly one. */
|
|
66
|
+
const statementIn = (text: string, scope: Span, ranges: readonly ClockRange[], lengths: readonly TimeLength[], words: WorkingHoursWords) => {
|
|
67
|
+
const inRanges = ranges.filter((range) => within(range, scope));
|
|
68
|
+
const inLengths = lengths.filter((length) => within(length, scope));
|
|
69
|
+
const breaks = labeled(text, inLengths, words.breaks);
|
|
70
|
+
const totals = labeled(text, inLengths, words.totals);
|
|
71
|
+
const [range, breakLength, total] = [inRanges[0], breaks[0], totals[0]];
|
|
72
|
+
if (inRanges.length !== 1 || breaks.length !== 1 || totals.length !== 1 || inLengths.length !== 2) return undefined;
|
|
73
|
+
if (range?.minutes === undefined || breakLength === undefined || total === undefined || breakLength.length === total.length) return undefined;
|
|
74
|
+
const label = breakLength.label;
|
|
75
|
+
const unexplained = mentionsIn(text, scope, words.breaks).some((mention) => mention.end <= label.start || mention.start >= label.end);
|
|
76
|
+
if (unexplained || isApproximate(text, breakLength.length, words) || isApproximate(text, total.length, words)) return undefined;
|
|
77
|
+
return { range: { ...range, minutes: range.minutes }, breakLength: breakLength.length, total: total.length };
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
/** Working hours whose stated total is not the end minus the start minus the break. */
|
|
81
|
+
export const workingHoursMismatches = (
|
|
82
|
+
text: string,
|
|
83
|
+
source: string,
|
|
84
|
+
sentences: readonly Span[],
|
|
85
|
+
times: readonly TimeSpan[],
|
|
86
|
+
lengths: readonly TimeLength[],
|
|
87
|
+
words: WorkingHoursWords,
|
|
88
|
+
): WorkingHoursMismatch[] => {
|
|
89
|
+
const ranges = clockRanges(text, times, words);
|
|
90
|
+
return readScopes(text, source, { sentences, times }, (scope) => statementIn(text, scope, ranges, lengths, words)).flatMap(
|
|
91
|
+
({ range, breakLength, total }) => {
|
|
92
|
+
const expected = range.minutes - breakLength.minutes;
|
|
93
|
+
if (expected <= 0 || expected === total.minutes) return [];
|
|
94
|
+
return [{ start: range.from, end: range.to, break: breakLength, total, expected }];
|
|
95
|
+
},
|
|
96
|
+
);
|
|
97
|
+
};
|
|
@@ -292,10 +292,65 @@ const proseLines = (lines: readonly string[]): string[] => {
|
|
|
292
292
|
return withoutFences(lines.map((line, index) => (index < skipped || INDENTED.test(line) ? "" : line)));
|
|
293
293
|
};
|
|
294
294
|
|
|
295
|
-
/**
|
|
295
|
+
/**
|
|
296
|
+
* 同じ書き方の見出し語が、名前で確かめられてこれだけある文書は、その書き方の用語集。用語集では、見出し語の後ろの段落はどれも定義なので、
|
|
297
|
+
* 名前の文字が揃わない項目(ADVIS: In hydrologic terms, a program…、AMVER: Automated Mutual Assistance Vessel Rescue System)も
|
|
298
|
+
* 説明済みと読む。書き方ごとに数えるので、名前を添えた箇条書きが並ぶ文書でも、略語だけの行(PDF、### MATLAB)は定義の見出しと読まない。
|
|
299
|
+
*/
|
|
300
|
+
const GLOSSARY_ENTRIES = 5;
|
|
301
|
+
|
|
302
|
+
/**
|
|
303
|
+
* 見出し語の行。略語 1 つか、/ で並べた略語(AMVER/SEAS)。前に 1 文字の語(A AMS)を置いてもよい。空白で並べた大文字の語
|
|
304
|
+
* (SEE ALSO、XYZ QRS)は見出しや略語の並びで、見出し語ではない。
|
|
305
|
+
*/
|
|
306
|
+
const HEADWORD_WORD = String.raw`[A-Z][A-Z&-]*[A-Z]`;
|
|
307
|
+
const HEADWORD_LINE = new RegExp(String.raw`^(?:#{1,6}\s+)?(?:[A-Z]\s)?(?<words>${HEADWORD_WORD}(?:/${HEADWORD_WORD})*)\s*(?<colon>[::])?(?:\s+#+)?$`, "u");
|
|
308
|
+
const HEADING_LINE = /^#{1,6}\s/u;
|
|
309
|
+
|
|
310
|
+
/** 定義の段落。小文字の語を含み(次の見出し語ではなく)、見出しでもない行。 */
|
|
311
|
+
const isDefinitionLine = (line: string): boolean => /\p{Ll}/u.test(line) && !HEADING_LINE.test(line);
|
|
312
|
+
|
|
313
|
+
/** 用語集の、見出し語だけの行と、その次の空でない行が定義の段落のもの。 */
|
|
314
|
+
const glossaryLineTerms = (lines: readonly string[], index: number): string[] => {
|
|
315
|
+
const line = (lines[index] ?? "").trim();
|
|
316
|
+
const groups = HEADWORD_LINE.exec(line.replaceAll(STRONG, ""))?.groups;
|
|
317
|
+
if (groups?.["words"] === undefined || (groups["colon"] !== undefined && !MARKED_LINE.test(line))) return [];
|
|
318
|
+
const next = lines.slice(index + 1, index + 1 + NEXT_LINE_REACH).find((candidate) => candidate.trim() !== "");
|
|
319
|
+
return next !== undefined && isDefinitionLine(next.trim()) ? groups["words"].split("/") : [];
|
|
320
|
+
};
|
|
321
|
+
|
|
322
|
+
/** 用語集の、印を付けた見出し語と区切りの後ろの定義(**ADVIS**: In hydrologic terms…、- ADVIS — a program…)。 */
|
|
323
|
+
const glossaryLeadTerm = (line: string): string[] => {
|
|
324
|
+
const lead = TERM_LEAD.exec(line.trim());
|
|
325
|
+
const term = lead?.groups?.["strongTerm"] ?? lead?.groups?.["term"];
|
|
326
|
+
return term !== undefined && /\p{Ll}/u.test(lead?.groups?.["rest"] ?? "") ? [term] : [];
|
|
327
|
+
};
|
|
328
|
+
|
|
329
|
+
type EntryForm = {
|
|
330
|
+
readonly named: (lines: readonly string[], index: number) => string[];
|
|
331
|
+
readonly defined: (lines: readonly string[], index: number) => string[];
|
|
332
|
+
};
|
|
333
|
+
|
|
334
|
+
/** 見出し語の書き方。行だけの見出し語と、印を付けた見出し語の後ろの名前。表は隣のセルの名前だけで読む。 */
|
|
335
|
+
const ENTRY_FORMS: readonly EntryForm[] = [
|
|
336
|
+
{ named: (lines, index) => (TABLE_ROW.test(lines[index] ?? "") ? [] : lineTerm(lines, index)), defined: glossaryLineTerms },
|
|
337
|
+
{
|
|
338
|
+
named: (lines, index) => (TABLE_ROW.test(lines[index] ?? "") ? [] : leadTerm(lines[index] ?? "")),
|
|
339
|
+
defined: (lines, index) => glossaryLeadTerm(lines[index] ?? ""),
|
|
340
|
+
},
|
|
341
|
+
{ named: (lines, index) => (TABLE_ROW.test(lines[index] ?? "") ? tableTerms(lines[index] ?? "") : []), defined: () => [] },
|
|
342
|
+
];
|
|
343
|
+
|
|
344
|
+
/** 一つの書き方で見出し語と読む略語。その書き方の用語集なら、名前でない定義を書いたものも。 */
|
|
345
|
+
const formTerms = (lines: readonly string[], form: EntryForm): string[] => {
|
|
346
|
+
const named = lines.flatMap((_, index) => form.named(lines, index));
|
|
347
|
+
return new Set(named).size < GLOSSARY_ENTRIES ? named : [...named, ...lines.flatMap((_, index) => form.defined(lines, index))];
|
|
348
|
+
};
|
|
349
|
+
|
|
350
|
+
/** 用語集の見出し語として、すぐ後ろに名前を書いた略語。用語集と読める書き方では、名前でなくても定義を書いた略語。 */
|
|
296
351
|
export const termEntryAcronyms = (source: string): ReadonlySet<string> => {
|
|
297
352
|
const lines = proseLines(source.split(/\r?\n/u));
|
|
298
|
-
return new Set(
|
|
353
|
+
return new Set(ENTRY_FORMS.flatMap((form) => formTerms(lines, form)));
|
|
299
354
|
};
|
|
300
355
|
|
|
301
356
|
export type ExpandedAt = (body: string, acronym: string, at: number) => boolean;
|
|
@@ -10,6 +10,7 @@ const countWordsOf = (doc: ProseDocument): CountWords => ({
|
|
|
10
10
|
anchors: patternsOf(doc, "count-anchor"),
|
|
11
11
|
numbers: patternsOf(doc, "count-number"),
|
|
12
12
|
counters: patternsOf(doc, "count-counter"),
|
|
13
|
+
frames: patternsOf(doc, "count-frame"),
|
|
13
14
|
hedgesBefore: patternsOf(doc, "count-hedge", "before"),
|
|
14
15
|
hedgesAfter: patternsOf(doc, "count-hedge", "after"),
|
|
15
16
|
});
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
// capacity-runtime-mismatch: a stated runtime longer than the battery capacity divided by the consumption (derived/battery-runtime.ts).
|
|
2
|
+
// Values are read from table rows (item name, value) and from "item name: value" lines. One key-value table and the labelled
|
|
3
|
+
// lines of one section are one device; a wider table is one device per column.
|
|
4
|
+
import type { Detector, Finding, ProseDocument } from "../plugin.ts";
|
|
5
|
+
import { cellsOf, tablesOf, type Cell } from "../facts/table-facts.ts";
|
|
6
|
+
import { linesOf, type Line } from "../structure/lines.ts";
|
|
7
|
+
import {
|
|
8
|
+
capacityRuntimeMismatches,
|
|
9
|
+
isPeakHeading,
|
|
10
|
+
labelOf,
|
|
11
|
+
splitCondition,
|
|
12
|
+
valueOf,
|
|
13
|
+
type BatteryWords,
|
|
14
|
+
type ElectricUnit,
|
|
15
|
+
type Entry,
|
|
16
|
+
type Family,
|
|
17
|
+
type Marker,
|
|
18
|
+
} from "../derived/battery-runtime.ts";
|
|
19
|
+
import { quoteAt } from "./structure-tree.ts";
|
|
20
|
+
|
|
21
|
+
const FAMILIES: readonly Family[] = ["charge", "current", "energy", "power"];
|
|
22
|
+
const isFamily = (group: string | undefined): group is Family => FAMILIES.some((family) => family === group);
|
|
23
|
+
|
|
24
|
+
type Lexicons = ProseDocument["lexicons"];
|
|
25
|
+
|
|
26
|
+
const markersOf = (lexicons: Lexicons, id: string, group?: string): Marker[] =>
|
|
27
|
+
(lexicons[id] ?? [])
|
|
28
|
+
.filter((entry) => group === undefined || entry.group === group)
|
|
29
|
+
.map((entry) => ({ pattern: entry.pattern, position: entry.position ?? "before" }));
|
|
30
|
+
|
|
31
|
+
export const batteryWordsOf = (lexicons: Lexicons): BatteryWords => {
|
|
32
|
+
const labels = (lexicons["battery-label"] ?? []).map((entry) => ({ pattern: entry.pattern, group: entry.group ?? "" }));
|
|
33
|
+
const bounds = markersOf(lexicons, "battery-label", "bound");
|
|
34
|
+
return {
|
|
35
|
+
electric: (lexicons["battery-unit"] ?? []).flatMap((entry): ElectricUnit[] =>
|
|
36
|
+
isFamily(entry.group) ? [{ pattern: entry.pattern, weight: entry.weight ?? 1, family: entry.group }] : [],
|
|
37
|
+
),
|
|
38
|
+
time: (lexicons["unit-time"] ?? []).map((entry) => ({ pattern: entry.pattern, weight: entry.weight ?? 1 })),
|
|
39
|
+
approximate: markersOf(lexicons, "approximate-marker").filter((marker) => !bounds.some((bound) => bound.pattern === marker.pattern)),
|
|
40
|
+
bounds,
|
|
41
|
+
connectors: (lexicons["range-connector"] ?? []).map((entry) => entry.pattern),
|
|
42
|
+
labels,
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const EMPHASIS = /[*`]/gu;
|
|
47
|
+
const plain = (text: string): string => text.replace(EMPHASIS, "");
|
|
48
|
+
|
|
49
|
+
type Slot = { readonly key: string; readonly entry: Entry };
|
|
50
|
+
|
|
51
|
+
const entryOf = (label: string, value: Cell, words: BatteryWords, columnPeak: boolean): Entry | undefined => {
|
|
52
|
+
const named = labelOf(plain(label), words);
|
|
53
|
+
const text = plain(value.text).trim();
|
|
54
|
+
const read = named === undefined ? undefined : valueOf(text, named.role, words);
|
|
55
|
+
if (named === undefined || read === undefined) return undefined;
|
|
56
|
+
const lead = value.text.length - value.text.trimStart().length;
|
|
57
|
+
return {
|
|
58
|
+
...named,
|
|
59
|
+
peak: named.peak || read.peak || columnPeak,
|
|
60
|
+
condition: named.condition === "" ? splitCondition(text).condition : named.condition,
|
|
61
|
+
reading: read.reading,
|
|
62
|
+
start: value.start + lead,
|
|
63
|
+
text,
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
const sectionAt = (doc: ProseDocument, offset: number): number => doc.sections.findLastIndex((section) => section.span.start <= offset);
|
|
68
|
+
|
|
69
|
+
const TWO_COLUMNS = 2;
|
|
70
|
+
|
|
71
|
+
const tableSlots = (doc: ProseDocument, words: BatteryWords): Slot[] =>
|
|
72
|
+
tablesOf(linesOf(doc.source)).flatMap((table) => {
|
|
73
|
+
const headings = cellsOf(table.header);
|
|
74
|
+
const wide = headings.length > TWO_COLUMNS;
|
|
75
|
+
return table.rows.flatMap((row) => {
|
|
76
|
+
const [label, ...values] = cellsOf(row);
|
|
77
|
+
if (label === undefined) return [];
|
|
78
|
+
return values.flatMap((value, index): Slot[] => {
|
|
79
|
+
const column = index + 1;
|
|
80
|
+
const peak = wide && isPeakHeading(plain(headings[column]?.text ?? ""), words);
|
|
81
|
+
const entry = entryOf(label.text, value, words, peak);
|
|
82
|
+
const key = wide ? `table ${table.header.start} ${column}` : `section ${sectionAt(doc, row.start)}`;
|
|
83
|
+
return entry === undefined || (!wide && column > 1) ? [] : [{ key, entry }];
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
const LIST_MARKER = /^\s*(?:[-*+]|\d+[.)])\s+/u;
|
|
89
|
+
const COLON = /[::]/u;
|
|
90
|
+
const MAX_LABEL = 80;
|
|
91
|
+
|
|
92
|
+
/** "Battery life: up to 10 hours", "- 消費電流:500 mA". */
|
|
93
|
+
const lineSlot = (doc: ProseDocument, line: Line, words: BatteryWords): Slot[] => {
|
|
94
|
+
const body = line.text.slice(LIST_MARKER.exec(line.text)?.[0].length ?? 0);
|
|
95
|
+
const colon = COLON.exec(body)?.index;
|
|
96
|
+
if (colon === undefined) return [];
|
|
97
|
+
const label = body.slice(0, colon).trim();
|
|
98
|
+
const value = body.slice(colon + 1).trim();
|
|
99
|
+
if (label === "" || label.length > MAX_LABEL || value === "") return [];
|
|
100
|
+
const start = line.start + line.text.lastIndexOf(value);
|
|
101
|
+
const entry = entryOf(label, { start, end: start + value.length, text: value }, words, false);
|
|
102
|
+
return entry === undefined ? [] : [{ key: `section ${sectionAt(doc, line.start)}`, entry }];
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
const HOUR_DECIMALS = 100;
|
|
106
|
+
|
|
107
|
+
export const capacityRuntime: Detector = (doc): Finding[] => {
|
|
108
|
+
const words = batteryWordsOf(doc.lexicons);
|
|
109
|
+
const lines = linesOf(doc.prose ?? doc.source).filter((line) => !line.text.includes("|"));
|
|
110
|
+
const slots = [...tableSlots(doc, words), ...lines.flatMap((line) => lineSlot(doc, line, words))];
|
|
111
|
+
const keys = [...new Set(slots.map((slot) => slot.key))];
|
|
112
|
+
return keys
|
|
113
|
+
.flatMap((key) => capacityRuntimeMismatches(slots.filter((slot) => slot.key === key).map((slot) => slot.entry)))
|
|
114
|
+
.map((mismatch) => ({
|
|
115
|
+
rule: "capacity-runtime-mismatch",
|
|
116
|
+
severity: "warning",
|
|
117
|
+
line: 0,
|
|
118
|
+
column: 0,
|
|
119
|
+
quote: quoteAt(doc.source, mismatch.runtime.start),
|
|
120
|
+
values: {
|
|
121
|
+
capacity: mismatch.capacity.text,
|
|
122
|
+
consumption: mismatch.consumption.text,
|
|
123
|
+
runtime: mismatch.runtime.text,
|
|
124
|
+
expected: Math.round(mismatch.idealHours * HOUR_DECIMALS) / HOUR_DECIMALS,
|
|
125
|
+
offset: mismatch.runtime.start,
|
|
126
|
+
},
|
|
127
|
+
}));
|
|
128
|
+
};
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
// A term written like the document's defined terms, capitalised inside a sentence (its Affiliates, disclose Proprietary
|
|
2
|
+
// Data), that the document defines nowhere. Read only where the document defines its terms with a defining word
|
|
3
|
+
// (MIN_DEFINED of them: "X" means, (the "X")). A capitalised run is also the name of a law, a body, a place, a party or a
|
|
4
|
+
// part of the document, so every name the language package lists is left, and so is every run set apart by markup (a
|
|
5
|
+
// heading, a link, bold, an HTML element, a table row, a list item's label). Pure.
|
|
6
|
+
import { escapeRegExp } from "../orthography.ts";
|
|
7
|
+
import type { Span, Token } from "../plugin.ts";
|
|
8
|
+
|
|
9
|
+
export type CapitalisedTerm = { readonly offset: number; readonly term: string };
|
|
10
|
+
|
|
11
|
+
/** The word lists the decision reads, matched as written. */
|
|
12
|
+
export type CapitalisedWords = {
|
|
13
|
+
/** A run holding one of these is a name (Act, Policy, Inc, California, Monday, Supplier), not a term. */
|
|
14
|
+
readonly names: readonly string[];
|
|
15
|
+
/** A run opening with one of these points at a part of the document (Section 4, Schedule A). */
|
|
16
|
+
readonly divisions: readonly string[];
|
|
17
|
+
/** Small words inside one name (Statement of Work, Trials and Betas). */
|
|
18
|
+
readonly joiners: readonly string[];
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
/** A term the document defines; bare is a definition with no defining word (("GPC")), which names more than it defines. */
|
|
22
|
+
export type Defined = { readonly term: string; readonly bare?: boolean };
|
|
23
|
+
|
|
24
|
+
export type CapitalisedInput = {
|
|
25
|
+
readonly source: string;
|
|
26
|
+
/** The text a reader sees (the source without link destinations): where a lower-case use counts. */
|
|
27
|
+
readonly readable: string;
|
|
28
|
+
readonly sentences: readonly (readonly Token[])[];
|
|
29
|
+
readonly defined: readonly Defined[];
|
|
30
|
+
/** Words set in quotes or bold anywhere ("Account" represents …, **Security Measures**): named on purpose. */
|
|
31
|
+
readonly named: readonly string[];
|
|
32
|
+
/** Spans set apart by markup: headings, links, bold, HTML elements, table rows, list items' labels. */
|
|
33
|
+
readonly marked: readonly Span[];
|
|
34
|
+
readonly words: CapitalisedWords;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
/** Fewer definitions than this, and capitals are the document's style, not its way of naming terms. */
|
|
38
|
+
const MIN_DEFINED = 2;
|
|
39
|
+
const CAPITALISED = /^\p{Lu}\p{Ll}+(?:['’]\p{Ll}+)?$/u;
|
|
40
|
+
const ACRONYM = /^\p{Lu}{2,}$/u;
|
|
41
|
+
const DEFINED_FORM = /^\p{Lu}/u;
|
|
42
|
+
const LOWER_WORD = /^\p{Ll}+$/u;
|
|
43
|
+
const HYPHEN = "-";
|
|
44
|
+
|
|
45
|
+
const isCapitalised = (token: Token | undefined): boolean => token !== undefined && CAPITALISED.test(token.surface);
|
|
46
|
+
/** A word that carries a run on once it has started: a capitalised word or an acronym (Commercial AI System). */
|
|
47
|
+
const continues = (token: Token | undefined): boolean => isCapitalised(token) || (token !== undefined && ACRONYM.test(token.surface));
|
|
48
|
+
const adjacent = (left: Token, right: Token): boolean => right.span.start - left.span.end <= 1;
|
|
49
|
+
const touching = (left: Token, right: Token): boolean => right.span.start === left.span.end;
|
|
50
|
+
|
|
51
|
+
/** The forms one term is written in: lower case, its last word as written and singular (Policies, Policy; Viruses, Virus). */
|
|
52
|
+
const formsOf = (term: string): string[] => {
|
|
53
|
+
const words = term.toLowerCase().split(/[\s-]+/u);
|
|
54
|
+
const head = words.slice(0, -1).join(" ");
|
|
55
|
+
const last = words.at(-1) ?? "";
|
|
56
|
+
const lasts = [last, last.replace(/ies$/u, "y"), last.replace(/es$/u, ""), last.replace(/(?<!s)s$/u, "")];
|
|
57
|
+
return lasts.map((form) => (head === "" ? form : `${head} ${form}`));
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
/** How many tokens the capitalised run starting at index takes: words that continue it, and a joiner or hyphen between two. */
|
|
61
|
+
const runLength = (tokens: readonly Token[], index: number, joiners: ReadonlySet<string>): number => {
|
|
62
|
+
const word = tokens[index];
|
|
63
|
+
const next = tokens[index + 1];
|
|
64
|
+
const after = tokens[index + 2];
|
|
65
|
+
if (next === undefined || word === undefined || !adjacent(word, next)) return 1;
|
|
66
|
+
if (continues(next)) return 1 + runLength(tokens, index + 1, joiners);
|
|
67
|
+
const hyphened = next.surface === HYPHEN && touching(word, next) && after !== undefined && touching(next, after);
|
|
68
|
+
const joined = hyphened || (joiners.has(next.surface) && after !== undefined && adjacent(next, after));
|
|
69
|
+
return joined && continues(after) ? 2 + runLength(tokens, index + 2, joiners) : 1;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
type Run = { readonly start: number; readonly end: number };
|
|
73
|
+
|
|
74
|
+
/** The capitalised runs of one sentence, as [start, end) token indexes; a run never starts inside the one before. */
|
|
75
|
+
const runsOf = (tokens: readonly Token[], joiners: ReadonlySet<string>): Run[] =>
|
|
76
|
+
tokens.reduce<Run[]>((runs, token, index) => {
|
|
77
|
+
if ((runs.at(-1)?.end ?? 0) > index || !isCapitalised(token)) return runs;
|
|
78
|
+
return [...runs, { start: index, end: index + runLength(tokens, index, joiners) }];
|
|
79
|
+
}, []);
|
|
80
|
+
|
|
81
|
+
const inside = (offset: number, spans: readonly Span[]): boolean => spans.some((span) => span.start <= offset && offset < span.end);
|
|
82
|
+
|
|
83
|
+
/** Used like a defined term: after a lower-case word, and not a modifier of a lower-case noun after it (the Premium plan). */
|
|
84
|
+
const placedLikeATerm = (before: Token | undefined, after: Token | undefined): boolean =>
|
|
85
|
+
before !== undefined && LOWER_WORD.test(before.surface) && !(after !== undefined && after.pos === "NOUN" && LOWER_WORD.test(after.surface));
|
|
86
|
+
|
|
87
|
+
/** Every run of whole words in a term (GitHub Service: GitHub, Service, GitHub Service). */
|
|
88
|
+
const partsOf = (term: string): string[] => {
|
|
89
|
+
const words = term.split(/\s+/u);
|
|
90
|
+
return words.flatMap((_, start) => words.slice(start).map((__, length) => words.slice(start, start + length + 1).join(" ")));
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
/** The text also writes the term in lower case (your account, account settings): an ordinary word, or a screen's label. */
|
|
94
|
+
const writtenInLowerCase = (text: string, term: string): boolean => {
|
|
95
|
+
const words = term
|
|
96
|
+
.toLowerCase()
|
|
97
|
+
.split(/[\s-]+/u)
|
|
98
|
+
.map(escapeRegExp)
|
|
99
|
+
.join(String.raw`[\s-]+`);
|
|
100
|
+
return new RegExp(String.raw`(?<!\p{L})${words}(?:e?s)?(?!\p{L})`, "u").test(text);
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* The first use of each capitalised run used inside a sentence like a defined term that names nothing the language
|
|
105
|
+
* package lists, is not set apart by markup, is never written in lower case, and neither is nor holds a defined or named
|
|
106
|
+
* term in any case.
|
|
107
|
+
*/
|
|
108
|
+
export const capitalisedTerms = (input: CapitalisedInput): CapitalisedTerm[] => {
|
|
109
|
+
const defining = input.defined.filter((definition) => definition.bare !== true && DEFINED_FORM.test(definition.term));
|
|
110
|
+
if (defining.length < MIN_DEFINED) return [];
|
|
111
|
+
const joiners = new Set(input.words.joiners);
|
|
112
|
+
const divisions = new Set(input.words.divisions.flatMap(formsOf));
|
|
113
|
+
const known = new Set([...input.defined.map((definition) => definition.term), ...input.named, ...input.words.names].flatMap(formsOf));
|
|
114
|
+
const isKnown = (term: string): boolean => partsOf(term).some((part) => formsOf(part).some((form) => known.has(form)));
|
|
115
|
+
const uses = input.sentences.flatMap((tokens) =>
|
|
116
|
+
runsOf(tokens, joiners).flatMap(({ start, end }): CapitalisedTerm[] => {
|
|
117
|
+
const first = tokens[start];
|
|
118
|
+
const last = tokens[end - 1];
|
|
119
|
+
if (first === undefined || last === undefined || !placedLikeATerm(tokens[start - 1], tokens[end])) return [];
|
|
120
|
+
if (inside(first.span.start, input.marked) || formsOf(first.surface).some((form) => divisions.has(form))) return [];
|
|
121
|
+
const term = input.source.slice(first.span.start, last.span.end);
|
|
122
|
+
return isKnown(term) || writtenInLowerCase(input.readable, term) ? [] : [{ offset: first.span.start, term }];
|
|
123
|
+
}),
|
|
124
|
+
);
|
|
125
|
+
return uses.filter((use, index) => uses.findIndex((other) => formsOf(other.term).some((form) => formsOf(use.term).includes(form))) === index);
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
const BOLD = /\*\*([^*\n]+)\*\*|__([^_\n]+)__/gu;
|
|
129
|
+
const QUOTED = /["“]([^"“”\n]{1,80}?)[,.]?["”]/gu;
|
|
130
|
+
const HTML_ELEMENT = /<([a-z][a-z0-9]*)\b[^>]*>[^<]*<\/\1>/giu;
|
|
131
|
+
const TABLE_ROW = /^[ \t]*\|.*$/gmu;
|
|
132
|
+
const ITEM_LABEL = /^[ \t]*(?:[*+-]|\d+[.)])[ \t]+[^:\n]{1,80}:/gmu;
|
|
133
|
+
|
|
134
|
+
const spansOf = (source: string, pattern: RegExp): Span[] =>
|
|
135
|
+
[...source.matchAll(pattern)].map((match) => ({ start: match.index, end: match.index + match[0].length }));
|
|
136
|
+
|
|
137
|
+
/** Bold, HTML elements, table rows and list items' labels in a Markdown source: labels and cells, not running text. */
|
|
138
|
+
export const setApartSpans = (source: string): Span[] => [BOLD, HTML_ELEMENT, TABLE_ROW, ITEM_LABEL].flatMap((pattern) => spansOf(source, pattern));
|
|
139
|
+
|
|
140
|
+
const LINK_DESTINATION = /\]\([^)\n]*\)|<?https?:\/\/[^\s)>]+>?/gu;
|
|
141
|
+
|
|
142
|
+
/** The source with link destinations and URLs blanked: the words a reader sees. */
|
|
143
|
+
export const readableText = (source: string): string => source.replaceAll(LINK_DESTINATION, (destination) => " ".repeat(destination.length));
|
|
144
|
+
|
|
145
|
+
/** The words set in quotes or bold anywhere in a source, without the emphasis marks. */
|
|
146
|
+
export const namedWords = (source: string): string[] =>
|
|
147
|
+
[BOLD, QUOTED].flatMap((pattern) => [...source.matchAll(pattern)].map((match) => (match[1] ?? match[2] ?? "").replaceAll(/[*_]/gu, "").trim()));
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// contact-variant: one email address or postal address written two ways in one document (contacts/emails.ts,
|
|
2
|
+
// contacts/addresses.ts). The address labels come from the language's address-label lexicon.
|
|
3
|
+
import { addressVariants } from "../contacts/addresses.ts";
|
|
4
|
+
import { emailVariants } from "../contacts/emails.ts";
|
|
5
|
+
import type { Variant, Writing } from "../contacts/variants.ts";
|
|
6
|
+
import { quoteAt } from "./structure-tree.ts";
|
|
7
|
+
import type { Detector, Finding } from "../plugin.ts";
|
|
8
|
+
|
|
9
|
+
const findingOf = (source: string, { writing, other }: Variant<Writing>, variant?: string): Finding => ({
|
|
10
|
+
rule: "",
|
|
11
|
+
severity: "info",
|
|
12
|
+
line: 0,
|
|
13
|
+
column: 0,
|
|
14
|
+
quote: quoteAt(source, writing.offset),
|
|
15
|
+
values: { written: writing.written, other: other.written, offset: writing.offset },
|
|
16
|
+
...(variant === undefined ? {} : { variant }),
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
export const contactVariant: Detector = (doc, options): Finding[] => {
|
|
20
|
+
const text = doc.prose ?? doc.source;
|
|
21
|
+
const emails = emailVariants(text).map((found) => findingOf(doc.source, found));
|
|
22
|
+
const addresses = addressVariants(text, options.lexicon ?? []).map(({ variant, found }) => findingOf(doc.source, found, variant));
|
|
23
|
+
return [...emails, ...addresses].toSorted((a, b) => Number(a.values?.["offset"]) - Number(b.values?.["offset"]));
|
|
24
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// A stated capacity smaller than a stated number registered, invited or attending (count-over-capacity). The words come
|
|
2
|
+
// from the language package: capacity-label, headcount-label, headcount-unit and capacity-exception.
|
|
3
|
+
import { countsOverCapacity, type CapacityWords, type CountMark } from "../structure/capacity-count.ts";
|
|
4
|
+
import { proseAndTablesOf } from "../table-text.ts";
|
|
5
|
+
import { quoteAt } from "./structure-tree.ts";
|
|
6
|
+
import type { Detector, Finding, ProseDocument } from "../plugin.ts";
|
|
7
|
+
|
|
8
|
+
const marksOf = (doc: ProseDocument, lexicon: string): CountMark[] =>
|
|
9
|
+
(doc.lexicons[lexicon] ?? []).map((entry) => ({ pattern: entry.pattern, position: entry.position, group: entry.group }));
|
|
10
|
+
|
|
11
|
+
const exceptionsOf = (doc: ProseDocument, group: string): string[] =>
|
|
12
|
+
(doc.lexicons["capacity-exception"] ?? []).filter((entry) => entry.group === group).map((entry) => entry.pattern);
|
|
13
|
+
|
|
14
|
+
const capacityWords = (doc: ProseDocument): CapacityWords => ({
|
|
15
|
+
capacities: marksOf(doc, "capacity-label"),
|
|
16
|
+
counts: marksOf(doc, "headcount-label"),
|
|
17
|
+
units: marksOf(doc, "headcount-unit"),
|
|
18
|
+
overflows: exceptionsOf(doc, "overflow"),
|
|
19
|
+
perSession: exceptionsOf(doc, "per-session"),
|
|
20
|
+
otherOccasions: exceptionsOf(doc, "other-occasion"),
|
|
21
|
+
negations: exceptionsOf(doc, "negation"),
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
/** The prose with its tables put back, so code is not read; offsets are the source's. */
|
|
25
|
+
export const countOverCapacity: Detector = (doc): Finding[] =>
|
|
26
|
+
countsOverCapacity(
|
|
27
|
+
proseAndTablesOf(doc),
|
|
28
|
+
capacityWords(doc),
|
|
29
|
+
doc.sections.map((section) => section.span),
|
|
30
|
+
).map((issue) => ({
|
|
31
|
+
rule: "count-over-capacity",
|
|
32
|
+
severity: "warning",
|
|
33
|
+
line: 0,
|
|
34
|
+
column: 0,
|
|
35
|
+
quote: quoteAt(doc.source, issue.offset),
|
|
36
|
+
values: { ...issue.values, offset: issue.offset },
|
|
37
|
+
}));
|
|
@@ -6,10 +6,14 @@ import { quoteAt } from "./structure-tree.ts";
|
|
|
6
6
|
|
|
7
7
|
const patternsOf = (doc: ProseDocument, lexicon: string): string[] => (doc.lexicons[lexicon] ?? []).map((entry) => entry.pattern);
|
|
8
8
|
|
|
9
|
-
/**
|
|
9
|
+
/** 期間の語、期間の外に置く語、文書の仕事の期間の語、締め切りの語、期間の後に来てよい仕事の語、概要の節の見出しの語、範囲の記号(range-connector、range-opener、range-frame の間の語)、月と曜日の名は語彙表から取る。 */
|
|
10
10
|
const wordsOf = (doc: ProseDocument): OutsideWords => ({
|
|
11
11
|
labels: patternsOf(doc, "period-label"),
|
|
12
|
+
terms: patternsOf(doc, "period-term-label"),
|
|
12
13
|
asides: patternsOf(doc, "period-aside"),
|
|
14
|
+
deadlines: patternsOf(doc, "period-deadline"),
|
|
15
|
+
overviews: patternsOf(doc, "period-overview-heading"),
|
|
16
|
+
afterTerm: patternsOf(doc, "period-after-term"),
|
|
13
17
|
connectors: [
|
|
14
18
|
...patternsOf(doc, "range-connector"),
|
|
15
19
|
...patternsOf(doc, "range-opener"),
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// date-stamp-order: an established date later than the last update, on the document's stamp lines (structure/stamp-order.ts).
|
|
2
|
+
// The stamp words come from the language's stamp-order-label lexicon, grouped into established and updated.
|
|
3
|
+
import type { Detector, Finding } from "../plugin.ts";
|
|
4
|
+
import { inDocumentOrder } from "../structure/issues.ts";
|
|
5
|
+
import { stampOrderIssues } from "../structure/stamp-order.ts";
|
|
6
|
+
import { proseAndTablesOf } from "../table-text.ts";
|
|
7
|
+
import { quoteAt } from "./structure-tree.ts";
|
|
8
|
+
|
|
9
|
+
export const dateStampOrder: Detector = (doc, options): Finding[] => {
|
|
10
|
+
if (doc.structure === undefined) return [];
|
|
11
|
+
const labels = options.lexicon ?? [];
|
|
12
|
+
const wordsOf = (group: string): string[] => labels.filter((entry) => entry.group === group).map((entry) => entry.pattern);
|
|
13
|
+
const dates = inDocumentOrder(doc.structure).flatMap((node) =>
|
|
14
|
+
node.kind === "date" ? [{ offset: node.span.start, end: node.span.end, value: String(node.attrs["value"]) }] : [],
|
|
15
|
+
);
|
|
16
|
+
return stampOrderIssues(proseAndTablesOf(doc), dates, { established: wordsOf("established"), updated: wordsOf("updated") }).map(({ offset, values }) => {
|
|
17
|
+
const { side, ...dated } = values;
|
|
18
|
+
return {
|
|
19
|
+
rule: "",
|
|
20
|
+
severity: "info",
|
|
21
|
+
line: 0,
|
|
22
|
+
column: 0,
|
|
23
|
+
quote: quoteAt(doc.source, offset),
|
|
24
|
+
values: { ...dated, offset },
|
|
25
|
+
...(side === undefined ? {} : { variant: String(side) }),
|
|
26
|
+
};
|
|
27
|
+
});
|
|
28
|
+
};
|