chaffjs 0.28.0 → 0.30.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/ai-score/of-document.d.ts.map +1 -1
- package/dist/ai-score/of-document.js +23 -14
- package/dist/ai-score/of-document.js.map +1 -1
- package/dist/ai-score/render.d.ts.map +1 -1
- package/dist/ai-score/render.js +13 -4
- package/dist/ai-score/render.js.map +1 -1
- package/dist/ai-score/score.d.ts +16 -1
- package/dist/ai-score/score.d.ts.map +1 -1
- package/dist/ai-score/score.js +15 -3
- package/dist/ai-score/score.js.map +1 -1
- package/dist/ai-score/signals.d.ts +2 -4
- package/dist/ai-score/signals.d.ts.map +1 -1
- package/dist/ai-score/signals.js +11 -2
- package/dist/ai-score/signals.js.map +1 -1
- package/dist/ai-score/text.d.ts +2 -0
- package/dist/ai-score/text.d.ts.map +1 -1
- package/dist/ai-score/text.js +4 -2
- package/dist/ai-score/text.js.map +1 -1
- package/dist/announced-count.d.ts +2 -0
- package/dist/announced-count.d.ts.map +1 -1
- package/dist/announced-count.js +14 -7
- package/dist/announced-count.js.map +1 -1
- package/dist/check-source.d.ts +3 -1
- package/dist/check-source.d.ts.map +1 -1
- package/dist/check-source.js +3 -1
- package/dist/check-source.js.map +1 -1
- package/dist/cli-text.d.ts.map +1 -1
- package/dist/cli-text.js +38 -16
- package/dist/cli-text.js.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +2 -1
- package/dist/cli.js.map +1 -1
- package/dist/commands/cite-claims.d.ts +36 -0
- package/dist/commands/cite-claims.d.ts.map +1 -0
- package/dist/commands/cite-claims.js +81 -0
- package/dist/commands/cite-claims.js.map +1 -0
- package/dist/commands/cite-page.d.ts +14 -0
- package/dist/commands/cite-page.d.ts.map +1 -0
- package/dist/commands/cite-page.js +47 -0
- package/dist/commands/cite-page.js.map +1 -0
- package/dist/commands/cite-scaffold.d.ts +16 -0
- package/dist/commands/cite-scaffold.d.ts.map +1 -0
- package/dist/commands/cite-scaffold.js +21 -0
- package/dist/commands/cite-scaffold.js.map +1 -0
- package/dist/commands/cite.d.ts +3 -12
- package/dist/commands/cite.d.ts.map +1 -1
- package/dist/commands/cite.js +110 -51
- package/dist/commands/cite.js.map +1 -1
- package/dist/company-names.d.ts +34 -0
- package/dist/company-names.d.ts.map +1 -0
- package/dist/company-names.js +158 -0
- package/dist/company-names.js.map +1 -0
- package/dist/default-values.d.ts +17 -0
- package/dist/default-values.d.ts.map +1 -0
- package/dist/default-values.js +134 -0
- package/dist/default-values.js.map +1 -0
- package/dist/deprecated-use.d.ts +17 -0
- package/dist/deprecated-use.d.ts.map +1 -0
- package/dist/deprecated-use.js +95 -0
- package/dist/deprecated-use.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/stays.d.ts +43 -0
- package/dist/derived/stays.d.ts.map +1 -0
- package/dist/derived/stays.js +105 -0
- package/dist/derived/stays.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 +168 -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/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-context.d.ts +2 -2
- package/dist/detectors/acronym-context.d.ts.map +1 -1
- package/dist/detectors/acronym-context.js +6 -0
- package/dist/detectors/acronym-context.js.map +1 -1
- 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/address-word.d.ts +3 -0
- package/dist/detectors/address-word.d.ts.map +1 -0
- package/dist/detectors/address-word.js +7 -0
- package/dist/detectors/address-word.js.map +1 -0
- package/dist/detectors/agreement-slip.d.ts.map +1 -1
- package/dist/detectors/agreement-slip.js +4 -1
- package/dist/detectors/agreement-slip.js.map +1 -1
- package/dist/detectors/ai-phrasing.d.ts +0 -4
- package/dist/detectors/ai-phrasing.d.ts.map +1 -1
- package/dist/detectors/ai-phrasing.js +5 -1
- package/dist/detectors/ai-phrasing.js.map +1 -1
- package/dist/detectors/amount-range.d.ts +3 -0
- package/dist/detectors/amount-range.d.ts.map +1 -0
- package/dist/detectors/amount-range.js +38 -0
- package/dist/detectors/amount-range.js.map +1 -0
- package/dist/detectors/amount-scale.d.ts +6 -1
- package/dist/detectors/amount-scale.d.ts.map +1 -1
- package/dist/detectors/amount-scale.js +33 -9
- package/dist/detectors/amount-scale.js.map +1 -1
- package/dist/detectors/announced-count.d.ts +1 -1
- package/dist/detectors/announced-count.d.ts.map +1 -1
- package/dist/detectors/announced-count.js +18 -3
- package/dist/detectors/announced-count.js.map +1 -1
- package/dist/detectors/bare-comparative.d.ts.map +1 -1
- package/dist/detectors/bare-comparative.js +4 -1
- package/dist/detectors/bare-comparative.js.map +1 -1
- package/dist/detectors/block-quotation.d.ts +13 -0
- package/dist/detectors/block-quotation.d.ts.map +1 -0
- package/dist/detectors/block-quotation.js +86 -0
- package/dist/detectors/block-quotation.js.map +1 -0
- package/dist/detectors/bracket-label.d.ts +10 -0
- package/dist/detectors/bracket-label.d.ts.map +1 -0
- package/dist/detectors/bracket-label.js +51 -0
- package/dist/detectors/bracket-label.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/citation-entry.d.ts +5 -0
- package/dist/detectors/citation-entry.d.ts.map +1 -1
- package/dist/detectors/citation-entry.js +19 -5
- package/dist/detectors/citation-entry.js.map +1 -1
- package/dist/detectors/code-before.d.ts +6 -0
- package/dist/detectors/code-before.d.ts.map +1 -0
- package/dist/detectors/code-before.js +15 -0
- package/dist/detectors/code-before.js.map +1 -0
- package/dist/detectors/connective-hierarchy.d.ts +11 -1
- package/dist/detectors/connective-hierarchy.d.ts.map +1 -1
- package/dist/detectors/connective-hierarchy.js +26 -6
- package/dist/detectors/connective-hierarchy.js.map +1 -1
- package/dist/detectors/currency-notation.d.ts.map +1 -1
- package/dist/detectors/currency-notation.js +2 -1
- package/dist/detectors/currency-notation.js.map +1 -1
- package/dist/detectors/date-outside-period.d.ts +4 -0
- package/dist/detectors/date-outside-period.d.ts.map +1 -0
- package/dist/detectors/date-outside-period.js +37 -0
- package/dist/detectors/date-outside-period.js.map +1 -0
- package/dist/detectors/default-values.d.ts +3 -0
- package/dist/detectors/default-values.d.ts.map +1 -0
- package/dist/detectors/default-values.js +14 -0
- package/dist/detectors/default-values.js.map +1 -0
- package/dist/detectors/defined-term-form.d.ts +6 -2
- package/dist/detectors/defined-term-form.d.ts.map +1 -1
- package/dist/detectors/defined-term-form.js +72 -12
- package/dist/detectors/defined-term-form.js.map +1 -1
- package/dist/detectors/definition-use.d.ts.map +1 -1
- package/dist/detectors/definition-use.js +8 -1
- package/dist/detectors/definition-use.js.map +1 -1
- package/dist/detectors/deprecated-use.d.ts +3 -0
- package/dist/detectors/deprecated-use.d.ts.map +1 -0
- package/dist/detectors/deprecated-use.js +14 -0
- package/dist/detectors/deprecated-use.js.map +1 -0
- package/dist/detectors/derived-numbers.d.ts +3 -1
- package/dist/detectors/derived-numbers.d.ts.map +1 -1
- package/dist/detectors/derived-numbers.js +119 -10
- package/dist/detectors/derived-numbers.js.map +1 -1
- package/dist/detectors/document-shape.d.ts +1 -0
- package/dist/detectors/document-shape.d.ts.map +1 -1
- package/dist/detectors/document-shape.js +4 -1
- package/dist/detectors/document-shape.js.map +1 -1
- package/dist/detectors/due-date.d.ts +3 -0
- package/dist/detectors/due-date.d.ts.map +1 -0
- package/dist/detectors/due-date.js +38 -0
- package/dist/detectors/due-date.js.map +1 -0
- package/dist/detectors/en-shape.d.ts.map +1 -1
- package/dist/detectors/en-shape.js +17 -9
- package/dist/detectors/en-shape.js.map +1 -1
- package/dist/detectors/fact-consistency.d.ts.map +1 -1
- package/dist/detectors/fact-consistency.js +76 -2
- package/dist/detectors/fact-consistency.js.map +1 -1
- package/dist/detectors/heading-echo.d.ts.map +1 -1
- package/dist/detectors/heading-echo.js +10 -1
- package/dist/detectors/heading-echo.js.map +1 -1
- package/dist/detectors/kana-function-word.d.ts +12 -0
- package/dist/detectors/kana-function-word.d.ts.map +1 -0
- package/dist/detectors/kana-function-word.js +59 -0
- package/dist/detectors/kana-function-word.js.map +1 -0
- package/dist/detectors/line-amount.d.ts +3 -0
- package/dist/detectors/line-amount.d.ts.map +1 -0
- package/dist/detectors/line-amount.js +22 -0
- package/dist/detectors/line-amount.js.map +1 -0
- package/dist/detectors/location-pointer.d.ts +6 -0
- package/dist/detectors/location-pointer.d.ts.map +1 -0
- package/dist/detectors/location-pointer.js +22 -0
- package/dist/detectors/location-pointer.js.map +1 -0
- package/dist/detectors/mark-shape.d.ts.map +1 -1
- package/dist/detectors/mark-shape.js +13 -1
- package/dist/detectors/mark-shape.js.map +1 -1
- package/dist/detectors/nado-closed-list.d.ts +3 -0
- package/dist/detectors/nado-closed-list.d.ts.map +1 -0
- package/dist/detectors/nado-closed-list.js +21 -0
- package/dist/detectors/nado-closed-list.js.map +1 -0
- package/dist/detectors/name-variant.d.ts.map +1 -1
- package/dist/detectors/name-variant.js +129 -8
- package/dist/detectors/name-variant.js.map +1 -1
- package/dist/detectors/next-word.d.ts.map +1 -1
- package/dist/detectors/next-word.js +41 -8
- package/dist/detectors/next-word.js.map +1 -1
- package/dist/detectors/number-word-figure.d.ts +5 -0
- package/dist/detectors/number-word-figure.d.ts.map +1 -0
- package/dist/detectors/number-word-figure.js +32 -0
- package/dist/detectors/number-word-figure.js.map +1 -0
- package/dist/detectors/obligation-without-deadline.d.ts +39 -0
- package/dist/detectors/obligation-without-deadline.d.ts.map +1 -0
- package/dist/detectors/obligation-without-deadline.js +148 -0
- package/dist/detectors/obligation-without-deadline.js.map +1 -0
- package/dist/detectors/open-end-names.d.ts +23 -0
- package/dist/detectors/open-end-names.d.ts.map +1 -0
- package/dist/detectors/open-end-names.js +95 -0
- package/dist/detectors/open-end-names.js.map +1 -0
- package/dist/detectors/ordinal-run-gaps.d.ts +8 -0
- package/dist/detectors/ordinal-run-gaps.d.ts.map +1 -0
- package/dist/detectors/ordinal-run-gaps.js +80 -0
- package/dist/detectors/ordinal-run-gaps.js.map +1 -0
- package/dist/detectors/orthographic-variant.d.ts.map +1 -1
- package/dist/detectors/orthographic-variant.js +26 -9
- package/dist/detectors/orthographic-variant.js.map +1 -1
- package/dist/detectors/orthography.d.ts.map +1 -1
- package/dist/detectors/orthography.js +5 -0
- package/dist/detectors/orthography.js.map +1 -1
- package/dist/detectors/parameter-table.d.ts +3 -0
- package/dist/detectors/parameter-table.d.ts.map +1 -0
- package/dist/detectors/parameter-table.js +16 -0
- package/dist/detectors/parameter-table.js.map +1 -0
- 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/phone-number-variant.d.ts +3 -0
- package/dist/detectors/phone-number-variant.d.ts.map +1 -0
- package/dist/detectors/phone-number-variant.js +18 -0
- package/dist/detectors/phone-number-variant.js.map +1 -0
- package/dist/detectors/prerequisite-order.d.ts +3 -0
- package/dist/detectors/prerequisite-order.d.ts.map +1 -0
- package/dist/detectors/prerequisite-order.js +30 -0
- package/dist/detectors/prerequisite-order.js.map +1 -0
- package/dist/detectors/quote-unnamed-speaker.d.ts +3 -0
- package/dist/detectors/quote-unnamed-speaker.d.ts.map +1 -0
- package/dist/detectors/quote-unnamed-speaker.js +18 -0
- package/dist/detectors/quote-unnamed-speaker.js.map +1 -0
- package/dist/detectors/quote-without-source.d.ts +12 -2
- package/dist/detectors/quote-without-source.d.ts.map +1 -1
- package/dist/detectors/quote-without-source.js +45 -11
- package/dist/detectors/quote-without-source.js.map +1 -1
- package/dist/detectors/registry/amount-range.d.ts +3 -0
- package/dist/detectors/registry/amount-range.d.ts.map +1 -0
- package/dist/detectors/registry/amount-range.js +3 -0
- package/dist/detectors/registry/amount-range.js.map +1 -0
- package/dist/detectors/registry/arrival-before-departure.d.ts +3 -0
- package/dist/detectors/registry/arrival-before-departure.d.ts.map +1 -0
- package/dist/detectors/registry/arrival-before-departure.js +3 -0
- package/dist/detectors/registry/arrival-before-departure.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/date-outside-period.d.ts +3 -0
- package/dist/detectors/registry/date-outside-period.d.ts.map +1 -0
- package/dist/detectors/registry/date-outside-period.js +3 -0
- package/dist/detectors/registry/date-outside-period.js.map +1 -0
- package/dist/detectors/registry/default-values.d.ts +3 -0
- package/dist/detectors/registry/default-values.d.ts.map +1 -0
- package/dist/detectors/registry/default-values.js +3 -0
- package/dist/detectors/registry/default-values.js.map +1 -0
- package/dist/detectors/registry/deprecated-use.d.ts +3 -0
- package/dist/detectors/registry/deprecated-use.d.ts.map +1 -0
- package/dist/detectors/registry/deprecated-use.js +3 -0
- package/dist/detectors/registry/deprecated-use.js.map +1 -0
- package/dist/detectors/registry/due-date.d.ts +3 -0
- package/dist/detectors/registry/due-date.d.ts.map +1 -0
- package/dist/detectors/registry/due-date.js +3 -0
- package/dist/detectors/registry/due-date.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/kana-function-word.d.ts +3 -0
- package/dist/detectors/registry/kana-function-word.d.ts.map +1 -0
- package/dist/detectors/registry/kana-function-word.js +3 -0
- package/dist/detectors/registry/kana-function-word.js.map +1 -0
- package/dist/detectors/registry/line-amount.d.ts +3 -0
- package/dist/detectors/registry/line-amount.d.ts.map +1 -0
- package/dist/detectors/registry/line-amount.js +3 -0
- package/dist/detectors/registry/line-amount.js.map +1 -0
- package/dist/detectors/registry/nado-closed-list.d.ts +3 -0
- package/dist/detectors/registry/nado-closed-list.d.ts.map +1 -0
- package/dist/detectors/registry/nado-closed-list.js +3 -0
- package/dist/detectors/registry/nado-closed-list.js.map +1 -0
- package/dist/detectors/registry/number-word-figure.d.ts +3 -0
- package/dist/detectors/registry/number-word-figure.d.ts.map +1 -0
- package/dist/detectors/registry/number-word-figure.js +3 -0
- package/dist/detectors/registry/number-word-figure.js.map +1 -0
- package/dist/detectors/registry/obligation-without-deadline.d.ts +3 -0
- package/dist/detectors/registry/obligation-without-deadline.d.ts.map +1 -0
- package/dist/detectors/registry/obligation-without-deadline.js +3 -0
- package/dist/detectors/registry/obligation-without-deadline.js.map +1 -0
- package/dist/detectors/registry/parameter-table.d.ts +3 -0
- package/dist/detectors/registry/parameter-table.d.ts.map +1 -0
- package/dist/detectors/registry/parameter-table.js +3 -0
- package/dist/detectors/registry/parameter-table.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/phone-number-variant.d.ts +3 -0
- package/dist/detectors/registry/phone-number-variant.d.ts.map +1 -0
- package/dist/detectors/registry/phone-number-variant.js +3 -0
- package/dist/detectors/registry/phone-number-variant.js.map +1 -0
- package/dist/detectors/registry/prerequisite-order.d.ts +3 -0
- package/dist/detectors/registry/prerequisite-order.d.ts.map +1 -0
- package/dist/detectors/registry/prerequisite-order.js +3 -0
- package/dist/detectors/registry/prerequisite-order.js.map +1 -0
- package/dist/detectors/registry/quote-unnamed-speaker.d.ts +3 -0
- package/dist/detectors/registry/quote-unnamed-speaker.d.ts.map +1 -0
- package/dist/detectors/registry/quote-unnamed-speaker.js +3 -0
- package/dist/detectors/registry/quote-unnamed-speaker.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/tax-amount.d.ts +3 -0
- package/dist/detectors/registry/tax-amount.d.ts.map +1 -0
- package/dist/detectors/registry/tax-amount.js +3 -0
- package/dist/detectors/registry/tax-amount.js.map +1 -0
- package/dist/detectors/registry/time-order.d.ts +3 -0
- package/dist/detectors/registry/time-order.d.ts.map +1 -0
- package/dist/detectors/registry/time-order.js +3 -0
- package/dist/detectors/registry/time-order.js.map +1 -0
- package/dist/detectors/registry/ui-label.d.ts +3 -0
- package/dist/detectors/registry/ui-label.d.ts.map +1 -0
- package/dist/detectors/registry/ui-label.js +3 -0
- package/dist/detectors/registry/ui-label.js.map +1 -0
- package/dist/detectors/registry/undefined-call.d.ts +3 -0
- package/dist/detectors/registry/undefined-call.d.ts.map +1 -0
- package/dist/detectors/registry/undefined-call.js +3 -0
- package/dist/detectors/registry/undefined-call.js.map +1 -0
- package/dist/detectors/registry/undefined-term.d.ts +3 -0
- package/dist/detectors/registry/undefined-term.d.ts.map +1 -0
- package/dist/detectors/registry/undefined-term.js +3 -0
- package/dist/detectors/registry/undefined-term.js.map +1 -0
- package/dist/detectors/registry/version-order.d.ts +3 -0
- package/dist/detectors/registry/version-order.d.ts.map +1 -0
- package/dist/detectors/registry/version-order.js +3 -0
- package/dist/detectors/registry/version-order.js.map +1 -0
- package/dist/detectors/registry/warning-action.d.ts +3 -0
- package/dist/detectors/registry/warning-action.d.ts.map +1 -0
- package/dist/detectors/registry/warning-action.js +3 -0
- package/dist/detectors/registry/warning-action.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/requirement-smell.d.ts.map +1 -1
- package/dist/detectors/requirement-smell.js +25 -8
- package/dist/detectors/requirement-smell.js.map +1 -1
- 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/structure-tree.d.ts +12 -4
- package/dist/detectors/structure-tree.d.ts.map +1 -1
- package/dist/detectors/structure-tree.js +40 -15
- package/dist/detectors/structure-tree.js.map +1 -1
- package/dist/detectors/superlative-scope.d.ts.map +1 -1
- package/dist/detectors/superlative-scope.js +11 -1
- package/dist/detectors/superlative-scope.js.map +1 -1
- package/dist/detectors/tax-amount.d.ts +3 -0
- package/dist/detectors/tax-amount.d.ts.map +1 -0
- package/dist/detectors/tax-amount.js +19 -0
- package/dist/detectors/tax-amount.js.map +1 -0
- package/dist/detectors/technical-docs.d.ts.map +1 -1
- package/dist/detectors/technical-docs.js +5 -1
- package/dist/detectors/technical-docs.js.map +1 -1
- package/dist/detectors/term-extension.d.ts +14 -0
- package/dist/detectors/term-extension.d.ts.map +1 -0
- package/dist/detectors/term-extension.js +67 -0
- package/dist/detectors/term-extension.js.map +1 -0
- package/dist/detectors/time-order.d.ts +5 -0
- package/dist/detectors/time-order.d.ts.map +1 -0
- package/dist/detectors/time-order.js +58 -0
- package/dist/detectors/time-order.js.map +1 -0
- package/dist/detectors/ui-label.d.ts +3 -0
- package/dist/detectors/ui-label.d.ts.map +1 -0
- package/dist/detectors/ui-label.js +16 -0
- package/dist/detectors/ui-label.js.map +1 -0
- package/dist/detectors/unbalanced-bracket.d.ts.map +1 -1
- package/dist/detectors/unbalanced-bracket.js +8 -13
- package/dist/detectors/unbalanced-bracket.js.map +1 -1
- package/dist/detectors/undefined-call.d.ts +3 -0
- package/dist/detectors/undefined-call.d.ts.map +1 -0
- package/dist/detectors/undefined-call.js +18 -0
- package/dist/detectors/undefined-call.js.map +1 -0
- package/dist/detectors/undefined-term.d.ts +22 -0
- package/dist/detectors/undefined-term.d.ts.map +1 -0
- package/dist/detectors/undefined-term.js +101 -0
- package/dist/detectors/undefined-term.js.map +1 -0
- package/dist/detectors/unknown-word.d.ts +1 -1
- package/dist/detectors/unknown-word.js +3 -3
- package/dist/detectors/unknown-word.js.map +1 -1
- package/dist/detectors/vague-deadline.d.ts +4 -0
- package/dist/detectors/vague-deadline.d.ts.map +1 -1
- package/dist/detectors/vague-deadline.js +3 -3
- package/dist/detectors/vague-deadline.js.map +1 -1
- package/dist/detectors/version-mismatch.d.ts.map +1 -1
- package/dist/detectors/version-mismatch.js +18 -1
- package/dist/detectors/version-mismatch.js.map +1 -1
- package/dist/detectors/version-order.d.ts +3 -0
- package/dist/detectors/version-order.d.ts.map +1 -0
- package/dist/detectors/version-order.js +43 -0
- package/dist/detectors/version-order.js.map +1 -0
- package/dist/detectors/warning-action.d.ts +3 -0
- package/dist/detectors/warning-action.d.ts.map +1 -0
- package/dist/detectors/warning-action.js +48 -0
- package/dist/detectors/warning-action.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/condition-pairs.d.ts +51 -0
- package/dist/facts/condition-pairs.d.ts.map +1 -0
- package/dist/facts/condition-pairs.js +203 -0
- package/dist/facts/condition-pairs.js.map +1 -0
- package/dist/facts/event-dates.d.ts +26 -0
- package/dist/facts/event-dates.d.ts.map +1 -0
- package/dist/facts/event-dates.js +38 -0
- package/dist/facts/event-dates.js.map +1 -0
- package/dist/facts/fact-scope.d.ts +2 -0
- package/dist/facts/fact-scope.d.ts.map +1 -1
- package/dist/facts/fact-scope.js +5 -0
- package/dist/facts/fact-scope.js.map +1 -1
- package/dist/facts/labelled-facts.d.ts +2 -0
- package/dist/facts/labelled-facts.d.ts.map +1 -1
- package/dist/facts/labelled-facts.js +9 -1
- package/dist/facts/labelled-facts.js.map +1 -1
- package/dist/facts/table-facts.d.ts +18 -0
- package/dist/facts/table-facts.d.ts.map +1 -1
- package/dist/facts/table-facts.js +4 -2
- package/dist/facts/table-facts.js.map +1 -1
- package/dist/grade/ai-score.d.ts +1 -1
- package/dist/grade/ai-score.d.ts.map +1 -1
- package/dist/grade/text.js +2 -2
- package/dist/grade/text.js.map +1 -1
- package/dist/heading-numbering.js +2 -2
- package/dist/heading-numbering.js.map +1 -1
- package/dist/html/fetch-page.d.ts +20 -0
- package/dist/html/fetch-page.d.ts.map +1 -0
- package/dist/html/fetch-page.js +51 -0
- package/dist/html/fetch-page.js.map +1 -0
- package/dist/html/fetched-text.d.ts +5 -0
- package/dist/html/fetched-text.d.ts.map +1 -0
- package/dist/html/fetched-text.js +25 -0
- package/dist/html/fetched-text.js.map +1 -0
- package/dist/html/html-content-block.d.ts +6 -0
- package/dist/html/html-content-block.d.ts.map +1 -0
- package/dist/html/html-content-block.js +86 -0
- package/dist/html/html-content-block.js.map +1 -0
- package/dist/html/html-elements.d.ts +41 -0
- package/dist/html/html-elements.d.ts.map +1 -0
- package/dist/html/html-elements.js +91 -0
- package/dist/html/html-elements.js.map +1 -0
- package/dist/html/html-footnote-marks.d.ts +2 -0
- package/dist/html/html-footnote-marks.d.ts.map +1 -0
- package/dist/html/html-footnote-marks.js +15 -0
- package/dist/html/html-footnote-marks.js.map +1 -0
- package/dist/html/html-heading-links.d.ts +6 -0
- package/dist/html/html-heading-links.d.ts.map +1 -0
- package/dist/html/html-heading-links.js +71 -0
- package/dist/html/html-heading-links.js.map +1 -0
- package/dist/html/html-lost-tags.d.ts +3 -0
- package/dist/html/html-lost-tags.d.ts.map +1 -0
- package/dist/html/html-lost-tags.js +11 -0
- package/dist/html/html-lost-tags.js.map +1 -0
- package/dist/html/html-markdown.d.ts +2 -0
- package/dist/html/html-markdown.d.ts.map +1 -0
- package/dist/html/html-markdown.js +347 -0
- package/dist/html/html-markdown.js.map +1 -0
- package/dist/html/html-preformatted.d.ts +17 -0
- package/dist/html/html-preformatted.d.ts.map +1 -0
- package/dist/html/html-preformatted.js +82 -0
- package/dist/html/html-preformatted.js.map +1 -0
- package/dist/html/html-reader-only.d.ts +6 -0
- package/dist/html/html-reader-only.d.ts.map +1 -0
- package/dist/html/html-reader-only.js +63 -0
- package/dist/html/html-reader-only.js.map +1 -0
- package/dist/html/html-run-in-headings.d.ts +2 -0
- package/dist/html/html-run-in-headings.d.ts.map +1 -0
- package/dist/html/html-run-in-headings.js +36 -0
- package/dist/html/html-run-in-headings.js.map +1 -0
- package/dist/html/html-tables.d.ts +3 -0
- package/dist/html/html-tables.d.ts.map +1 -0
- package/dist/html/html-tables.js +58 -0
- package/dist/html/html-tables.js.map +1 -0
- package/dist/html/html-widgets.d.ts +3 -0
- package/dist/html/html-widgets.d.ts.map +1 -0
- package/dist/html/html-widgets.js +71 -0
- package/dist/html/html-widgets.js.map +1 -0
- package/dist/html/markup-text.d.ts +5 -0
- package/dist/html/markup-text.d.ts.map +1 -0
- package/dist/html/markup-text.js +32 -0
- package/dist/html/markup-text.js.map +1 -0
- package/dist/html/page-document.d.ts +9 -0
- package/dist/html/page-document.d.ts.map +1 -0
- package/dist/html/page-document.js +19 -0
- package/dist/html/page-document.js.map +1 -0
- package/dist/inline-count.d.ts +19 -0
- package/dist/inline-count.d.ts.map +1 -0
- package/dist/inline-count.js +109 -0
- package/dist/inline-count.js.map +1 -0
- package/dist/kana-spelling.d.ts +5 -0
- package/dist/kana-spelling.d.ts.map +1 -1
- package/dist/kana-spelling.js +5 -0
- package/dist/kana-spelling.js.map +1 -1
- package/dist/location-part.d.ts +13 -0
- package/dist/location-part.d.ts.map +1 -0
- package/dist/location-part.js +24 -0
- package/dist/location-part.js.map +1 -0
- package/dist/nado-closed-list.d.ts +20 -0
- package/dist/nado-closed-list.d.ts.map +1 -0
- package/dist/nado-closed-list.js +72 -0
- package/dist/nado-closed-list.js.map +1 -0
- package/dist/name-cue.d.ts +17 -0
- package/dist/name-cue.d.ts.map +1 -0
- package/dist/name-cue.js +29 -0
- package/dist/name-cue.js.map +1 -0
- package/dist/name-variants.d.ts +29 -2
- package/dist/name-variants.d.ts.map +1 -1
- package/dist/name-variants.js +107 -8
- 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/paragraph-runs.d.ts +6 -1
- package/dist/paragraph-runs.d.ts.map +1 -1
- package/dist/paragraph-runs.js +9 -2
- package/dist/paragraph-runs.js.map +1 -1
- package/dist/parameter-table.d.ts +19 -0
- package/dist/parameter-table.d.ts.map +1 -0
- package/dist/parameter-table.js +191 -0
- package/dist/parameter-table.js.map +1 -0
- package/dist/phone-numbers.d.ts +23 -0
- package/dist/phone-numbers.d.ts.map +1 -0
- package/dist/phone-numbers.js +83 -0
- package/dist/phone-numbers.js.map +1 -0
- package/dist/place-names.d.ts +55 -0
- package/dist/place-names.d.ts.map +1 -0
- package/dist/place-names.js +196 -0
- package/dist/place-names.js.map +1 -0
- package/dist/plugin.d.ts +11 -0
- package/dist/plugin.d.ts.map +1 -1
- package/dist/prerequisite-order.d.ts +16 -0
- package/dist/prerequisite-order.d.ts.map +1 -0
- package/dist/prerequisite-order.js +29 -0
- package/dist/prerequisite-order.js.map +1 -0
- package/dist/profile/parse.d.ts.map +1 -1
- package/dist/profile/parse.js +10 -1
- package/dist/profile/parse.js.map +1 -1
- package/dist/reasons.d.ts +2 -0
- package/dist/reasons.d.ts.map +1 -1
- package/dist/reasons.js +2 -0
- package/dist/reasons.js.map +1 -1
- package/dist/render/rules-json.d.ts.map +1 -1
- package/dist/render/rules-json.js +4 -0
- package/dist/render/rules-json.js.map +1 -1
- package/dist/render/rules-table.d.ts.map +1 -1
- package/dist/render/rules-table.js +6 -2
- package/dist/render/rules-table.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/rule-genres.d.ts +5 -2
- package/dist/rule-genres.d.ts.map +1 -1
- package/dist/rule-genres.js +2 -0
- package/dist/rule-genres.js.map +1 -1
- package/dist/rule-load.d.ts.map +1 -1
- package/dist/rule-load.js +2 -1
- package/dist/rule-load.js.map +1 -1
- package/dist/run.d.ts.map +1 -1
- package/dist/run.js +5 -1
- package/dist/run.js.map +1 -1
- package/dist/spelling.d.ts +2 -0
- package/dist/spelling.d.ts.map +1 -1
- package/dist/spelling.js +6 -0
- package/dist/spelling.js.map +1 -1
- package/dist/structure/action-due.d.ts +21 -0
- package/dist/structure/action-due.d.ts.map +1 -0
- package/dist/structure/action-due.js +126 -0
- package/dist/structure/action-due.js.map +1 -0
- package/dist/structure/amount-range.d.ts +30 -0
- package/dist/structure/amount-range.d.ts.map +1 -0
- package/dist/structure/amount-range.js +153 -0
- package/dist/structure/amount-range.js.map +1 -0
- package/dist/structure/amount-scale.d.ts +6 -0
- package/dist/structure/amount-scale.d.ts.map +1 -1
- package/dist/structure/amount-scale.js +13 -0
- package/dist/structure/amount-scale.js.map +1 -1
- package/dist/structure/cite.d.ts +5 -2
- package/dist/structure/cite.d.ts.map +1 -1
- package/dist/structure/cite.js +20 -1
- package/dist/structure/cite.js.map +1 -1
- 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 +12 -0
- package/dist/structure/counted-amounts.d.ts.map +1 -0
- package/dist/structure/counted-amounts.js +30 -0
- package/dist/structure/counted-amounts.js.map +1 -0
- 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 +24 -3
- package/dist/structure/date-order.d.ts.map +1 -1
- package/dist/structure/date-order.js +66 -17
- package/dist/structure/date-order.js.map +1 -1
- package/dist/structure/date-outside-period.d.ts +33 -0
- package/dist/structure/date-outside-period.d.ts.map +1 -0
- package/dist/structure/date-outside-period.js +132 -0
- package/dist/structure/date-outside-period.js.map +1 -0
- package/dist/structure/date-range.d.ts +5 -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/definition-use.d.ts +5 -2
- package/dist/structure/definition-use.d.ts.map +1 -1
- package/dist/structure/definition-use.js +11 -3
- package/dist/structure/definition-use.js.map +1 -1
- package/dist/structure/due-date.d.ts +19 -0
- package/dist/structure/due-date.d.ts.map +1 -0
- package/dist/structure/due-date.js +30 -0
- package/dist/structure/due-date.js.map +1 -0
- package/dist/structure/heading-runs.d.ts +9 -0
- package/dist/structure/heading-runs.d.ts.map +1 -0
- package/dist/structure/heading-runs.js +23 -0
- package/dist/structure/heading-runs.js.map +1 -0
- package/dist/structure/install-pin.d.ts +46 -0
- package/dist/structure/install-pin.d.ts.map +1 -0
- package/dist/structure/install-pin.js +85 -0
- package/dist/structure/install-pin.js.map +1 -0
- package/dist/structure/leg-times.d.ts +36 -0
- package/dist/structure/leg-times.d.ts.map +1 -0
- package/dist/structure/leg-times.js +148 -0
- package/dist/structure/leg-times.js.map +1 -0
- package/dist/structure/line-amount-unit.d.ts +24 -0
- package/dist/structure/line-amount-unit.d.ts.map +1 -0
- package/dist/structure/line-amount-unit.js +24 -0
- package/dist/structure/line-amount-unit.js.map +1 -0
- package/dist/structure/line-amount.d.ts +40 -0
- package/dist/structure/line-amount.d.ts.map +1 -0
- package/dist/structure/line-amount.js +118 -0
- package/dist/structure/line-amount.js.map +1 -0
- package/dist/structure/number-word-figure.d.ts +37 -0
- package/dist/structure/number-word-figure.d.ts.map +1 -0
- package/dist/structure/number-word-figure.js +151 -0
- package/dist/structure/number-word-figure.js.map +1 -0
- package/dist/structure/numbering.d.ts +1 -0
- package/dist/structure/numbering.d.ts.map +1 -1
- package/dist/structure/numbering.js +3 -0
- package/dist/structure/numbering.js.map +1 -1
- package/dist/structure/ordinal-runs.d.ts +45 -0
- package/dist/structure/ordinal-runs.d.ts.map +1 -0
- package/dist/structure/ordinal-runs.js +78 -0
- package/dist/structure/ordinal-runs.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/percent-sum-prose.d.ts +1 -1
- package/dist/structure/percent-sum-prose.d.ts.map +1 -1
- package/dist/structure/percent-sum-prose.js +45 -3
- package/dist/structure/percent-sum-prose.js.map +1 -1
- package/dist/structure/percent-sum.d.ts +8 -0
- package/dist/structure/percent-sum.d.ts.map +1 -1
- package/dist/structure/percent-sum.js +8 -1
- package/dist/structure/percent-sum.js.map +1 -1
- package/dist/structure/release-list.d.ts +9 -0
- package/dist/structure/release-list.d.ts.map +1 -0
- package/dist/structure/release-list.js +46 -0
- package/dist/structure/release-list.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/share-column.d.ts +7 -0
- package/dist/structure/share-column.d.ts.map +1 -0
- package/dist/structure/share-column.js +22 -0
- package/dist/structure/share-column.js.map +1 -0
- package/dist/structure/stated-period.d.ts +31 -0
- package/dist/structure/stated-period.d.ts.map +1 -0
- package/dist/structure/stated-period.js +127 -0
- package/dist/structure/stated-period.js.map +1 -0
- package/dist/structure/tax.d.ts +25 -0
- package/dist/structure/tax.d.ts.map +1 -0
- package/dist/structure/tax.js +86 -0
- package/dist/structure/tax.js.map +1 -0
- package/dist/structure/time-marks.d.ts +58 -0
- package/dist/structure/time-marks.d.ts.map +1 -0
- package/dist/structure/time-marks.js +74 -0
- package/dist/structure/time-marks.js.map +1 -0
- package/dist/structure/time-order.d.ts +42 -0
- package/dist/structure/time-order.d.ts.map +1 -0
- package/dist/structure/time-order.js +107 -0
- package/dist/structure/time-order.js.map +1 -0
- package/dist/structure/title-lines.d.ts +8 -0
- package/dist/structure/title-lines.d.ts.map +1 -0
- package/dist/structure/title-lines.js +27 -0
- package/dist/structure/title-lines.js.map +1 -0
- package/dist/structure/total.d.ts.map +1 -1
- package/dist/structure/total.js +3 -1
- package/dist/structure/total.js.map +1 -1
- package/dist/structure/version-mismatch.d.ts +1 -5
- package/dist/structure/version-mismatch.d.ts.map +1 -1
- package/dist/structure/version-mismatch.js +65 -12
- package/dist/structure/version-mismatch.js.map +1 -1
- package/dist/structure/version-order.d.ts +25 -0
- package/dist/structure/version-order.d.ts.map +1 -0
- package/dist/structure/version-order.js +77 -0
- package/dist/structure/version-order.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/dist/table-text.d.ts +9 -0
- package/dist/table-text.d.ts.map +1 -0
- package/dist/table-text.js +36 -0
- package/dist/table-text.js.map +1 -0
- package/dist/ui-labels.d.ts +16 -0
- package/dist/ui-labels.d.ts.map +1 -0
- package/dist/ui-labels.js +42 -0
- package/dist/ui-labels.js.map +1 -0
- package/dist/undefined-call.d.ts +13 -0
- package/dist/undefined-call.d.ts.map +1 -0
- package/dist/undefined-call.js +55 -0
- package/dist/undefined-call.js.map +1 -0
- package/dist/unnamed-speaker.d.ts +23 -0
- package/dist/unnamed-speaker.d.ts.map +1 -0
- package/dist/unnamed-speaker.js +176 -0
- package/dist/unnamed-speaker.js.map +1 -0
- package/dist/warning-action.d.ts +22 -0
- package/dist/warning-action.d.ts.map +1 -0
- package/dist/warning-action.js +58 -0
- package/dist/warning-action.js.map +1 -0
- package/genres.yaml +2 -0
- package/package.json +4 -3
- package/profiles/statute.yaml +8 -0
- package/rules/agreement-slip.yaml +2 -2
- package/rules/amount-range-reversed.yaml +52 -0
- package/rules/amount-scale-consistency.yaml +4 -4
- package/rules/announced-count-mismatch.yaml +9 -4
- package/rules/arrival-before-departure.yaml +48 -0
- package/rules/connection-time-short.yaml +52 -0
- package/rules/connective-hierarchy.yaml +3 -3
- package/rules/currency-notation-consistency.yaml +2 -2
- package/rules/date-order.yaml +9 -4
- package/rules/date-outside-period.yaml +64 -0
- package/rules/default-value-mismatch.yaml +79 -0
- package/rules/defined-term-form.yaml +9 -7
- package/rules/deprecated-option-used.yaml +78 -0
- package/rules/doubled-nado.yaml +28 -12
- package/rules/due-before-issue.yaml +68 -0
- package/rules/duplicate-definition.yaml +2 -2
- package/rules/duration-mismatch.yaml +15 -4
- package/rules/duration-product-mismatch.yaml +73 -0
- package/rules/heading-echo.yaml +2 -2
- package/rules/hyphen-as-dash.yaml +2 -2
- package/rules/kana-function-word.yaml +58 -0
- package/rules/latin-spacing.yaml +6 -5
- package/rules/line-amount-mismatch.yaml +58 -0
- package/rules/nado-closed-list.yaml +77 -0
- package/rules/name-variant.yaml +20 -2
- package/rules/number-word-figure-mismatch.yaml +76 -0
- package/rules/numbering-gap.yaml +2 -2
- package/rules/obligation-without-deadline.yaml +95 -0
- package/rules/one-sentence-paragraph-run.yaml +2 -3
- package/rules/parameter-table-mismatch.yaml +90 -0
- package/rules/party-order.yaml +84 -0
- package/rules/percent-sum-mismatch.yaml +2 -2
- package/rules/phone-number-variant.yaml +68 -0
- package/rules/prerequisite-after-step.yaml +78 -0
- package/rules/quote-unnamed-speaker.yaml +67 -0
- package/rules/quote-without-source.yaml +6 -6
- package/rules/required-listed-as-preferred.yaml +102 -0
- package/rules/requirement-smell.yaml +3 -3
- package/rules/return-type-mismatch.yaml +79 -0
- package/rules/sentence-initial-conjunction-run.yaml +13 -7
- package/rules/summary-fact-mismatch.yaml +4 -4
- package/rules/tax-mismatch.yaml +71 -0
- package/rules/time-order.yaml +65 -0
- package/rules/title-length.yaml +2 -2
- package/rules/ui-label-variant.yaml +70 -0
- package/rules/unbalanced-bracket.yaml +4 -4
- package/rules/uncomparable-graded.yaml +29 -10
- package/rules/undefined-function-call.yaml +77 -0
- package/rules/undefined-term.yaml +86 -0
- package/rules/unknown-word.yaml +2 -2
- package/rules/unqualified-superlative.yaml +2 -2
- package/rules/use-before-definition.yaml +2 -2
- package/rules/version-mismatch.yaml +12 -4
- package/rules/version-order.yaml +85 -0
- package/rules/very-adjective.yaml +31 -13
- package/rules/warning-without-action.yaml +64 -0
- package/rules/wordy-phrase.yaml +27 -9
- package/src/ai-score/of-document.ts +19 -9
- package/src/ai-score/render.ts +24 -4
- package/src/ai-score/score.ts +24 -3
- package/src/ai-score/signals.ts +12 -2
- package/src/ai-score/text.ts +7 -2
- package/src/announced-count.ts +19 -12
- package/src/check-source.ts +11 -2
- package/src/cli-text.ts +38 -16
- package/src/cli.ts +2 -1
- package/src/commands/cite-claims.ts +103 -0
- package/src/commands/cite-page.ts +61 -0
- package/src/commands/cite-scaffold.ts +27 -0
- package/src/commands/cite.ts +127 -58
- package/src/company-names.ts +202 -0
- package/src/default-values.ts +158 -0
- package/src/deprecated-use.ts +122 -0
- package/src/derived/session-hours.ts +62 -0
- package/src/derived/stays.ts +145 -0
- package/src/derived/time-lengths.ts +226 -0
- package/src/derived/unit-counts.ts +18 -0
- package/src/derived/working-hours.ts +97 -0
- package/src/detectors/acronym-context.ts +10 -2
- package/src/detectors/acronym-expansion.ts +57 -2
- package/src/detectors/address-word.ts +9 -0
- package/src/detectors/agreement-slip.ts +7 -1
- package/src/detectors/ai-phrasing.ts +6 -1
- package/src/detectors/amount-range.ts +54 -0
- package/src/detectors/amount-scale.ts +50 -17
- package/src/detectors/announced-count.ts +29 -11
- package/src/detectors/bare-comparative.ts +7 -2
- package/src/detectors/block-quotation.ts +95 -0
- package/src/detectors/bracket-label.ts +58 -0
- package/src/detectors/capitalised-term.ts +147 -0
- package/src/detectors/citation-entry.ts +20 -5
- package/src/detectors/code-before.ts +14 -0
- package/src/detectors/connective-hierarchy.ts +39 -11
- package/src/detectors/currency-notation.ts +2 -1
- package/src/detectors/date-outside-period.ts +41 -0
- package/src/detectors/default-values.ts +17 -0
- package/src/detectors/defined-term-form.ts +84 -15
- package/src/detectors/definition-use.ts +10 -2
- package/src/detectors/deprecated-use.ts +17 -0
- package/src/detectors/derived-numbers.ts +174 -10
- package/src/detectors/document-shape.ts +6 -1
- package/src/detectors/due-date.ts +47 -0
- package/src/detectors/en-shape.ts +27 -11
- package/src/detectors/fact-consistency.ts +95 -3
- package/src/detectors/heading-echo.ts +11 -1
- package/src/detectors/kana-function-word.ts +71 -0
- package/src/detectors/line-amount.ts +33 -0
- package/src/detectors/location-pointer.ts +30 -0
- package/src/detectors/mark-shape.ts +18 -1
- package/src/detectors/nado-closed-list.ts +25 -0
- package/src/detectors/name-variant.ts +164 -13
- package/src/detectors/next-word.ts +56 -9
- package/src/detectors/number-word-figure.ts +43 -0
- package/src/detectors/obligation-without-deadline.ts +192 -0
- package/src/detectors/open-end-names.ts +140 -0
- package/src/detectors/ordinal-run-gaps.ts +101 -0
- package/src/detectors/orthographic-variant.ts +39 -14
- package/src/detectors/orthography.ts +6 -1
- package/src/detectors/parameter-table.ts +17 -0
- package/src/detectors/party-order.ts +50 -0
- package/src/detectors/phone-number-variant.ts +18 -0
- package/src/detectors/prerequisite-order.ts +35 -0
- package/src/detectors/quote-unnamed-speaker.ts +19 -0
- package/src/detectors/quote-without-source.ts +57 -10
- package/src/detectors/registry/amount-range.ts +4 -0
- package/src/detectors/registry/arrival-before-departure.ts +4 -0
- package/src/detectors/registry/connection-time-short.ts +4 -0
- package/src/detectors/registry/date-outside-period.ts +4 -0
- package/src/detectors/registry/default-values.ts +4 -0
- package/src/detectors/registry/deprecated-use.ts +4 -0
- package/src/detectors/registry/due-date.ts +4 -0
- package/src/detectors/registry/duration-product-mismatch.ts +4 -0
- package/src/detectors/registry/kana-function-word.ts +4 -0
- package/src/detectors/registry/line-amount.ts +4 -0
- package/src/detectors/registry/nado-closed-list.ts +4 -0
- package/src/detectors/registry/number-word-figure.ts +4 -0
- package/src/detectors/registry/obligation-without-deadline.ts +4 -0
- package/src/detectors/registry/parameter-table.ts +4 -0
- package/src/detectors/registry/party-order.ts +4 -0
- package/src/detectors/registry/phone-number-variant.ts +4 -0
- package/src/detectors/registry/prerequisite-order.ts +4 -0
- package/src/detectors/registry/quote-unnamed-speaker.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/tax-amount.ts +4 -0
- package/src/detectors/registry/time-order.ts +4 -0
- package/src/detectors/registry/ui-label.ts +4 -0
- package/src/detectors/registry/undefined-call.ts +4 -0
- package/src/detectors/registry/undefined-term.ts +4 -0
- package/src/detectors/registry/version-order.ts +4 -0
- package/src/detectors/registry/warning-action.ts +4 -0
- package/src/detectors/requirement-lists.ts +65 -0
- package/src/detectors/requirement-smell.ts +29 -9
- package/src/detectors/return-type.ts +30 -0
- package/src/detectors/structure-tree.ts +55 -22
- package/src/detectors/superlative-scope.ts +13 -1
- package/src/detectors/tax-amount.ts +25 -0
- package/src/detectors/technical-docs.ts +7 -1
- package/src/detectors/term-extension.ts +67 -0
- package/src/detectors/time-order.ts +84 -0
- package/src/detectors/ui-label.ts +17 -0
- package/src/detectors/unbalanced-bracket.ts +7 -14
- package/src/detectors/undefined-call.ts +19 -0
- package/src/detectors/undefined-term.ts +120 -0
- package/src/detectors/unknown-word.ts +3 -3
- package/src/detectors/vague-deadline.ts +3 -3
- package/src/detectors/version-mismatch.ts +26 -5
- package/src/detectors/version-order.ts +50 -0
- package/src/detectors/warning-action.ts +49 -0
- package/src/document.ts +4 -1
- package/src/facts/condition-pairs.ts +289 -0
- package/src/facts/event-dates.ts +63 -0
- package/src/facts/fact-scope.ts +6 -0
- package/src/facts/labelled-facts.ts +13 -1
- package/src/facts/table-facts.ts +6 -3
- package/src/grade/ai-score.ts +1 -1
- package/src/grade/text.ts +2 -2
- package/src/heading-numbering.ts +2 -2
- package/src/html/fetch-page.ts +64 -0
- package/src/html/fetched-text.ts +32 -0
- package/src/html/html-content-block.ts +107 -0
- package/src/html/html-elements.ts +127 -0
- package/src/html/html-footnote-marks.ts +20 -0
- package/src/html/html-heading-links.ts +93 -0
- package/src/html/html-lost-tags.ts +14 -0
- package/src/html/html-markdown.ts +481 -0
- package/src/html/html-preformatted.ts +110 -0
- package/src/html/html-reader-only.ts +82 -0
- package/src/html/html-run-in-headings.ts +43 -0
- package/src/html/html-tables.ts +76 -0
- package/src/html/html-widgets.ts +114 -0
- package/src/html/markup-text.ts +35 -0
- package/src/html/page-document.ts +22 -0
- package/src/inline-count.ts +146 -0
- package/src/kana-spelling.ts +7 -0
- package/src/location-part.ts +30 -0
- package/src/nado-closed-list.ts +106 -0
- package/src/name-cue.ts +35 -0
- package/src/name-variants.ts +133 -12
- package/src/name-word-order.ts +149 -0
- package/src/paragraph-runs.ts +12 -2
- package/src/parameter-table.ts +208 -0
- package/src/phone-numbers.ts +98 -0
- package/src/place-names.ts +248 -0
- package/src/plugin.ts +9 -0
- package/src/prerequisite-order.ts +39 -0
- package/src/profile/parse.ts +10 -1
- package/src/reasons.ts +4 -0
- package/src/render/rules-json.ts +4 -0
- package/src/render/rules-table.ts +6 -3
- package/src/return-type.ts +361 -0
- package/src/rule-genres.ts +5 -2
- package/src/rule-load.ts +3 -2
- package/src/run.ts +3 -1
- package/src/spelling.ts +8 -0
- package/src/structure/action-due.ts +179 -0
- package/src/structure/amount-range.ts +219 -0
- package/src/structure/amount-scale.ts +18 -0
- package/src/structure/cite.ts +21 -2
- package/src/structure/connection-times.ts +226 -0
- package/src/structure/counted-amounts.ts +42 -0
- package/src/structure/date-order-tie.ts +86 -0
- package/src/structure/date-order.ts +100 -23
- package/src/structure/date-outside-period.ts +192 -0
- package/src/structure/date-range.ts +45 -9
- package/src/structure/definition-use.ts +24 -3
- package/src/structure/due-date.ts +46 -0
- package/src/structure/heading-runs.ts +24 -0
- package/src/structure/install-pin.ts +115 -0
- package/src/structure/leg-times.ts +213 -0
- package/src/structure/line-amount-unit.ts +35 -0
- package/src/structure/line-amount.ts +162 -0
- package/src/structure/number-word-figure.ts +199 -0
- package/src/structure/numbering.ts +3 -0
- package/src/structure/ordinal-runs.ts +107 -0
- package/src/structure/party-order.ts +115 -0
- package/src/structure/percent-sum-prose.ts +46 -3
- package/src/structure/percent-sum.ts +16 -2
- package/src/structure/release-list.ts +69 -0
- package/src/structure/requirement-lists.ts +145 -0
- package/src/structure/share-column.ts +25 -0
- package/src/structure/stated-period.ts +161 -0
- package/src/structure/tax.ts +114 -0
- package/src/structure/time-marks.ts +127 -0
- package/src/structure/time-order.ts +141 -0
- package/src/structure/title-lines.ts +33 -0
- package/src/structure/total.ts +5 -1
- package/src/structure/version-mismatch.ts +67 -13
- package/src/structure/version-order.ts +94 -0
- package/src/surname-near.ts +31 -0
- package/src/table-cells.ts +41 -0
- package/src/table-names.ts +113 -0
- package/src/table-text.ts +39 -0
- package/src/ui-labels.ts +55 -0
- package/src/undefined-call.ts +65 -0
- package/src/unnamed-speaker.ts +224 -0
- package/src/warning-action.ts +73 -0
- package/styles/koyobun.yaml +7 -4
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
// A name the document calls deprecated (`indent` is deprecated; | `indent` | 0 | 非推奨 |) still used in one of its code
|
|
2
|
+
// examples ({ indent: 2 }, --indent, indent=2). Pure; reads the Markdown source. The words that mark a name deprecated
|
|
3
|
+
// (deprecated, 非推奨) and the phrases that negate them come from the language's lexicons.
|
|
4
|
+
import { codeFences } from "./detectors/code-fences.ts";
|
|
5
|
+
|
|
6
|
+
/** A deprecated name used in code: where it is used, and where the document calls it deprecated. */
|
|
7
|
+
export type DeprecatedUse = { readonly name: string; readonly offset: number; readonly marked: number };
|
|
8
|
+
|
|
9
|
+
/** The lowercase words that mark a name deprecated, and the phrases that negate one ("not deprecated", 非推奨ではな). */
|
|
10
|
+
export type DeprecationWords = { readonly words: readonly string[]; readonly negated: readonly string[] };
|
|
11
|
+
|
|
12
|
+
type Line = { readonly text: string; readonly start: number };
|
|
13
|
+
type Marked = { readonly name: string; readonly offset: number };
|
|
14
|
+
type Span = { readonly start: number; readonly end: number };
|
|
15
|
+
type Found = { readonly at: number; readonly end: number };
|
|
16
|
+
|
|
17
|
+
/** A name in code marks: `indent`, or the flag `--indent`, which is the name indent. */
|
|
18
|
+
const CODE_SPAN = /`-{0,2}([A-Za-z_$][\w$-]*)`/gu;
|
|
19
|
+
const FIRST_CELL_NAME = /`-{0,2}([A-Za-z_$][\w$-]*)`|^\s*-{0,2}([A-Za-z_$][\w$-]*)\s*$/u;
|
|
20
|
+
const TABLE_ROW = /^[ \t]{0,3}\|/u;
|
|
21
|
+
/** An anchor before a field name in a table cell: <a name="schemaExample"></a>example. */
|
|
22
|
+
const HTML_TAG = /<[^<>]*>/gu;
|
|
23
|
+
/** Where one statement ends: a sentence or a clause after a semicolon ("`indent` is deprecated; use `prefix`"). */
|
|
24
|
+
const STATEMENT_END = /[.;。;!?!?]/u;
|
|
25
|
+
/** A block that declares an API (interface Options { indent: number }) documents the name, and does not use it. */
|
|
26
|
+
const DECLARATION_BLOCK = /^[ \t]*(?:export[ \t]+)?(?:interface|class|type[ \t]+[\w$]+[ \t]*=)/mu;
|
|
27
|
+
|
|
28
|
+
const linesOf = (source: string): Line[] => {
|
|
29
|
+
const starts = [0, ...[...source.matchAll(/\n/gu)].map((match) => match.index + 1)];
|
|
30
|
+
return starts.map((start, index) => ({ text: source.slice(start, (starts[index + 1] ?? source.length + 1) - 1), start }));
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const insideOne = (spans: readonly Span[], offset: number): boolean => spans.some((span) => offset >= span.start && offset < span.end);
|
|
34
|
+
|
|
35
|
+
const occurrences = (text: string, words: readonly string[]): Found[] => {
|
|
36
|
+
const lower = text.toLowerCase();
|
|
37
|
+
return words.flatMap((word) => {
|
|
38
|
+
const found: Found[] = [];
|
|
39
|
+
for (let at = lower.indexOf(word); at !== -1; at = lower.indexOf(word, at + word.length)) found.push({ at, end: at + word.length });
|
|
40
|
+
return found;
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
/** The deprecation words in a text, less those inside a negated phrase ("is not deprecated"). */
|
|
45
|
+
const wordsIn = (text: string, words: DeprecationWords): Found[] => {
|
|
46
|
+
const negated = occurrences(text, words.negated);
|
|
47
|
+
return occurrences(text, words.words).filter((word) => !negated.some((phrase) => phrase.at <= word.at && word.end <= phrase.end));
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
/** Characters between a code span and the word: "`indent` を非推奨" is nearer than "非推奨にし、`prefix`". */
|
|
51
|
+
const gap = (span: Found, word: Found): number => (span.end <= word.at ? word.at - span.end : span.at - word.end);
|
|
52
|
+
|
|
53
|
+
/** A table row's first-cell name, and whether its later cells call it deprecated. */
|
|
54
|
+
const rowOf = (line: Line, words: DeprecationWords): (Marked & { readonly deprecated: boolean }) | undefined => {
|
|
55
|
+
const cells = line.text.split("|");
|
|
56
|
+
const first = cells.findIndex((cell) => cell.trim() !== "");
|
|
57
|
+
if (first === -1) return undefined;
|
|
58
|
+
const name = FIRST_CELL_NAME.exec((cells[first] ?? "").replace(HTML_TAG, ""));
|
|
59
|
+
const written = name?.[1] ?? name?.[2];
|
|
60
|
+
const deprecated = wordsIn(cells.slice(first + 1).join("|"), words).length > 0;
|
|
61
|
+
return written === undefined ? undefined : { name: written, offset: line.start + line.text.indexOf(written), deprecated };
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const markedInRow = (line: Line, words: DeprecationWords): Marked[] => {
|
|
65
|
+
const row = rowOf(line, words);
|
|
66
|
+
return row?.deprecated === true ? [{ name: row.name, offset: row.offset }] : [];
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Names a table also lists without calling them deprecated: one page may describe two fields of one name, of which only
|
|
71
|
+
* one is deprecated (an example field of one object, and of another), and an example cannot tell which it uses.
|
|
72
|
+
*/
|
|
73
|
+
const listedAlive = (lines: readonly Line[], words: DeprecationWords): Set<string> =>
|
|
74
|
+
new Set(
|
|
75
|
+
lines.flatMap((line) => (line.text.includes("|") ? [rowOf(line, words)] : [])).flatMap((row) => (row === undefined || row.deprecated ? [] : [row.name])),
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
/** In a statement, the code name nearest to each deprecation word: "`indent` is deprecated", "Deprecated: `indent`". */
|
|
79
|
+
const markedInProse = (line: Line, words: DeprecationWords): Marked[] =>
|
|
80
|
+
wordsIn(line.text, words).flatMap((word) => {
|
|
81
|
+
const { at } = word;
|
|
82
|
+
const from = Math.max(...[...line.text.slice(0, at).matchAll(new RegExp(STATEMENT_END, "gu"))].map((match) => match.index + 1), 0);
|
|
83
|
+
const after = line.text.slice(at).search(STATEMENT_END);
|
|
84
|
+
const to = after === -1 ? line.text.length : at + after;
|
|
85
|
+
const spans = [...line.text.slice(from, to).matchAll(CODE_SPAN)].map((match) => ({
|
|
86
|
+
name: match[1] ?? "",
|
|
87
|
+
at: from + match.index,
|
|
88
|
+
end: from + match.index + match[0].length,
|
|
89
|
+
}));
|
|
90
|
+
const nearest = spans.toSorted((left, right) => gap(left, word) - gap(right, word))[0];
|
|
91
|
+
return nearest === undefined ? [] : [{ name: nearest.name, offset: line.start + line.text.indexOf(nearest.name, nearest.at) }];
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
const escape = (text: string): string => text.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&");
|
|
95
|
+
|
|
96
|
+
/** A name used as an option in code: a key ({ indent: 2 }, "indent": 2), an argument (indent=2) or a flag (--indent). */
|
|
97
|
+
const usePattern = (name: string): RegExp =>
|
|
98
|
+
new RegExp(`(?:(?<![\\w$.-])["']?${escape(name)}["']?[ \\t]*(?::(?!:)|=(?!=))|(?<![\\w-])--${escape(name)}(?![\\w-]))`, "u");
|
|
99
|
+
|
|
100
|
+
const usesIn = (line: Line, marks: ReadonlyMap<string, number>): DeprecatedUse[] =>
|
|
101
|
+
[...marks].flatMap(([name, marked]) => {
|
|
102
|
+
const match = usePattern(name).exec(line.text);
|
|
103
|
+
return match === null ? [] : [{ name, offset: line.start + match.index + match[0].indexOf(name), marked }];
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* The code lines that use a name the document calls deprecated. A code line that says so itself (`indent: 2 // deprecated`)
|
|
108
|
+
* shows the old use on purpose and is left out, and so is a block that declares an API rather than using it.
|
|
109
|
+
*/
|
|
110
|
+
export const deprecatedUses = (source: string, words: DeprecationWords): DeprecatedUse[] => {
|
|
111
|
+
if (words.words.length === 0) return [];
|
|
112
|
+
const fences = codeFences(source);
|
|
113
|
+
const lines = linesOf(source);
|
|
114
|
+
const prose = lines.filter((line) => !insideOne(fences, line.start));
|
|
115
|
+
const alive = listedAlive(prose, words);
|
|
116
|
+
const marked = prose
|
|
117
|
+
.flatMap((line) => (TABLE_ROW.test(line.text) ? markedInRow(line, words) : markedInProse(line, words)))
|
|
118
|
+
.filter((mark) => !alive.has(mark.name));
|
|
119
|
+
const firstMark = new Map(marked.toReversed().map((mark) => [mark.name, mark.offset]));
|
|
120
|
+
const examples = fences.filter((fence) => !DECLARATION_BLOCK.test(source.slice(fence.start, fence.end)));
|
|
121
|
+
return lines.filter((line) => insideOne(examples, line.start) && wordsIn(line.text, words).length === 0).flatMap((line) => usesIn(line, firstMark));
|
|
122
|
+
};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { Span } from "../plugin.ts";
|
|
2
|
+
import type { Mark } from "../structure/time-marks.ts";
|
|
3
|
+
import { labelOf, readScopes, within, type TimeLength } from "./time-lengths.ts";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* A number of sessions times the length of one against the stated total (90分×15回(計24時間), 15 sessions of 90
|
|
7
|
+
* minutes, 24 hours in total). Read in one line, or in a list whose items say it together, holding exactly one count of
|
|
8
|
+
* two or more sessions, one length of a session and one total. A total written as approximate (約24時間, about 24 hours)
|
|
9
|
+
* may differ by less than the smallest unit it is written in. Pure.
|
|
10
|
+
*/
|
|
11
|
+
export type Count = Span & { readonly amount: number };
|
|
12
|
+
|
|
13
|
+
export type SessionHoursWords = { readonly totals: readonly Mark[]; readonly approximate: readonly Mark[] };
|
|
14
|
+
|
|
15
|
+
export type SessionHoursMismatch = {
|
|
16
|
+
readonly count: Count;
|
|
17
|
+
readonly length: TimeLength;
|
|
18
|
+
readonly total: TimeLength;
|
|
19
|
+
/** The count times the length, in minutes. */
|
|
20
|
+
readonly expected: number;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const overlaps = (left: Span, right: Span): boolean => left.start < right.end && right.start < left.end;
|
|
24
|
+
|
|
25
|
+
type Statement = { readonly count: Count; readonly length: TimeLength; readonly total: TimeLength };
|
|
26
|
+
|
|
27
|
+
/** The length with a rough mark written before it taken in (計約24時間 reads its label past 約). */
|
|
28
|
+
const withRoughMark = (text: string, length: TimeLength, words: SessionHoursWords): Span => {
|
|
29
|
+
const mark = labelOf(text, length, words.approximate);
|
|
30
|
+
return mark !== undefined && mark.end <= length.start ? { start: mark.start, end: length.end } : length;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const statementIn = (text: string, scope: Span, counts: readonly Count[], lengths: readonly TimeLength[], words: SessionHoursWords) => {
|
|
34
|
+
const inCounts = counts.filter((count) => count.amount > 1 && within(count, scope));
|
|
35
|
+
const inLengths = lengths.filter((length) => within(length, scope));
|
|
36
|
+
const totals = inLengths.filter((length) => labelOf(text, withRoughMark(text, length, words), words.totals) !== undefined);
|
|
37
|
+
const sessions = inLengths.filter((length) => !totals.includes(length));
|
|
38
|
+
const [count, length, total] = [inCounts[0], sessions[0], totals[0]];
|
|
39
|
+
if (inCounts.length !== 1 || sessions.length !== 1 || totals.length !== 1 || count === undefined || length === undefined || total === undefined)
|
|
40
|
+
return undefined;
|
|
41
|
+
if (overlaps(count, length) || labelOf(text, length, words.approximate) !== undefined) return undefined;
|
|
42
|
+
return { count, length, total } satisfies Statement;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const allowanceOf = (text: string, total: TimeLength, words: SessionHoursWords): number =>
|
|
46
|
+
labelOf(text, total, words.approximate) === undefined ? 0 : total.unit;
|
|
47
|
+
|
|
48
|
+
/** Sessions whose count times length is not the stated total. counts are the written counts of sessions (15回, 15 sessions). */
|
|
49
|
+
export const sessionHoursMismatches = (
|
|
50
|
+
text: string,
|
|
51
|
+
source: string,
|
|
52
|
+
sentences: readonly Span[],
|
|
53
|
+
counts: readonly Count[],
|
|
54
|
+
lengths: readonly TimeLength[],
|
|
55
|
+
words: SessionHoursWords,
|
|
56
|
+
): SessionHoursMismatch[] =>
|
|
57
|
+
readScopes(text, source, { sentences, times: [] }, (scope) => statementIn(text, scope, counts, lengths, words)).flatMap(({ count, length, total }) => {
|
|
58
|
+
const expected = count.amount * length.minutes;
|
|
59
|
+
const allowance = allowanceOf(text, total, words);
|
|
60
|
+
if (allowance === 0 ? expected === total.minutes : Math.abs(expected - total.minutes) < allowance) return [];
|
|
61
|
+
return [{ count, length, total, expected }];
|
|
62
|
+
});
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import type { Span } from "../plugin.ts";
|
|
2
|
+
import { bySentence } from "./sentence-buckets.ts";
|
|
3
|
+
import { calendarDateOf, dateOf, shifted } from "./date-arithmetic.ts";
|
|
4
|
+
import type { DatedValue } from "./durations.ts";
|
|
5
|
+
import { cellsOf, tablesOf, type Cell } from "../facts/table-facts.ts";
|
|
6
|
+
import { linesOf } from "../structure/lines.ts";
|
|
7
|
+
import { withoutEdgeMarks } from "../facts/trim-marks.ts";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* 泊数。チェックインからチェックアウトまでの泊数は、二つの日付の差の日数(10月12日から10月14日までは2泊)。
|
|
11
|
+
* 一つの文に日付がちょうど二つと泊数がちょうど一つあるときと、チェックイン・チェックアウト・泊数の列がそろった表の行で比べる。
|
|
12
|
+
* 「2泊3日」のように泊数と日数を並べたものは、日数が泊数より一つ多いかを見る。Pure.
|
|
13
|
+
*/
|
|
14
|
+
export type Count = Span & { readonly amount: number };
|
|
15
|
+
|
|
16
|
+
export type NightsMismatch = { readonly start: DatedValue; readonly end: DatedValue; readonly nights: Span; readonly expected: number };
|
|
17
|
+
|
|
18
|
+
export type NightsDaysMismatch = { readonly nights: Count; readonly days: Count; readonly expected: number };
|
|
19
|
+
|
|
20
|
+
export type StayColumnWords = {
|
|
21
|
+
readonly checkIn: readonly string[];
|
|
22
|
+
readonly checkOut: readonly string[];
|
|
23
|
+
readonly nights: readonly string[];
|
|
24
|
+
/** The words of a nights unit (泊, nights) a nights cell may write after its number. */
|
|
25
|
+
readonly units: readonly string[];
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const DAY_MS = 86_400_000;
|
|
29
|
+
|
|
30
|
+
type Between = { start: DatedValue; end: DatedValue; nights: number };
|
|
31
|
+
|
|
32
|
+
const daysFrom = (from: Date, to: Date): number => Math.round((to.getTime() - from.getTime()) / DAY_MS);
|
|
33
|
+
|
|
34
|
+
/** 月日だけの二つの日付は、近いほうの向き(12月30日と1月2日は年をまたいで3泊、10月14日と10月12日は2泊)。 */
|
|
35
|
+
const nearerWay = (first: DatedValue, second: DatedValue, firstDay: Date, secondDay: Date): Between => {
|
|
36
|
+
const forward = daysFrom(firstDay, secondDay);
|
|
37
|
+
const ahead = forward < 0 ? daysFrom(firstDay, shifted(secondDay, 1, "year")) : forward;
|
|
38
|
+
const back = -forward < 0 ? daysFrom(secondDay, shifted(firstDay, 1, "year")) : -forward;
|
|
39
|
+
return back < ahead ? { start: second, end: first, nights: back } : { start: first, end: second, nights: ahead };
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
/** 二つの日付の間の泊数。年まで書いたら早いほうから。年の有る日付と無い日付の組は読まない。 */
|
|
43
|
+
const nightsBetween = (first: DatedValue, second: DatedValue): Between | undefined => {
|
|
44
|
+
const [firstDate, secondDate] = [calendarDateOf(first.value), calendarDateOf(second.value)];
|
|
45
|
+
if (firstDate === undefined || secondDate === undefined || (firstDate.year === undefined) !== (secondDate.year === undefined)) return undefined;
|
|
46
|
+
const [firstDay, secondDay] = [dateOf(firstDate), dateOf(secondDate)];
|
|
47
|
+
if (firstDate.year === undefined) return nearerWay(first, second, firstDay, secondDay);
|
|
48
|
+
const forward = daysFrom(firstDay, secondDay);
|
|
49
|
+
return forward < 0 ? { start: second, end: first, nights: -forward } : { start: first, end: second, nights: forward };
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const mismatchOf = (first: DatedValue, second: DatedValue, nights: Count): NightsMismatch | undefined => {
|
|
53
|
+
const between = nightsBetween(first, second);
|
|
54
|
+
if (between === undefined || between.nights <= 0 || between.nights === nights.amount) return undefined;
|
|
55
|
+
return { start: between.start, end: between.end, nights, expected: between.nights };
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
/** 一つの文の中の、二つの日付と泊数。 */
|
|
59
|
+
export const stayNightsMismatches = (sentences: readonly Span[], dates: readonly DatedValue[], nights: readonly Count[]): NightsMismatch[] => {
|
|
60
|
+
const datesIn = bySentence(sentences, dates);
|
|
61
|
+
return [...bySentence(sentences, nights).entries()].flatMap(([index, inNights]) => {
|
|
62
|
+
const inDates = datesIn.get(index) ?? [];
|
|
63
|
+
const [first, second] = inDates;
|
|
64
|
+
const [count] = inNights;
|
|
65
|
+
if (inDates.length !== 2 || inNights.length !== 1 || first === undefined || second === undefined || count === undefined) return [];
|
|
66
|
+
const mismatch = mismatchOf(first, second, count);
|
|
67
|
+
return mismatch === undefined ? [] : [mismatch];
|
|
68
|
+
});
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
const normalizedGap = (text: string): string => text.normalize("NFKC").trim().toLowerCase().replace(/\s+/gu, " ");
|
|
72
|
+
|
|
73
|
+
const joined = (source: string, left: Span, right: Span, joiners: readonly string[]): boolean => {
|
|
74
|
+
if (right.start < left.end) return false;
|
|
75
|
+
const gap = normalizedGap(source.slice(left.end, right.start));
|
|
76
|
+
return gap === "" || joiners.some((joiner) => normalizedGap(joiner) === gap);
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
/** 泊数と日数を並べたもの(2泊3日、2 days, 1 night)。泊数の直前か直後に、つなぎの語だけを挟んで日数がある。 */
|
|
80
|
+
export const nightsDaysPairs = (
|
|
81
|
+
source: string,
|
|
82
|
+
nights: readonly Count[],
|
|
83
|
+
days: readonly Count[],
|
|
84
|
+
joiners: readonly string[],
|
|
85
|
+
): { nights: Count; days: Count }[] =>
|
|
86
|
+
nights.flatMap((count) => {
|
|
87
|
+
const paired = days.find((day) => joined(source, count, day, joiners) || joined(source, day, count, joiners));
|
|
88
|
+
return paired === undefined ? [] : [{ nights: count, days: paired }];
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
/** 日数が泊数より一つ多くない組。 */
|
|
92
|
+
export const nightsDaysMismatches = (pairs: readonly { nights: Count; days: Count }[]): NightsDaysMismatch[] =>
|
|
93
|
+
pairs.flatMap((pair) => (pair.days.amount === pair.nights.amount + 1 ? [] : [{ ...pair, expected: pair.nights.amount + 1 }]));
|
|
94
|
+
|
|
95
|
+
const keyOf = (text: string): string => withoutEdgeMarks(text).normalize("NFKC").toLowerCase().replace(/\s+/gu, " ");
|
|
96
|
+
|
|
97
|
+
const columnOf = (header: readonly Cell[], names: readonly string[]): number => {
|
|
98
|
+
const wanted = new Set(names.map(keyOf));
|
|
99
|
+
return header.findIndex((cell) => wanted.has(keyOf(cell.text)));
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
const LEADING_DIGITS = /^\d+/u;
|
|
103
|
+
|
|
104
|
+
/** 泊数の升の数(「2」「2泊」「2 nights」)。それ以外を書いた升は読まない。 */
|
|
105
|
+
const nightsInCell = (cell: Cell, units: readonly string[]): Count | undefined => {
|
|
106
|
+
const key = keyOf(cell.text);
|
|
107
|
+
const digits = LEADING_DIGITS.exec(key)?.[0];
|
|
108
|
+
if (digits === undefined) return undefined;
|
|
109
|
+
const rest = key.slice(digits.length).trim();
|
|
110
|
+
if (rest !== "" && !units.some((unit) => keyOf(unit) === rest)) return undefined;
|
|
111
|
+
const offset = cell.text.length - cell.text.trimStart().length;
|
|
112
|
+
return { start: cell.start + offset, end: cell.end, amount: Number(digits) };
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
const onlyDateIn = (cell: Cell | undefined, dates: readonly DatedValue[]): DatedValue | undefined => {
|
|
116
|
+
if (cell === undefined) return undefined;
|
|
117
|
+
const inside = dates.filter((date) => date.start >= cell.start && date.end <= cell.end);
|
|
118
|
+
return inside.length === 1 ? inside[0] : undefined;
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
type StayColumns = { readonly checkIn: number; readonly checkOut: number; readonly nights: number };
|
|
122
|
+
|
|
123
|
+
const rowMismatch = (cells: readonly Cell[], columns: StayColumns, dates: readonly DatedValue[], units: readonly string[]): NightsMismatch | undefined => {
|
|
124
|
+
const checkIn = onlyDateIn(cells[columns.checkIn], dates);
|
|
125
|
+
const checkOut = onlyDateIn(cells[columns.checkOut], dates);
|
|
126
|
+
const nightsCell = cells[columns.nights];
|
|
127
|
+
const nights = nightsCell === undefined ? undefined : nightsInCell(nightsCell, units);
|
|
128
|
+
return checkIn === undefined || checkOut === undefined || nights === undefined ? undefined : mismatchOf(checkIn, checkOut, nights);
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
/** チェックイン・チェックアウト・泊数の列がある表の、行ごとの泊数。 */
|
|
132
|
+
export const tableNightsMismatches = (source: string, dates: readonly DatedValue[], words: StayColumnWords): NightsMismatch[] =>
|
|
133
|
+
tablesOf(linesOf(source)).flatMap(({ header, rows }) => {
|
|
134
|
+
const headerCells = cellsOf(header);
|
|
135
|
+
const columns = {
|
|
136
|
+
checkIn: columnOf(headerCells, words.checkIn),
|
|
137
|
+
checkOut: columnOf(headerCells, words.checkOut),
|
|
138
|
+
nights: columnOf(headerCells, words.nights),
|
|
139
|
+
};
|
|
140
|
+
if (Object.values(columns).some((index) => index < 0)) return [];
|
|
141
|
+
return rows.flatMap((row) => {
|
|
142
|
+
const mismatch = rowMismatch(cellsOf(row), columns, dates, words.units);
|
|
143
|
+
return mismatch === undefined ? [] : [mismatch];
|
|
144
|
+
});
|
|
145
|
+
});
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
import type { Span } from "../plugin.ts";
|
|
2
|
+
import { escapeRegExp } from "../orthography.ts";
|
|
3
|
+
import { isWordAt, wordOffsets, type Mark } from "../structure/time-marks.ts";
|
|
4
|
+
import { linesOf } from "../structure/lines.ts";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Lengths of time in hours and minutes (8時間, 7時間30分, 90分, 1-hour, one-hour, 7.5 hours), the words written beside
|
|
8
|
+
* them (実働8時間, 8 hours a day), and the stretches of text a statement of hours is read in. The words come from the
|
|
9
|
+
* language packages; nothing here knows a language. Pure.
|
|
10
|
+
*/
|
|
11
|
+
export type TimeLength = Span & {
|
|
12
|
+
readonly minutes: number;
|
|
13
|
+
/** The smallest unit the length is written in, in minutes: 60 for 24時間, 1 for 90分 or 7時間30分, 30 for 7時間半. */
|
|
14
|
+
readonly unit: number;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export type LengthWords = {
|
|
18
|
+
readonly hourUnits: readonly string[];
|
|
19
|
+
readonly minuteUnits: readonly string[];
|
|
20
|
+
/** What written right after the hour unit adds half an hour (7時間半). */
|
|
21
|
+
readonly halves: readonly string[];
|
|
22
|
+
/** Numbers written as words, in order from one. */
|
|
23
|
+
readonly numberWords: readonly string[];
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const MINUTES_PER_HOUR = 60;
|
|
27
|
+
const HALF_HOUR = 30;
|
|
28
|
+
|
|
29
|
+
const alternation = (words: readonly string[]): string =>
|
|
30
|
+
words
|
|
31
|
+
.filter((word) => word !== "")
|
|
32
|
+
.toSorted((left, right) => right.length - left.length)
|
|
33
|
+
.map(escapeRegExp)
|
|
34
|
+
.join("|");
|
|
35
|
+
|
|
36
|
+
const LATIN_END = /[a-z]$/iu;
|
|
37
|
+
const LATIN_START = /^[a-z]/iu;
|
|
38
|
+
|
|
39
|
+
const numberOf = (written: string, numberWords: readonly string[]): number => {
|
|
40
|
+
const position = numberWords.findIndex((word) => word.toLowerCase() === written.toLowerCase());
|
|
41
|
+
return position >= 0 ? position + 1 : Number(written.normalize("NFKC"));
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
/** A digit number not inside a longer one, or a number word standing as a word of its own. */
|
|
45
|
+
const numberPattern = (numberWords: readonly string[]): string => {
|
|
46
|
+
const words = alternation(numberWords);
|
|
47
|
+
const digits = "(?<![\\p{N}.,./⁄])(\\p{Nd}+(?:[..]\\p{Nd}+)?)";
|
|
48
|
+
return words === "" ? digits : `(?:${digits}|(?<![\\p{L}\\p{N}\\p{Pd}])(${words}))`;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const SEPARATOR = "[\\s\\-‐]?";
|
|
52
|
+
|
|
53
|
+
type Read = { readonly span: Span; readonly minutes: number; readonly unit: number };
|
|
54
|
+
|
|
55
|
+
/** A Latin unit runs on into a longer word ("8 hoursx") or a letter-led tail: not a length. */
|
|
56
|
+
const runsOn = (text: string, end: number): boolean => LATIN_END.test(text.slice(end - 1, end)) && LATIN_START.test(text.charAt(end));
|
|
57
|
+
|
|
58
|
+
const DECIMAL_BASE = 10;
|
|
59
|
+
|
|
60
|
+
/** 7.5 hours is written to a tenth of an hour, 6 minutes. */
|
|
61
|
+
const hourStep = (number: string | undefined): number => {
|
|
62
|
+
const decimals = (number ?? "").normalize("NFKC").split(".")[1]?.length ?? 0;
|
|
63
|
+
return MINUTES_PER_HOUR / DECIMAL_BASE ** decimals;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
const smallestUnit = (number: string | undefined, minutes: string | undefined, half: string | undefined): number => {
|
|
67
|
+
if (minutes !== undefined) return 1;
|
|
68
|
+
return half === undefined ? hourStep(number) : Math.min(HALF_HOUR, hourStep(number));
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
const hourLengths = (text: string, words: LengthWords): Read[] => {
|
|
72
|
+
const [hours, minutes, halves] = [alternation(words.hourUnits), alternation(words.minuteUnits), alternation(words.halves)];
|
|
73
|
+
if (hours === "") return [];
|
|
74
|
+
const minutePart = minutes === "" ? "" : `|\\s?(\\p{Nd}{1,2})\\s?(?:${minutes})`;
|
|
75
|
+
const halfPart = halves === "" ? "" : `|\\s?(${halves})`;
|
|
76
|
+
const tail = minutePart === "" && halfPart === "" ? "" : `(?:${minutePart.slice(1)}${halfPart})?`;
|
|
77
|
+
const pattern = new RegExp(`${numberPattern(words.numberWords)}${SEPARATOR}(?:${hours})${tail}`, "giu");
|
|
78
|
+
return [...text.matchAll(pattern)].flatMap((match): Read[] => {
|
|
79
|
+
const end = match.index + match[0].length;
|
|
80
|
+
if (runsOn(text, end)) return [];
|
|
81
|
+
const amount = numberOf(match[1] ?? match[2] ?? "", words.numberWords);
|
|
82
|
+
const extra = match[3] === undefined ? 0 : Number(match[3].normalize("NFKC"));
|
|
83
|
+
const half = match[4] === undefined ? 0 : HALF_HOUR;
|
|
84
|
+
return [{ span: { start: match.index, end }, minutes: amount * MINUTES_PER_HOUR + extra + half, unit: smallestUnit(match[1], match[3], match[4]) }];
|
|
85
|
+
});
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
const minuteLengths = (text: string, words: LengthWords): Read[] => {
|
|
89
|
+
const minutes = alternation(words.minuteUnits);
|
|
90
|
+
if (minutes === "") return [];
|
|
91
|
+
const pattern = new RegExp(`${numberPattern(words.numberWords)}${SEPARATOR}(?:${minutes})`, "giu");
|
|
92
|
+
return [...text.matchAll(pattern)].flatMap((match): Read[] => {
|
|
93
|
+
const end = match.index + match[0].length;
|
|
94
|
+
return runsOn(text, end) ? [] : [{ span: { start: match.index, end }, minutes: numberOf(match[1] ?? match[2] ?? "", words.numberWords), unit: 1 }];
|
|
95
|
+
});
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
const overlaps = (left: Span, right: Span): boolean => left.start < right.end && right.start < left.end;
|
|
99
|
+
|
|
100
|
+
/** Lengths of time in hours and minutes, in the order written. A minutes-only reading inside an hours one is dropped. */
|
|
101
|
+
export const timeLengths = (text: string, words: LengthWords): TimeLength[] => {
|
|
102
|
+
const hours = hourLengths(text, words);
|
|
103
|
+
const minutes = minuteLengths(text, words).filter((read) => !hours.some((hour) => overlaps(hour.span, read.span)));
|
|
104
|
+
return [...hours, ...minutes]
|
|
105
|
+
.filter((read) => Number.isFinite(read.minutes) && read.minutes > 0)
|
|
106
|
+
.map((read) => ({ ...read.span, minutes: read.minutes, unit: read.unit }))
|
|
107
|
+
.toSorted((left, right) => left.start - right.start);
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
const longestFirst = (marks: readonly Mark[]): Mark[] => marks.toSorted((left, right) => right.pattern.length - left.pattern.length);
|
|
111
|
+
|
|
112
|
+
const LABEL_GAP_BEFORE = new Set([" ", "\t", "\u3000", ":", ":"]);
|
|
113
|
+
const LABEL_GAP_AFTER = /^\s*/u;
|
|
114
|
+
const LOOK_AROUND = 40;
|
|
115
|
+
|
|
116
|
+
const lower = (text: string): string => text.toLowerCase();
|
|
117
|
+
|
|
118
|
+
/** Where the separators that may stand between a label and its length (休憩:1時間、Break: 1 hour) begin, reading back from at. */
|
|
119
|
+
const gapStart = (text: string, at: number): number => {
|
|
120
|
+
let start = at;
|
|
121
|
+
while (start > 0 && LABEL_GAP_BEFORE.has(text.charAt(start - 1))) start -= 1;
|
|
122
|
+
return start;
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
/** Whether pattern is written as a word at offset at, case aside. Reads a window around it, not the whole text. */
|
|
126
|
+
const isLabelAt = (text: string, at: number, pattern: string): boolean => {
|
|
127
|
+
if (at < 0) return false;
|
|
128
|
+
const from = Math.max(0, at - 1);
|
|
129
|
+
return isWordAt(lower(text.slice(from, at + pattern.length + 1)), at - from, lower(pattern));
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
/** The label written right before span (after separators only), or undefined. */
|
|
133
|
+
const labelBefore = (text: string, span: Span, marks: readonly Mark[]): Span | undefined => {
|
|
134
|
+
const end = gapStart(text, span.start);
|
|
135
|
+
if (span.start - end > LOOK_AROUND) return undefined;
|
|
136
|
+
const found = longestFirst(marks.filter((mark) => (mark.position ?? "before") === "before")).find((mark) =>
|
|
137
|
+
isLabelAt(text, end - mark.pattern.length, mark.pattern),
|
|
138
|
+
);
|
|
139
|
+
return found === undefined ? undefined : { start: end - found.pattern.length, end };
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
/** The label written right after span (after white space only), or undefined. */
|
|
143
|
+
const labelAfter = (text: string, span: Span, marks: readonly Mark[]): Span | undefined => {
|
|
144
|
+
const start = span.end + (LABEL_GAP_AFTER.exec(text.slice(span.end, span.end + LOOK_AROUND))?.[0].length ?? 0);
|
|
145
|
+
const found = longestFirst(marks.filter((mark) => mark.position === "after")).find((mark) => isLabelAt(text, start, mark.pattern));
|
|
146
|
+
return found === undefined ? undefined : { start, end: start + found.pattern.length };
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
/** The label beside span, before or after it. */
|
|
150
|
+
export const labelOf = (text: string, span: Span, marks: readonly Mark[]): Span | undefined => labelBefore(text, span, marks) ?? labelAfter(text, span, marks);
|
|
151
|
+
|
|
152
|
+
/** Where the words of marks are written inside scope. */
|
|
153
|
+
export const mentionsIn = (text: string, scope: Span, marks: readonly Mark[]): Span[] => {
|
|
154
|
+
const inside = lower(text.slice(scope.start, scope.end));
|
|
155
|
+
return [...new Set(marks.map((mark) => lower(mark.pattern)))].flatMap((pattern) =>
|
|
156
|
+
wordOffsets(inside, pattern).map((at) => ({ start: scope.start + at, end: scope.start + at + pattern.length })),
|
|
157
|
+
);
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
export const within = (inner: Span, outer: Span): boolean => inner.start >= outer.start && inner.end <= outer.end;
|
|
161
|
+
|
|
162
|
+
const LIST_ITEM = /^\s*(?:[-*+・•]|\d{1,3}[.)])\s/u;
|
|
163
|
+
|
|
164
|
+
type Paragraph = { readonly span: Span; readonly lines: readonly Span[]; readonly listed: boolean };
|
|
165
|
+
|
|
166
|
+
type Run = { readonly lines: Span[]; listed: boolean };
|
|
167
|
+
|
|
168
|
+
/** Runs of non-blank lines. listed: every line of the run is a list item in the source. */
|
|
169
|
+
const paragraphsOf = (text: string, source: string): Paragraph[] => {
|
|
170
|
+
const listedLines = linesOf(source).map((line) => LIST_ITEM.test(line.text));
|
|
171
|
+
const runs: Run[] = [{ lines: [], listed: true }];
|
|
172
|
+
linesOf(text).forEach((line, index) => {
|
|
173
|
+
const run = runs[runs.length - 1];
|
|
174
|
+
if (line.text.trim() === "") runs.push({ lines: [], listed: true });
|
|
175
|
+
else if (run !== undefined) {
|
|
176
|
+
run.lines.push({ start: line.start, end: line.start + line.text.length });
|
|
177
|
+
run.listed = run.listed && listedLines[index] === true;
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
return runs.flatMap(({ lines, listed }) => {
|
|
181
|
+
const [first, last] = [lines[0], lines[lines.length - 1]];
|
|
182
|
+
return first === undefined || last === undefined ? [] : [{ span: { start: first.start, end: last.end }, lines, listed }];
|
|
183
|
+
});
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
const clipped = (inner: Span, outer: Span): Span => ({ start: Math.max(inner.start, outer.start), end: Math.min(inner.end, outer.end) });
|
|
187
|
+
|
|
188
|
+
/** A sentence that ends on a clock time ("5:30 p.m. (a one-hour break") runs on into the next. */
|
|
189
|
+
const joinedAtTimes = (sentences: readonly Span[], times: readonly Span[]): Span[] =>
|
|
190
|
+
sentences.reduce<Span[]>((joined, sentence) => {
|
|
191
|
+
const last = joined[joined.length - 1];
|
|
192
|
+
if (last !== undefined && times.some((time) => time.start < last.end && last.end <= time.end)) {
|
|
193
|
+
joined[joined.length - 1] = { start: last.start, end: sentence.end };
|
|
194
|
+
} else joined.push(sentence);
|
|
195
|
+
return joined;
|
|
196
|
+
}, []);
|
|
197
|
+
|
|
198
|
+
/** The sentences of a line, clipped to it; the line itself when no sentence lies on it. */
|
|
199
|
+
const sentencesOn = (line: Span, sentences: readonly Span[]): Span[] => {
|
|
200
|
+
const on = sentences.filter((sentence) => overlaps(sentence, line)).map((sentence) => clipped(sentence, line));
|
|
201
|
+
return on.length === 0 ? [line] : on;
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* The stretches a statement is read in: each sentence of a line, and a list whose items say it together (勤務時間 /
|
|
206
|
+
* 休憩 / 実働 on three items). read returns undefined when a stretch does not hold exactly one statement; a list that
|
|
207
|
+
* reads as one is not read again line by line.
|
|
208
|
+
*/
|
|
209
|
+
export const readScopes = <T>(
|
|
210
|
+
text: string,
|
|
211
|
+
source: string,
|
|
212
|
+
split: { readonly sentences: readonly Span[]; readonly times: readonly Span[] },
|
|
213
|
+
read: (scope: Span) => T | undefined,
|
|
214
|
+
): T[] => {
|
|
215
|
+
const sentences = joinedAtTimes(split.sentences, split.times);
|
|
216
|
+
return paragraphsOf(text, source).flatMap((paragraph) => {
|
|
217
|
+
const whole = paragraph.listed && paragraph.lines.length > 1 ? read(paragraph.span) : undefined;
|
|
218
|
+
if (whole !== undefined) return [whole];
|
|
219
|
+
return paragraph.lines.flatMap((line) =>
|
|
220
|
+
sentencesOn(line, sentences).flatMap((scope) => {
|
|
221
|
+
const result = read(scope);
|
|
222
|
+
return result === undefined ? [] : [result];
|
|
223
|
+
}),
|
|
224
|
+
);
|
|
225
|
+
});
|
|
226
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Span } from "../plugin.ts";
|
|
2
|
+
import { escapeRegExp } from "../orthography.ts";
|
|
3
|
+
|
|
4
|
+
export type UnitCount = Span & { readonly amount: number };
|
|
5
|
+
|
|
6
|
+
const LATIN_UNIT = /^[a-z]+$/iu;
|
|
7
|
+
|
|
8
|
+
/** 数字と単位(3泊、3 nights、15回)。英字の単位は語の切れ目まで。Pure. */
|
|
9
|
+
export const numeralCounts = (text: string, units: readonly string[]): UnitCount[] =>
|
|
10
|
+
units.flatMap((unit) => {
|
|
11
|
+
const tail = LATIN_UNIT.test(unit) ? "(?![\\p{L}\\p{N}])" : "";
|
|
12
|
+
const pattern = new RegExp(`(?<![\\p{N}.,])(\\p{Nd}+)\\s?${escapeRegExp(unit)}${tail}`, "giu");
|
|
13
|
+
return [...text.matchAll(pattern)].map((match) => ({
|
|
14
|
+
start: match.index,
|
|
15
|
+
end: match.index + match[0].length,
|
|
16
|
+
amount: Number((match[1] ?? "").normalize("NFKC")),
|
|
17
|
+
}));
|
|
18
|
+
});
|