@discretion/core 0.1.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/CHANGELOG.md +117 -0
- package/LICENSE +21 -0
- package/README.md +319 -0
- package/dist/src/checksums/aba.d.ts +25 -0
- package/dist/src/checksums/aba.d.ts.map +1 -0
- package/dist/src/checksums/aba.js +47 -0
- package/dist/src/checksums/aba.js.map +1 -0
- package/dist/src/checksums/digits.d.ts +55 -0
- package/dist/src/checksums/digits.d.ts.map +1 -0
- package/dist/src/checksums/digits.js +114 -0
- package/dist/src/checksums/digits.js.map +1 -0
- package/dist/src/checksums/icao9303.d.ts +29 -0
- package/dist/src/checksums/icao9303.d.ts.map +1 -0
- package/dist/src/checksums/icao9303.js +56 -0
- package/dist/src/checksums/icao9303.js.map +1 -0
- package/dist/src/checksums/index.d.ts +21 -0
- package/dist/src/checksums/index.d.ts.map +1 -0
- package/dist/src/checksums/index.js +21 -0
- package/dist/src/checksums/index.js.map +1 -0
- package/dist/src/checksums/iso7064.d.ts +67 -0
- package/dist/src/checksums/iso7064.d.ts.map +1 -0
- package/dist/src/checksums/iso7064.js +159 -0
- package/dist/src/checksums/iso7064.js.map +1 -0
- package/dist/src/checksums/luhn.d.ts +32 -0
- package/dist/src/checksums/luhn.d.ts.map +1 -0
- package/dist/src/checksums/luhn.js +66 -0
- package/dist/src/checksums/luhn.js.map +1 -0
- package/dist/src/checksums/mod97.d.ts +55 -0
- package/dist/src/checksums/mod97.d.ts.map +1 -0
- package/dist/src/checksums/mod97.js +94 -0
- package/dist/src/checksums/mod97.js.map +1 -0
- package/dist/src/checksums/verhoeff.d.ts +28 -0
- package/dist/src/checksums/verhoeff.d.ts.map +1 -0
- package/dist/src/checksums/verhoeff.js +80 -0
- package/dist/src/checksums/verhoeff.js.map +1 -0
- package/dist/src/checksums/weighted.d.ts +64 -0
- package/dist/src/checksums/weighted.d.ts.map +1 -0
- package/dist/src/checksums/weighted.js +97 -0
- package/dist/src/checksums/weighted.js.map +1 -0
- package/dist/src/context/documentProfile.d.ts +34 -0
- package/dist/src/context/documentProfile.d.ts.map +1 -0
- package/dist/src/context/documentProfile.js +253 -0
- package/dist/src/context/documentProfile.js.map +1 -0
- package/dist/src/context/negativeRules.d.ts +60 -0
- package/dist/src/context/negativeRules.d.ts.map +1 -0
- package/dist/src/context/negativeRules.js +696 -0
- package/dist/src/context/negativeRules.js.map +1 -0
- package/dist/src/context/score.d.ts +52 -0
- package/dist/src/context/score.d.ts.map +1 -0
- package/dist/src/context/score.js +346 -0
- package/dist/src/context/score.js.map +1 -0
- package/dist/src/context/structure.d.ts +46 -0
- package/dist/src/context/structure.d.ts.map +1 -0
- package/dist/src/context/structure.js +528 -0
- package/dist/src/context/structure.js.map +1 -0
- package/dist/src/context/triggers.d.ts +73 -0
- package/dist/src/context/triggers.d.ts.map +1 -0
- package/dist/src/context/triggers.js +172 -0
- package/dist/src/context/triggers.js.map +1 -0
- package/dist/src/context/types.d.ts +137 -0
- package/dist/src/context/types.d.ts.map +1 -0
- package/dist/src/context/types.js +25 -0
- package/dist/src/context/types.js.map +1 -0
- package/dist/src/crypto/keccak256.d.ts +15 -0
- package/dist/src/crypto/keccak256.d.ts.map +1 -0
- package/dist/src/crypto/keccak256.js +89 -0
- package/dist/src/crypto/keccak256.js.map +1 -0
- package/dist/src/crypto/sha256.d.ts +16 -0
- package/dist/src/crypto/sha256.d.ts.map +1 -0
- package/dist/src/crypto/sha256.js +81 -0
- package/dist/src/crypto/sha256.js.map +1 -0
- package/dist/src/detect/detectors/bankcodes/auBsb.d.ts +11 -0
- package/dist/src/detect/detectors/bankcodes/auBsb.d.ts.map +1 -0
- package/dist/src/detect/detectors/bankcodes/auBsb.js +34 -0
- package/dist/src/detect/detectors/bankcodes/auBsb.js.map +1 -0
- package/dist/src/detect/detectors/bankcodes/brAgencia.d.ts +15 -0
- package/dist/src/detect/detectors/bankcodes/brAgencia.d.ts.map +1 -0
- package/dist/src/detect/detectors/bankcodes/brAgencia.js +43 -0
- package/dist/src/detect/detectors/bankcodes/brAgencia.js.map +1 -0
- package/dist/src/detect/detectors/bankcodes/caTransit.d.ts +13 -0
- package/dist/src/detect/detectors/bankcodes/caTransit.d.ts.map +1 -0
- package/dist/src/detect/detectors/bankcodes/caTransit.js +86 -0
- package/dist/src/detect/detectors/bankcodes/caTransit.js.map +1 -0
- package/dist/src/detect/detectors/bankcodes/inIfsc.d.ts +13 -0
- package/dist/src/detect/detectors/bankcodes/inIfsc.d.ts.map +1 -0
- package/dist/src/detect/detectors/bankcodes/inIfsc.js +37 -0
- package/dist/src/detect/detectors/bankcodes/inIfsc.js.map +1 -0
- package/dist/src/detect/detectors/bankcodes/index.d.ts +10 -0
- package/dist/src/detect/detectors/bankcodes/index.d.ts.map +1 -0
- package/dist/src/detect/detectors/bankcodes/index.js +10 -0
- package/dist/src/detect/detectors/bankcodes/index.js.map +1 -0
- package/dist/src/detect/detectors/bankcodes/ukSortCode.d.ts +13 -0
- package/dist/src/detect/detectors/bankcodes/ukSortCode.d.ts.map +1 -0
- package/dist/src/detect/detectors/bankcodes/ukSortCode.js +36 -0
- package/dist/src/detect/detectors/bankcodes/ukSortCode.js.map +1 -0
- package/dist/src/detect/detectors/bankcodes/usRouting.d.ts +12 -0
- package/dist/src/detect/detectors/bankcodes/usRouting.d.ts.map +1 -0
- package/dist/src/detect/detectors/bankcodes/usRouting.js +45 -0
- package/dist/src/detect/detectors/bankcodes/usRouting.js.map +1 -0
- package/dist/src/detect/detectors/contact/email.d.ts +16 -0
- package/dist/src/detect/detectors/contact/email.d.ts.map +1 -0
- package/dist/src/detect/detectors/contact/email.js +111 -0
- package/dist/src/detect/detectors/contact/email.js.map +1 -0
- package/dist/src/detect/detectors/contact/index.d.ts +11 -0
- package/dist/src/detect/detectors/contact/index.d.ts.map +1 -0
- package/dist/src/detect/detectors/contact/index.js +11 -0
- package/dist/src/detect/detectors/contact/index.js.map +1 -0
- package/dist/src/detect/detectors/contact/ipv4.d.ts +12 -0
- package/dist/src/detect/detectors/contact/ipv4.d.ts.map +1 -0
- package/dist/src/detect/detectors/contact/ipv4.js +109 -0
- package/dist/src/detect/detectors/contact/ipv4.js.map +1 -0
- package/dist/src/detect/detectors/contact/ipv6.d.ts +16 -0
- package/dist/src/detect/detectors/contact/ipv6.d.ts.map +1 -0
- package/dist/src/detect/detectors/contact/ipv6.js +187 -0
- package/dist/src/detect/detectors/contact/ipv6.js.map +1 -0
- package/dist/src/detect/detectors/contact/mac.d.ts +14 -0
- package/dist/src/detect/detectors/contact/mac.d.ts.map +1 -0
- package/dist/src/detect/detectors/contact/mac.js +64 -0
- package/dist/src/detect/detectors/contact/mac.js.map +1 -0
- package/dist/src/detect/detectors/contact/phone.d.ts +21 -0
- package/dist/src/detect/detectors/contact/phone.d.ts.map +1 -0
- package/dist/src/detect/detectors/contact/phone.js +76 -0
- package/dist/src/detect/detectors/contact/phone.js.map +1 -0
- package/dist/src/detect/detectors/contact/urlCredentials.d.ts +23 -0
- package/dist/src/detect/detectors/contact/urlCredentials.d.ts.map +1 -0
- package/dist/src/detect/detectors/contact/urlCredentials.js +123 -0
- package/dist/src/detect/detectors/contact/urlCredentials.js.map +1 -0
- package/dist/src/detect/detectors/crypto/ada.d.ts +13 -0
- package/dist/src/detect/detectors/crypto/ada.d.ts.map +1 -0
- package/dist/src/detect/detectors/crypto/ada.js +51 -0
- package/dist/src/detect/detectors/crypto/ada.js.map +1 -0
- package/dist/src/detect/detectors/crypto/btc.d.ts +15 -0
- package/dist/src/detect/detectors/crypto/btc.d.ts.map +1 -0
- package/dist/src/detect/detectors/crypto/btc.js +78 -0
- package/dist/src/detect/detectors/crypto/btc.js.map +1 -0
- package/dist/src/detect/detectors/crypto/dot.d.ts +13 -0
- package/dist/src/detect/detectors/crypto/dot.d.ts.map +1 -0
- package/dist/src/detect/detectors/crypto/dot.js +41 -0
- package/dist/src/detect/detectors/crypto/dot.js.map +1 -0
- package/dist/src/detect/detectors/crypto/eth.d.ts +15 -0
- package/dist/src/detect/detectors/crypto/eth.d.ts.map +1 -0
- package/dist/src/detect/detectors/crypto/eth.js +63 -0
- package/dist/src/detect/detectors/crypto/eth.js.map +1 -0
- package/dist/src/detect/detectors/crypto/index.d.ts +12 -0
- package/dist/src/detect/detectors/crypto/index.d.ts.map +1 -0
- package/dist/src/detect/detectors/crypto/index.js +12 -0
- package/dist/src/detect/detectors/crypto/index.js.map +1 -0
- package/dist/src/detect/detectors/crypto/ltc.d.ts +12 -0
- package/dist/src/detect/detectors/crypto/ltc.d.ts.map +1 -0
- package/dist/src/detect/detectors/crypto/ltc.js +71 -0
- package/dist/src/detect/detectors/crypto/ltc.js.map +1 -0
- package/dist/src/detect/detectors/crypto/sol.d.ts +13 -0
- package/dist/src/detect/detectors/crypto/sol.d.ts.map +1 -0
- package/dist/src/detect/detectors/crypto/sol.js +39 -0
- package/dist/src/detect/detectors/crypto/sol.js.map +1 -0
- package/dist/src/detect/detectors/crypto/trx.d.ts +8 -0
- package/dist/src/detect/detectors/crypto/trx.d.ts.map +1 -0
- package/dist/src/detect/detectors/crypto/trx.js +34 -0
- package/dist/src/detect/detectors/crypto/trx.js.map +1 -0
- package/dist/src/detect/detectors/crypto/xmr.d.ts +10 -0
- package/dist/src/detect/detectors/crypto/xmr.d.ts.map +1 -0
- package/dist/src/detect/detectors/crypto/xmr.js +51 -0
- package/dist/src/detect/detectors/crypto/xmr.js.map +1 -0
- package/dist/src/detect/detectors/documents/driversLicense.d.ts +24 -0
- package/dist/src/detect/detectors/documents/driversLicense.d.ts.map +1 -0
- package/dist/src/detect/detectors/documents/driversLicense.js +79 -0
- package/dist/src/detect/detectors/documents/driversLicense.js.map +1 -0
- package/dist/src/detect/detectors/documents/healthData.d.ts +23 -0
- package/dist/src/detect/detectors/documents/healthData.d.ts.map +1 -0
- package/dist/src/detect/detectors/documents/healthData.js +78 -0
- package/dist/src/detect/detectors/documents/healthData.js.map +1 -0
- package/dist/src/detect/detectors/documents/index.d.ts +9 -0
- package/dist/src/detect/detectors/documents/index.d.ts.map +1 -0
- package/dist/src/detect/detectors/documents/index.js +9 -0
- package/dist/src/detect/detectors/documents/index.js.map +1 -0
- package/dist/src/detect/detectors/documents/passportMrz.d.ts +20 -0
- package/dist/src/detect/detectors/documents/passportMrz.d.ts.map +1 -0
- package/dist/src/detect/detectors/documents/passportMrz.js +194 -0
- package/dist/src/detect/detectors/documents/passportMrz.js.map +1 -0
- package/dist/src/detect/detectors/documents/usNpi.d.ts +16 -0
- package/dist/src/detect/detectors/documents/usNpi.d.ts.map +1 -0
- package/dist/src/detect/detectors/documents/usNpi.js +48 -0
- package/dist/src/detect/detectors/documents/usNpi.js.map +1 -0
- package/dist/src/detect/detectors/documents/vin.d.ts +15 -0
- package/dist/src/detect/detectors/documents/vin.d.ts.map +1 -0
- package/dist/src/detect/detectors/documents/vin.js +64 -0
- package/dist/src/detect/detectors/documents/vin.js.map +1 -0
- package/dist/src/detect/detectors/financial/creditCard.d.ts +23 -0
- package/dist/src/detect/detectors/financial/creditCard.d.ts.map +1 -0
- package/dist/src/detect/detectors/financial/creditCard.js +157 -0
- package/dist/src/detect/detectors/financial/creditCard.js.map +1 -0
- package/dist/src/detect/detectors/financial/iban.d.ts +18 -0
- package/dist/src/detect/detectors/financial/iban.d.ts.map +1 -0
- package/dist/src/detect/detectors/financial/iban.js +80 -0
- package/dist/src/detect/detectors/financial/iban.js.map +1 -0
- package/dist/src/detect/detectors/financial/ibanRegistry.d.ts +35 -0
- package/dist/src/detect/detectors/financial/ibanRegistry.d.ts.map +1 -0
- package/dist/src/detect/detectors/financial/ibanRegistry.js +92 -0
- package/dist/src/detect/detectors/financial/ibanRegistry.js.map +1 -0
- package/dist/src/detect/detectors/financial/index.d.ts +7 -0
- package/dist/src/detect/detectors/financial/index.d.ts.map +1 -0
- package/dist/src/detect/detectors/financial/index.js +7 -0
- package/dist/src/detect/detectors/financial/index.js.map +1 -0
- package/dist/src/detect/detectors/financial/swiftBic.d.ts +17 -0
- package/dist/src/detect/detectors/financial/swiftBic.d.ts.map +1 -0
- package/dist/src/detect/detectors/financial/swiftBic.js +55 -0
- package/dist/src/detect/detectors/financial/swiftBic.js.map +1 -0
- package/dist/src/detect/detectors/index.d.ts +15 -0
- package/dist/src/detect/detectors/index.d.ts.map +1 -0
- package/dist/src/detect/detectors/index.js +15 -0
- package/dist/src/detect/detectors/index.js.map +1 -0
- package/dist/src/detect/detectors/location/coordinates.d.ts +14 -0
- package/dist/src/detect/detectors/location/coordinates.d.ts.map +1 -0
- package/dist/src/detect/detectors/location/coordinates.js +79 -0
- package/dist/src/detect/detectors/location/coordinates.js.map +1 -0
- package/dist/src/detect/detectors/location/index.d.ts +7 -0
- package/dist/src/detect/detectors/location/index.d.ts.map +1 -0
- package/dist/src/detect/detectors/location/index.js +7 -0
- package/dist/src/detect/detectors/location/index.js.map +1 -0
- package/dist/src/detect/detectors/location/postalCode.d.ts +13 -0
- package/dist/src/detect/detectors/location/postalCode.d.ts.map +1 -0
- package/dist/src/detect/detectors/location/postalCode.js +53 -0
- package/dist/src/detect/detectors/location/postalCode.js.map +1 -0
- package/dist/src/detect/detectors/location/postalRegistry.d.ts +19 -0
- package/dist/src/detect/detectors/location/postalRegistry.d.ts.map +1 -0
- package/dist/src/detect/detectors/location/postalRegistry.js +73 -0
- package/dist/src/detect/detectors/location/postalRegistry.js.map +1 -0
- package/dist/src/detect/detectors/location/streetAddress.d.ts +21 -0
- package/dist/src/detect/detectors/location/streetAddress.d.ts.map +1 -0
- package/dist/src/detect/detectors/location/streetAddress.js +70 -0
- package/dist/src/detect/detectors/location/streetAddress.js.map +1 -0
- package/dist/src/detect/detectors/natid/africa.d.ts +17 -0
- package/dist/src/detect/detectors/natid/africa.d.ts.map +1 -0
- package/dist/src/detect/detectors/natid/africa.js +106 -0
- package/dist/src/detect/detectors/natid/africa.js.map +1 -0
- package/dist/src/detect/detectors/natid/ar.d.ts +14 -0
- package/dist/src/detect/detectors/natid/ar.d.ts.map +1 -0
- package/dist/src/detect/detectors/natid/ar.js +62 -0
- package/dist/src/detect/detectors/natid/ar.js.map +1 -0
- package/dist/src/detect/detectors/natid/au.d.ts +13 -0
- package/dist/src/detect/detectors/natid/au.d.ts.map +1 -0
- package/dist/src/detect/detectors/natid/au.js +100 -0
- package/dist/src/detect/detectors/natid/au.js.map +1 -0
- package/dist/src/detect/detectors/natid/be.d.ts +8 -0
- package/dist/src/detect/detectors/natid/be.d.ts.map +1 -0
- package/dist/src/detect/detectors/natid/be.js +44 -0
- package/dist/src/detect/detectors/natid/be.js.map +1 -0
- package/dist/src/detect/detectors/natid/bg.d.ts +7 -0
- package/dist/src/detect/detectors/natid/bg.d.ts.map +1 -0
- package/dist/src/detect/detectors/natid/bg.js +44 -0
- package/dist/src/detect/detectors/natid/bg.js.map +1 -0
- package/dist/src/detect/detectors/natid/br.d.ts +8 -0
- package/dist/src/detect/detectors/natid/br.d.ts.map +1 -0
- package/dist/src/detect/detectors/natid/br.js +85 -0
- package/dist/src/detect/detectors/natid/br.js.map +1 -0
- package/dist/src/detect/detectors/natid/ca.d.ts +8 -0
- package/dist/src/detect/detectors/natid/ca.d.ts.map +1 -0
- package/dist/src/detect/detectors/natid/ca.js +41 -0
- package/dist/src/detect/detectors/natid/ca.js.map +1 -0
- package/dist/src/detect/detectors/natid/cl.d.ts +9 -0
- package/dist/src/detect/detectors/natid/cl.d.ts.map +1 -0
- package/dist/src/detect/detectors/natid/cl.js +47 -0
- package/dist/src/detect/detectors/natid/cl.js.map +1 -0
- package/dist/src/detect/detectors/natid/cn.d.ts +9 -0
- package/dist/src/detect/detectors/natid/cn.d.ts.map +1 -0
- package/dist/src/detect/detectors/natid/cn.js +49 -0
- package/dist/src/detect/detectors/natid/cn.js.map +1 -0
- package/dist/src/detect/detectors/natid/co.d.ts +10 -0
- package/dist/src/detect/detectors/natid/co.d.ts.map +1 -0
- package/dist/src/detect/detectors/natid/co.js +43 -0
- package/dist/src/detect/detectors/natid/co.js.map +1 -0
- package/dist/src/detect/detectors/natid/cz.d.ts +11 -0
- package/dist/src/detect/detectors/natid/cz.d.ts.map +1 -0
- package/dist/src/detect/detectors/natid/cz.js +44 -0
- package/dist/src/detect/detectors/natid/cz.js.map +1 -0
- package/dist/src/detect/detectors/natid/de.d.ts +16 -0
- package/dist/src/detect/detectors/natid/de.d.ts.map +1 -0
- package/dist/src/detect/detectors/natid/de.js +77 -0
- package/dist/src/detect/detectors/natid/de.js.map +1 -0
- package/dist/src/detect/detectors/natid/dk.d.ts +9 -0
- package/dist/src/detect/detectors/natid/dk.d.ts.map +1 -0
- package/dist/src/detect/detectors/natid/dk.js +31 -0
- package/dist/src/detect/detectors/natid/dk.js.map +1 -0
- package/dist/src/detect/detectors/natid/es.d.ts +12 -0
- package/dist/src/detect/detectors/natid/es.d.ts.map +1 -0
- package/dist/src/detect/detectors/natid/es.js +96 -0
- package/dist/src/detect/detectors/natid/es.js.map +1 -0
- package/dist/src/detect/detectors/natid/fi.d.ts +10 -0
- package/dist/src/detect/detectors/natid/fi.d.ts.map +1 -0
- package/dist/src/detect/detectors/natid/fi.js +40 -0
- package/dist/src/detect/detectors/natid/fi.js.map +1 -0
- package/dist/src/detect/detectors/natid/fr.d.ts +12 -0
- package/dist/src/detect/detectors/natid/fr.d.ts.map +1 -0
- package/dist/src/detect/detectors/natid/fr.js +61 -0
- package/dist/src/detect/detectors/natid/fr.js.map +1 -0
- package/dist/src/detect/detectors/natid/gb.d.ts +10 -0
- package/dist/src/detect/detectors/natid/gb.d.ts.map +1 -0
- package/dist/src/detect/detectors/natid/gb.js +72 -0
- package/dist/src/detect/detectors/natid/gb.js.map +1 -0
- package/dist/src/detect/detectors/natid/gr.d.ts +7 -0
- package/dist/src/detect/detectors/natid/gr.d.ts.map +1 -0
- package/dist/src/detect/detectors/natid/gr.js +36 -0
- package/dist/src/detect/detectors/natid/gr.js.map +1 -0
- package/dist/src/detect/detectors/natid/gulf.d.ts +16 -0
- package/dist/src/detect/detectors/natid/gulf.d.ts.map +1 -0
- package/dist/src/detect/detectors/natid/gulf.js +121 -0
- package/dist/src/detect/detectors/natid/gulf.js.map +1 -0
- package/dist/src/detect/detectors/natid/hk.d.ts +9 -0
- package/dist/src/detect/detectors/natid/hk.d.ts.map +1 -0
- package/dist/src/detect/detectors/natid/hk.js +41 -0
- package/dist/src/detect/detectors/natid/hk.js.map +1 -0
- package/dist/src/detect/detectors/natid/hr.d.ts +6 -0
- package/dist/src/detect/detectors/natid/hr.d.ts.map +1 -0
- package/dist/src/detect/detectors/natid/hr.js +32 -0
- package/dist/src/detect/detectors/natid/hr.js.map +1 -0
- package/dist/src/detect/detectors/natid/hu.d.ts +7 -0
- package/dist/src/detect/detectors/natid/hu.d.ts.map +1 -0
- package/dist/src/detect/detectors/natid/hu.js +37 -0
- package/dist/src/detect/detectors/natid/hu.js.map +1 -0
- package/dist/src/detect/detectors/natid/ie.d.ts +9 -0
- package/dist/src/detect/detectors/natid/ie.d.ts.map +1 -0
- package/dist/src/detect/detectors/natid/ie.js +36 -0
- package/dist/src/detect/detectors/natid/ie.js.map +1 -0
- package/dist/src/detect/detectors/natid/il.d.ts +10 -0
- package/dist/src/detect/detectors/natid/il.d.ts.map +1 -0
- package/dist/src/detect/detectors/natid/il.js +38 -0
- package/dist/src/detect/detectors/natid/il.js.map +1 -0
- package/dist/src/detect/detectors/natid/in.d.ts +17 -0
- package/dist/src/detect/detectors/natid/in.d.ts.map +1 -0
- package/dist/src/detect/detectors/natid/in.js +67 -0
- package/dist/src/detect/detectors/natid/in.js.map +1 -0
- package/dist/src/detect/detectors/natid/index.d.ts +55 -0
- package/dist/src/detect/detectors/natid/index.d.ts.map +1 -0
- package/dist/src/detect/detectors/natid/index.js +55 -0
- package/dist/src/detect/detectors/natid/index.js.map +1 -0
- package/dist/src/detect/detectors/natid/is.d.ts +8 -0
- package/dist/src/detect/detectors/natid/is.d.ts.map +1 -0
- package/dist/src/detect/detectors/natid/is.js +42 -0
- package/dist/src/detect/detectors/natid/is.js.map +1 -0
- package/dist/src/detect/detectors/natid/it.d.ts +12 -0
- package/dist/src/detect/detectors/natid/it.d.ts.map +1 -0
- package/dist/src/detect/detectors/natid/it.js +62 -0
- package/dist/src/detect/detectors/natid/it.js.map +1 -0
- package/dist/src/detect/detectors/natid/jp.d.ts +9 -0
- package/dist/src/detect/detectors/natid/jp.d.ts.map +1 -0
- package/dist/src/detect/detectors/natid/jp.js +46 -0
- package/dist/src/detect/detectors/natid/jp.js.map +1 -0
- package/dist/src/detect/detectors/natid/kr.d.ts +11 -0
- package/dist/src/detect/detectors/natid/kr.d.ts.map +1 -0
- package/dist/src/detect/detectors/natid/kr.js +40 -0
- package/dist/src/detect/detectors/natid/kr.js.map +1 -0
- package/dist/src/detect/detectors/natid/kz.d.ts +8 -0
- package/dist/src/detect/detectors/natid/kz.d.ts.map +1 -0
- package/dist/src/detect/detectors/natid/kz.js +46 -0
- package/dist/src/detect/detectors/natid/kz.js.map +1 -0
- package/dist/src/detect/detectors/natid/mx.d.ts +16 -0
- package/dist/src/detect/detectors/natid/mx.d.ts.map +1 -0
- package/dist/src/detect/detectors/natid/mx.js +82 -0
- package/dist/src/detect/detectors/natid/mx.js.map +1 -0
- package/dist/src/detect/detectors/natid/nl.d.ts +8 -0
- package/dist/src/detect/detectors/natid/nl.d.ts.map +1 -0
- package/dist/src/detect/detectors/natid/nl.js +40 -0
- package/dist/src/detect/detectors/natid/nl.js.map +1 -0
- package/dist/src/detect/detectors/natid/no.d.ts +9 -0
- package/dist/src/detect/detectors/natid/no.d.ts.map +1 -0
- package/dist/src/detect/detectors/natid/no.js +52 -0
- package/dist/src/detect/detectors/natid/no.js.map +1 -0
- package/dist/src/detect/detectors/natid/nz.d.ts +9 -0
- package/dist/src/detect/detectors/natid/nz.d.ts.map +1 -0
- package/dist/src/detect/detectors/natid/nz.js +52 -0
- package/dist/src/detect/detectors/natid/nz.js.map +1 -0
- package/dist/src/detect/detectors/natid/pe.d.ts +7 -0
- package/dist/src/detect/detectors/natid/pe.d.ts.map +1 -0
- package/dist/src/detect/detectors/natid/pe.js +26 -0
- package/dist/src/detect/detectors/natid/pe.js.map +1 -0
- package/dist/src/detect/detectors/natid/pl.d.ts +11 -0
- package/dist/src/detect/detectors/natid/pl.d.ts.map +1 -0
- package/dist/src/detect/detectors/natid/pl.js +105 -0
- package/dist/src/detect/detectors/natid/pl.js.map +1 -0
- package/dist/src/detect/detectors/natid/pt.d.ts +6 -0
- package/dist/src/detect/detectors/natid/pt.d.ts.map +1 -0
- package/dist/src/detect/detectors/natid/pt.js +35 -0
- package/dist/src/detect/detectors/natid/pt.js.map +1 -0
- package/dist/src/detect/detectors/natid/ro.d.ts +8 -0
- package/dist/src/detect/detectors/natid/ro.d.ts.map +1 -0
- package/dist/src/detect/detectors/natid/ro.js +48 -0
- package/dist/src/detect/detectors/natid/ro.js.map +1 -0
- package/dist/src/detect/detectors/natid/ru.d.ts +11 -0
- package/dist/src/detect/detectors/natid/ru.d.ts.map +1 -0
- package/dist/src/detect/detectors/natid/ru.js +86 -0
- package/dist/src/detect/detectors/natid/ru.js.map +1 -0
- package/dist/src/detect/detectors/natid/se.d.ts +9 -0
- package/dist/src/detect/detectors/natid/se.d.ts.map +1 -0
- package/dist/src/detect/detectors/natid/se.js +43 -0
- package/dist/src/detect/detectors/natid/se.js.map +1 -0
- package/dist/src/detect/detectors/natid/seasia.d.ts +19 -0
- package/dist/src/detect/detectors/natid/seasia.d.ts.map +1 -0
- package/dist/src/detect/detectors/natid/seasia.js +182 -0
- package/dist/src/detect/detectors/natid/seasia.js.map +1 -0
- package/dist/src/detect/detectors/natid/sg.d.ts +8 -0
- package/dist/src/detect/detectors/natid/sg.d.ts.map +1 -0
- package/dist/src/detect/detectors/natid/sg.js +39 -0
- package/dist/src/detect/detectors/natid/sg.js.map +1 -0
- package/dist/src/detect/detectors/natid/si.d.ts +8 -0
- package/dist/src/detect/detectors/natid/si.d.ts.map +1 -0
- package/dist/src/detect/detectors/natid/si.js +44 -0
- package/dist/src/detect/detectors/natid/si.js.map +1 -0
- package/dist/src/detect/detectors/natid/tr.d.ts +14 -0
- package/dist/src/detect/detectors/natid/tr.d.ts.map +1 -0
- package/dist/src/detect/detectors/natid/tr.js +79 -0
- package/dist/src/detect/detectors/natid/tr.js.map +1 -0
- package/dist/src/detect/detectors/natid/tw.d.ts +9 -0
- package/dist/src/detect/detectors/natid/tw.d.ts.map +1 -0
- package/dist/src/detect/detectors/natid/tw.js +40 -0
- package/dist/src/detect/detectors/natid/tw.js.map +1 -0
- package/dist/src/detect/detectors/natid/ua.d.ts +7 -0
- package/dist/src/detect/detectors/natid/ua.d.ts.map +1 -0
- package/dist/src/detect/detectors/natid/ua.js +38 -0
- package/dist/src/detect/detectors/natid/ua.js.map +1 -0
- package/dist/src/detect/detectors/natid/us.d.ts +15 -0
- package/dist/src/detect/detectors/natid/us.d.ts.map +1 -0
- package/dist/src/detect/detectors/natid/us.js +119 -0
- package/dist/src/detect/detectors/natid/us.js.map +1 -0
- package/dist/src/detect/detectors/natid/za.d.ts +9 -0
- package/dist/src/detect/detectors/natid/za.d.ts.map +1 -0
- package/dist/src/detect/detectors/natid/za.js +44 -0
- package/dist/src/detect/detectors/natid/za.js.map +1 -0
- package/dist/src/detect/detectors/secrets/apiKey.d.ts +14 -0
- package/dist/src/detect/detectors/secrets/apiKey.d.ts.map +1 -0
- package/dist/src/detect/detectors/secrets/apiKey.js +103 -0
- package/dist/src/detect/detectors/secrets/apiKey.js.map +1 -0
- package/dist/src/detect/detectors/secrets/connectionString.d.ts +12 -0
- package/dist/src/detect/detectors/secrets/connectionString.d.ts.map +1 -0
- package/dist/src/detect/detectors/secrets/connectionString.js +70 -0
- package/dist/src/detect/detectors/secrets/connectionString.js.map +1 -0
- package/dist/src/detect/detectors/secrets/genericSecret.d.ts +22 -0
- package/dist/src/detect/detectors/secrets/genericSecret.d.ts.map +1 -0
- package/dist/src/detect/detectors/secrets/genericSecret.js +77 -0
- package/dist/src/detect/detectors/secrets/genericSecret.js.map +1 -0
- package/dist/src/detect/detectors/secrets/index.d.ts +9 -0
- package/dist/src/detect/detectors/secrets/index.d.ts.map +1 -0
- package/dist/src/detect/detectors/secrets/index.js +9 -0
- package/dist/src/detect/detectors/secrets/index.js.map +1 -0
- package/dist/src/detect/detectors/secrets/jwt.d.ts +11 -0
- package/dist/src/detect/detectors/secrets/jwt.d.ts.map +1 -0
- package/dist/src/detect/detectors/secrets/jwt.js +111 -0
- package/dist/src/detect/detectors/secrets/jwt.js.map +1 -0
- package/dist/src/detect/detectors/secrets/pemPrivateKey.d.ts +16 -0
- package/dist/src/detect/detectors/secrets/pemPrivateKey.d.ts.map +1 -0
- package/dist/src/detect/detectors/secrets/pemPrivateKey.js +56 -0
- package/dist/src/detect/detectors/secrets/pemPrivateKey.js.map +1 -0
- package/dist/src/detect/detectors/vat/euVat.d.ts +17 -0
- package/dist/src/detect/detectors/vat/euVat.d.ts.map +1 -0
- package/dist/src/detect/detectors/vat/euVat.js +293 -0
- package/dist/src/detect/detectors/vat/euVat.js.map +1 -0
- package/dist/src/detect/detectors/vat/index.d.ts +5 -0
- package/dist/src/detect/detectors/vat/index.d.ts.map +1 -0
- package/dist/src/detect/detectors/vat/index.js +5 -0
- package/dist/src/detect/detectors/vat/index.js.map +1 -0
- package/dist/src/detect/entropy.d.ts +28 -0
- package/dist/src/detect/entropy.d.ts.map +1 -0
- package/dist/src/detect/entropy.js +64 -0
- package/dist/src/detect/entropy.js.map +1 -0
- package/dist/src/detect/isoCountries.d.ts +10 -0
- package/dist/src/detect/isoCountries.d.ts.map +1 -0
- package/dist/src/detect/isoCountries.js +25 -0
- package/dist/src/detect/isoCountries.js.map +1 -0
- package/dist/src/detect/registry.d.ts +50 -0
- package/dist/src/detect/registry.d.ts.map +1 -0
- package/dist/src/detect/registry.js +110 -0
- package/dist/src/detect/registry.js.map +1 -0
- package/dist/src/detect/runner.d.ts +64 -0
- package/dist/src/detect/runner.d.ts.map +1 -0
- package/dist/src/detect/runner.js +142 -0
- package/dist/src/detect/runner.js.map +1 -0
- package/dist/src/detect/types.d.ts +251 -0
- package/dist/src/detect/types.d.ts.map +1 -0
- package/dist/src/detect/types.js +59 -0
- package/dist/src/detect/types.js.map +1 -0
- package/dist/src/encoding/base58.d.ts +26 -0
- package/dist/src/encoding/base58.d.ts.map +1 -0
- package/dist/src/encoding/base58.js +77 -0
- package/dist/src/encoding/base58.js.map +1 -0
- package/dist/src/encoding/base58monero.d.ts +15 -0
- package/dist/src/encoding/base58monero.d.ts.map +1 -0
- package/dist/src/encoding/base58monero.js +87 -0
- package/dist/src/encoding/base58monero.js.map +1 -0
- package/dist/src/encoding/bech32.d.ts +28 -0
- package/dist/src/encoding/bech32.d.ts.map +1 -0
- package/dist/src/encoding/bech32.js +108 -0
- package/dist/src/encoding/bech32.js.map +1 -0
- package/dist/src/encoding/bytes.d.ts +15 -0
- package/dist/src/encoding/bytes.d.ts.map +1 -0
- package/dist/src/encoding/bytes.js +46 -0
- package/dist/src/encoding/bytes.js.map +1 -0
- package/dist/src/entityFamily.d.ts +18 -0
- package/dist/src/entityFamily.d.ts.map +1 -0
- package/dist/src/entityFamily.js +54 -0
- package/dist/src/entityFamily.js.map +1 -0
- package/dist/src/entityLabel.d.ts +18 -0
- package/dist/src/entityLabel.d.ts.map +1 -0
- package/dist/src/entityLabel.js +53 -0
- package/dist/src/entityLabel.js.map +1 -0
- package/dist/src/entityTypes.d.ts +64 -0
- package/dist/src/entityTypes.d.ts.map +1 -0
- package/dist/src/entityTypes.js +94 -0
- package/dist/src/entityTypes.js.map +1 -0
- package/dist/src/exposure/index.d.ts +86 -0
- package/dist/src/exposure/index.d.ts.map +1 -0
- package/dist/src/exposure/index.js +134 -0
- package/dist/src/exposure/index.js.map +1 -0
- package/dist/src/fuse/calibrate.d.ts +95 -0
- package/dist/src/fuse/calibrate.d.ts.map +1 -0
- package/dist/src/fuse/calibrate.js +165 -0
- package/dist/src/fuse/calibrate.js.map +1 -0
- package/dist/src/fuse/defaultCalibration.d.ts +52 -0
- package/dist/src/fuse/defaultCalibration.d.ts.map +1 -0
- package/dist/src/fuse/defaultCalibration.js +41 -0
- package/dist/src/fuse/defaultCalibration.js.map +1 -0
- package/dist/src/fuse/explain.d.ts +55 -0
- package/dist/src/fuse/explain.d.ts.map +1 -0
- package/dist/src/fuse/explain.js +91 -0
- package/dist/src/fuse/explain.js.map +1 -0
- package/dist/src/fuse/profiles.d.ts +80 -0
- package/dist/src/fuse/profiles.d.ts.map +1 -0
- package/dist/src/fuse/profiles.js +126 -0
- package/dist/src/fuse/profiles.js.map +1 -0
- package/dist/src/fuse/resolve.d.ts +73 -0
- package/dist/src/fuse/resolve.d.ts.map +1 -0
- package/dist/src/fuse/resolve.js +206 -0
- package/dist/src/fuse/resolve.js.map +1 -0
- package/dist/src/gazetteer/index.d.ts +41 -0
- package/dist/src/gazetteer/index.d.ts.map +1 -0
- package/dist/src/gazetteer/index.js +117 -0
- package/dist/src/gazetteer/index.js.map +1 -0
- package/dist/src/generate/bankcodes.d.ts +20 -0
- package/dist/src/generate/bankcodes.d.ts.map +1 -0
- package/dist/src/generate/bankcodes.js +71 -0
- package/dist/src/generate/bankcodes.js.map +1 -0
- package/dist/src/generate/contact.d.ts +31 -0
- package/dist/src/generate/contact.d.ts.map +1 -0
- package/dist/src/generate/contact.js +139 -0
- package/dist/src/generate/contact.js.map +1 -0
- package/dist/src/generate/crypto.d.ts +27 -0
- package/dist/src/generate/crypto.d.ts.map +1 -0
- package/dist/src/generate/crypto.js +88 -0
- package/dist/src/generate/crypto.js.map +1 -0
- package/dist/src/generate/documents.d.ts +24 -0
- package/dist/src/generate/documents.d.ts.map +1 -0
- package/dist/src/generate/documents.js +124 -0
- package/dist/src/generate/documents.js.map +1 -0
- package/dist/src/generate/financial.d.ts +26 -0
- package/dist/src/generate/financial.d.ts.map +1 -0
- package/dist/src/generate/financial.js +136 -0
- package/dist/src/generate/financial.js.map +1 -0
- package/dist/src/generate/index.d.ts +23 -0
- package/dist/src/generate/index.d.ts.map +1 -0
- package/dist/src/generate/index.js +23 -0
- package/dist/src/generate/index.js.map +1 -0
- package/dist/src/generate/location.d.ts +12 -0
- package/dist/src/generate/location.d.ts.map +1 -0
- package/dist/src/generate/location.js +75 -0
- package/dist/src/generate/location.js.map +1 -0
- package/dist/src/generate/natidAmOc.d.ts +22 -0
- package/dist/src/generate/natidAmOc.d.ts.map +1 -0
- package/dist/src/generate/natidAmOc.js +181 -0
- package/dist/src/generate/natidAmOc.js.map +1 -0
- package/dist/src/generate/natidAsia.d.ts +20 -0
- package/dist/src/generate/natidAsia.d.ts.map +1 -0
- package/dist/src/generate/natidAsia.js +147 -0
- package/dist/src/generate/natidAsia.js.map +1 -0
- package/dist/src/generate/natidCee.d.ts +21 -0
- package/dist/src/generate/natidCee.d.ts.map +1 -0
- package/dist/src/generate/natidCee.js +181 -0
- package/dist/src/generate/natidCee.js.map +1 -0
- package/dist/src/generate/natidMeCis.d.ts +17 -0
- package/dist/src/generate/natidMeCis.d.ts.map +1 -0
- package/dist/src/generate/natidMeCis.js +121 -0
- package/dist/src/generate/natidMeCis.js.map +1 -0
- package/dist/src/generate/natidWest.d.ts +32 -0
- package/dist/src/generate/natidWest.d.ts.map +1 -0
- package/dist/src/generate/natidWest.js +187 -0
- package/dist/src/generate/natidWest.js.map +1 -0
- package/dist/src/generate/prng.d.ts +10 -0
- package/dist/src/generate/prng.d.ts.map +1 -0
- package/dist/src/generate/prng.js +18 -0
- package/dist/src/generate/prng.js.map +1 -0
- package/dist/src/generate/secrets.d.ts +23 -0
- package/dist/src/generate/secrets.d.ts.map +1 -0
- package/dist/src/generate/secrets.js +126 -0
- package/dist/src/generate/secrets.js.map +1 -0
- package/dist/src/generate/vat.d.ts +11 -0
- package/dist/src/generate/vat.d.ts.map +1 -0
- package/dist/src/generate/vat.js +233 -0
- package/dist/src/generate/vat.js.map +1 -0
- package/dist/src/index.d.ts +81 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +76 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/mask/egressGuard.d.ts +54 -0
- package/dist/src/mask/egressGuard.d.ts.map +1 -0
- package/dist/src/mask/egressGuard.js +67 -0
- package/dist/src/mask/egressGuard.js.map +1 -0
- package/dist/src/mask/masker.d.ts +76 -0
- package/dist/src/mask/masker.d.ts.map +1 -0
- package/dist/src/mask/masker.js +201 -0
- package/dist/src/mask/masker.js.map +1 -0
- package/dist/src/mask/restorer.d.ts +96 -0
- package/dist/src/mask/restorer.d.ts.map +1 -0
- package/dist/src/mask/restorer.js +263 -0
- package/dist/src/mask/restorer.js.map +1 -0
- package/dist/src/mask/surrogatePools.d.ts +33 -0
- package/dist/src/mask/surrogatePools.d.ts.map +1 -0
- package/dist/src/mask/surrogatePools.js +81 -0
- package/dist/src/mask/surrogatePools.js.map +1 -0
- package/dist/src/mask/surrogates.d.ts +45 -0
- package/dist/src/mask/surrogates.d.ts.map +1 -0
- package/dist/src/mask/surrogates.js +241 -0
- package/dist/src/mask/surrogates.js.map +1 -0
- package/dist/src/mask/vault.d.ts +76 -0
- package/dist/src/mask/vault.d.ts.map +1 -0
- package/dist/src/mask/vault.js +141 -0
- package/dist/src/mask/vault.js.map +1 -0
- package/dist/src/ner/align.d.ts +36 -0
- package/dist/src/ner/align.d.ts.map +1 -0
- package/dist/src/ner/align.js +73 -0
- package/dist/src/ner/align.js.map +1 -0
- package/dist/src/ner/chunk.d.ts +27 -0
- package/dist/src/ner/chunk.d.ts.map +1 -0
- package/dist/src/ner/chunk.js +55 -0
- package/dist/src/ner/chunk.js.map +1 -0
- package/dist/src/ner/chunkCache.d.ts +63 -0
- package/dist/src/ner/chunkCache.d.ts.map +1 -0
- package/dist/src/ner/chunkCache.js +99 -0
- package/dist/src/ner/chunkCache.js.map +1 -0
- package/dist/src/ner/engine.d.ts +53 -0
- package/dist/src/ner/engine.d.ts.map +1 -0
- package/dist/src/ner/engine.js +113 -0
- package/dist/src/ner/engine.js.map +1 -0
- package/dist/src/ner/merge.d.ts +26 -0
- package/dist/src/ner/merge.d.ts.map +1 -0
- package/dist/src/ner/merge.js +108 -0
- package/dist/src/ner/merge.js.map +1 -0
- package/dist/src/ner/runStage2.d.ts +17 -0
- package/dist/src/ner/runStage2.d.ts.map +1 -0
- package/dist/src/ner/runStage2.js +43 -0
- package/dist/src/ner/runStage2.js.map +1 -0
- package/dist/src/ner/stage2b.d.ts +59 -0
- package/dist/src/ner/stage2b.d.ts.map +1 -0
- package/dist/src/ner/stage2b.js +51 -0
- package/dist/src/ner/stage2b.js.map +1 -0
- package/dist/src/ner/transformersClassifier.d.ts +45 -0
- package/dist/src/ner/transformersClassifier.d.ts.map +1 -0
- package/dist/src/ner/transformersClassifier.js +40 -0
- package/dist/src/ner/transformersClassifier.js.map +1 -0
- package/dist/src/ner/types.d.ts +93 -0
- package/dist/src/ner/types.d.ts.map +1 -0
- package/dist/src/ner/types.js +12 -0
- package/dist/src/ner/types.js.map +1 -0
- package/dist/src/normalization.d.ts +24 -0
- package/dist/src/normalization.d.ts.map +1 -0
- package/dist/src/normalization.js +92 -0
- package/dist/src/normalization.js.map +1 -0
- package/dist/src/offsetMap.d.ts +165 -0
- package/dist/src/offsetMap.d.ts.map +1 -0
- package/dist/src/offsetMap.js +225 -0
- package/dist/src/offsetMap.js.map +1 -0
- package/dist/src/pipeline.d.ts +58 -0
- package/dist/src/pipeline.d.ts.map +1 -0
- package/dist/src/pipeline.js +57 -0
- package/dist/src/pipeline.js.map +1 -0
- package/dist/src/protect.d.ts +146 -0
- package/dist/src/protect.d.ts.map +1 -0
- package/dist/src/protect.js +161 -0
- package/dist/src/protect.js.map +1 -0
- package/dist/src/scripts.d.ts +37 -0
- package/dist/src/scripts.d.ts.map +1 -0
- package/dist/src/scripts.js +145 -0
- package/dist/src/scripts.js.map +1 -0
- package/dist/src/transforms/foldDigits.d.ts +49 -0
- package/dist/src/transforms/foldDigits.d.ts.map +1 -0
- package/dist/src/transforms/foldDigits.js +135 -0
- package/dist/src/transforms/foldDigits.js.map +1 -0
- package/dist/src/transforms/graphemes.d.ts +6 -0
- package/dist/src/transforms/graphemes.d.ts.map +1 -0
- package/dist/src/transforms/graphemes.js +6 -0
- package/dist/src/transforms/graphemes.js.map +1 -0
- package/dist/src/transforms/homoglyphFold.d.ts +5 -0
- package/dist/src/transforms/homoglyphFold.d.ts.map +1 -0
- package/dist/src/transforms/homoglyphFold.js +214 -0
- package/dist/src/transforms/homoglyphFold.js.map +1 -0
- package/dist/src/transforms/nfkc.d.ts +20 -0
- package/dist/src/transforms/nfkc.d.ts.map +1 -0
- package/dist/src/transforms/nfkc.js +48 -0
- package/dist/src/transforms/nfkc.js.map +1 -0
- package/dist/src/transforms/stripInvisibles.d.ts +37 -0
- package/dist/src/transforms/stripInvisibles.d.ts.map +1 -0
- package/dist/src/transforms/stripInvisibles.js +151 -0
- package/dist/src/transforms/stripInvisibles.js.map +1 -0
- package/dist/src/transforms/whitespacePunct.d.ts +21 -0
- package/dist/src/transforms/whitespacePunct.d.ts.map +1 -0
- package/dist/src/transforms/whitespacePunct.js +100 -0
- package/dist/src/transforms/whitespacePunct.js.map +1 -0
- package/dist/src/types.d.ts +212 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/types.js +14 -0
- package/dist/src/types.js.map +1 -0
- package/package.json +67 -0
- package/src/checksums/aba.ts +45 -0
- package/src/checksums/digits.ts +108 -0
- package/src/checksums/icao9303.ts +53 -0
- package/src/checksums/index.ts +36 -0
- package/src/checksums/iso7064.ts +168 -0
- package/src/checksums/luhn.ts +66 -0
- package/src/checksums/mod97.ts +91 -0
- package/src/checksums/verhoeff.ts +84 -0
- package/src/checksums/weighted.ts +108 -0
- package/src/context/documentProfile.ts +293 -0
- package/src/context/negativeRules.ts +765 -0
- package/src/context/score.ts +430 -0
- package/src/context/structure.ts +611 -0
- package/src/context/triggers.ts +266 -0
- package/src/context/types.ts +150 -0
- package/src/crypto/keccak256.ts +98 -0
- package/src/crypto/sha256.ts +76 -0
- package/src/detect/AUTHORING.md +50 -0
- package/src/detect/detectors/bankcodes/auBsb.ts +36 -0
- package/src/detect/detectors/bankcodes/brAgencia.ts +46 -0
- package/src/detect/detectors/bankcodes/caTransit.ts +89 -0
- package/src/detect/detectors/bankcodes/inIfsc.ts +40 -0
- package/src/detect/detectors/bankcodes/index.ts +9 -0
- package/src/detect/detectors/bankcodes/ukSortCode.ts +38 -0
- package/src/detect/detectors/bankcodes/usRouting.ts +47 -0
- package/src/detect/detectors/contact/email.ts +113 -0
- package/src/detect/detectors/contact/index.ts +10 -0
- package/src/detect/detectors/contact/ipv4.ts +112 -0
- package/src/detect/detectors/contact/ipv6.ts +188 -0
- package/src/detect/detectors/contact/mac.ts +68 -0
- package/src/detect/detectors/contact/phone.ts +81 -0
- package/src/detect/detectors/contact/urlCredentials.ts +124 -0
- package/src/detect/detectors/crypto/ada.ts +52 -0
- package/src/detect/detectors/crypto/btc.ts +77 -0
- package/src/detect/detectors/crypto/dot.ts +42 -0
- package/src/detect/detectors/crypto/eth.ts +70 -0
- package/src/detect/detectors/crypto/index.ts +11 -0
- package/src/detect/detectors/crypto/ltc.ts +69 -0
- package/src/detect/detectors/crypto/sol.ts +41 -0
- package/src/detect/detectors/crypto/trx.ts +35 -0
- package/src/detect/detectors/crypto/xmr.ts +54 -0
- package/src/detect/detectors/documents/driversLicense.ts +83 -0
- package/src/detect/detectors/documents/healthData.ts +88 -0
- package/src/detect/detectors/documents/index.ts +8 -0
- package/src/detect/detectors/documents/passportMrz.ts +203 -0
- package/src/detect/detectors/documents/usNpi.ts +50 -0
- package/src/detect/detectors/documents/vin.ts +67 -0
- package/src/detect/detectors/financial/creditCard.ts +167 -0
- package/src/detect/detectors/financial/iban.ts +82 -0
- package/src/detect/detectors/financial/ibanRegistry.ts +112 -0
- package/src/detect/detectors/financial/index.ts +6 -0
- package/src/detect/detectors/financial/swiftBic.ts +61 -0
- package/src/detect/detectors/index.ts +14 -0
- package/src/detect/detectors/location/coordinates.ts +84 -0
- package/src/detect/detectors/location/index.ts +6 -0
- package/src/detect/detectors/location/postalCode.ts +56 -0
- package/src/detect/detectors/location/postalRegistry.ts +74 -0
- package/src/detect/detectors/location/streetAddress.ts +84 -0
- package/src/detect/detectors/natid/africa.ts +108 -0
- package/src/detect/detectors/natid/ar.ts +62 -0
- package/src/detect/detectors/natid/au.ts +99 -0
- package/src/detect/detectors/natid/be.ts +45 -0
- package/src/detect/detectors/natid/bg.ts +44 -0
- package/src/detect/detectors/natid/br.ts +81 -0
- package/src/detect/detectors/natid/ca.ts +40 -0
- package/src/detect/detectors/natid/cl.ts +47 -0
- package/src/detect/detectors/natid/cn.ts +48 -0
- package/src/detect/detectors/natid/co.ts +46 -0
- package/src/detect/detectors/natid/cz.ts +44 -0
- package/src/detect/detectors/natid/de.ts +75 -0
- package/src/detect/detectors/natid/dk.ts +31 -0
- package/src/detect/detectors/natid/es.ts +95 -0
- package/src/detect/detectors/natid/fi.ts +41 -0
- package/src/detect/detectors/natid/fr.ts +63 -0
- package/src/detect/detectors/natid/gb.ts +70 -0
- package/src/detect/detectors/natid/gr.ts +35 -0
- package/src/detect/detectors/natid/gulf.ts +116 -0
- package/src/detect/detectors/natid/hk.ts +42 -0
- package/src/detect/detectors/natid/hr.ts +32 -0
- package/src/detect/detectors/natid/hu.ts +36 -0
- package/src/detect/detectors/natid/ie.ts +37 -0
- package/src/detect/detectors/natid/il.ts +37 -0
- package/src/detect/detectors/natid/in.ts +67 -0
- package/src/detect/detectors/natid/index.ts +54 -0
- package/src/detect/detectors/natid/is.ts +42 -0
- package/src/detect/detectors/natid/it.ts +65 -0
- package/src/detect/detectors/natid/jp.ts +48 -0
- package/src/detect/detectors/natid/kr.ts +41 -0
- package/src/detect/detectors/natid/kz.ts +44 -0
- package/src/detect/detectors/natid/mx.ts +83 -0
- package/src/detect/detectors/natid/nl.ts +38 -0
- package/src/detect/detectors/natid/no.ts +50 -0
- package/src/detect/detectors/natid/nz.ts +53 -0
- package/src/detect/detectors/natid/pe.ts +28 -0
- package/src/detect/detectors/natid/pl.ts +100 -0
- package/src/detect/detectors/natid/pt.ts +36 -0
- package/src/detect/detectors/natid/ro.ts +47 -0
- package/src/detect/detectors/natid/ru.ts +82 -0
- package/src/detect/detectors/natid/se.ts +42 -0
- package/src/detect/detectors/natid/seasia.ts +174 -0
- package/src/detect/detectors/natid/sg.ts +39 -0
- package/src/detect/detectors/natid/si.ts +42 -0
- package/src/detect/detectors/natid/tr.ts +76 -0
- package/src/detect/detectors/natid/tw.ts +41 -0
- package/src/detect/detectors/natid/ua.ts +38 -0
- package/src/detect/detectors/natid/us.ts +118 -0
- package/src/detect/detectors/natid/za.ts +42 -0
- package/src/detect/detectors/secrets/apiKey.ts +115 -0
- package/src/detect/detectors/secrets/connectionString.ts +71 -0
- package/src/detect/detectors/secrets/genericSecret.ts +81 -0
- package/src/detect/detectors/secrets/index.ts +8 -0
- package/src/detect/detectors/secrets/jwt.ts +101 -0
- package/src/detect/detectors/secrets/pemPrivateKey.ts +59 -0
- package/src/detect/detectors/vat/euVat.ts +280 -0
- package/src/detect/detectors/vat/index.ts +4 -0
- package/src/detect/entropy.ts +60 -0
- package/src/detect/isoCountries.ts +30 -0
- package/src/detect/registry.ts +134 -0
- package/src/detect/runner.ts +187 -0
- package/src/detect/types.ts +296 -0
- package/src/encoding/base58.ts +85 -0
- package/src/encoding/base58monero.ts +90 -0
- package/src/encoding/bech32.ts +125 -0
- package/src/encoding/bytes.ts +48 -0
- package/src/entityFamily.ts +70 -0
- package/src/entityLabel.ts +56 -0
- package/src/entityTypes.ts +107 -0
- package/src/exposure/index.ts +189 -0
- package/src/fuse/calibrate.ts +224 -0
- package/src/fuse/defaultCalibration.ts +71 -0
- package/src/fuse/explain.ts +114 -0
- package/src/fuse/profiles.ts +187 -0
- package/src/fuse/resolve.ts +237 -0
- package/src/gazetteer/index.ts +139 -0
- package/src/generate/bankcodes.ts +82 -0
- package/src/generate/contact.ts +147 -0
- package/src/generate/crypto.ts +91 -0
- package/src/generate/documents.ts +142 -0
- package/src/generate/financial.ts +149 -0
- package/src/generate/index.ts +22 -0
- package/src/generate/location.ts +80 -0
- package/src/generate/natidAmOc.ts +198 -0
- package/src/generate/natidAsia.ts +162 -0
- package/src/generate/natidCee.ts +196 -0
- package/src/generate/natidMeCis.ts +131 -0
- package/src/generate/natidWest.ts +208 -0
- package/src/generate/prng.ts +17 -0
- package/src/generate/secrets.ts +141 -0
- package/src/generate/vat.ts +239 -0
- package/src/index.ts +186 -0
- package/src/mask/egressGuard.ts +88 -0
- package/src/mask/masker.ts +276 -0
- package/src/mask/restorer.ts +284 -0
- package/src/mask/surrogatePools.ts +96 -0
- package/src/mask/surrogates.ts +248 -0
- package/src/mask/vault.ts +153 -0
- package/src/ner/align.ts +86 -0
- package/src/ner/chunk.ts +65 -0
- package/src/ner/chunkCache.ts +110 -0
- package/src/ner/engine.ts +141 -0
- package/src/ner/merge.ts +123 -0
- package/src/ner/runStage2.ts +51 -0
- package/src/ner/stage2b.ts +73 -0
- package/src/ner/transformersClassifier.ts +79 -0
- package/src/ner/types.ts +99 -0
- package/src/normalization.ts +119 -0
- package/src/offsetMap.ts +271 -0
- package/src/pipeline.ts +96 -0
- package/src/protect.ts +284 -0
- package/src/scripts.ts +164 -0
- package/src/transforms/foldDigits.ts +138 -0
- package/src/transforms/graphemes.ts +5 -0
- package/src/transforms/homoglyphFold.ts +221 -0
- package/src/transforms/nfkc.ts +48 -0
- package/src/transforms/stripInvisibles.ts +158 -0
- package/src/transforms/whitespacePunct.ts +100 -0
- package/src/types.ts +339 -0
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* merge.ts — decode per-token BIO labels into entity spans.
|
|
3
|
+
*
|
|
4
|
+
* Handles BOTH tagging conventions the candidate models use:
|
|
5
|
+
* • IOB2 (mBERT/distilmBERT NER-HRL): entities start with B-X.
|
|
6
|
+
* • IOB1 (XLM-R CoNLL fine-tunes): entities may start with I-X after O
|
|
7
|
+
* or at sequence start; B-X appears only to split adjacent same-type
|
|
8
|
+
* entities.
|
|
9
|
+
* Decoding rule that satisfies both: a token starts a NEW entity when its
|
|
10
|
+
* label is B-X, or when it is I-X and the previous token was not part of
|
|
11
|
+
* an X entity. Same-type I-X continues; any other label ends the entity.
|
|
12
|
+
*
|
|
13
|
+
* Unlocated pieces ([UNK] and friends) inside an entity are BRIDGED: the
|
|
14
|
+
* entity's span runs from its first located piece to its last located
|
|
15
|
+
* piece. An entity with no located piece at all is dropped — emitting a
|
|
16
|
+
* guessed span would violate the exact-offsets contract.
|
|
17
|
+
*
|
|
18
|
+
* The entity score is the MINIMUM token score — one uncertain token makes
|
|
19
|
+
* the whole span uncertain. Scores are uncalibrated model softmax until
|
|
20
|
+
* Stage 4 (M8) calibrates; the eval buckets measure what they are worth.
|
|
21
|
+
*/
|
|
22
|
+
/** Model label suffix → Discretion entity type. MISC and friends drop. */
|
|
23
|
+
const DEFAULT_LABEL_TYPES = {
|
|
24
|
+
PER: 'PERSON',
|
|
25
|
+
PERSON: 'PERSON',
|
|
26
|
+
ORG: 'ORG',
|
|
27
|
+
LOC: 'LOCATION',
|
|
28
|
+
LOCATION: 'LOCATION',
|
|
29
|
+
GPE: 'LOCATION',
|
|
30
|
+
};
|
|
31
|
+
function labelParts(label) {
|
|
32
|
+
if (label === 'O' || label === '')
|
|
33
|
+
return { prefix: 'O' };
|
|
34
|
+
const dash = label.indexOf('-');
|
|
35
|
+
const prefix = label.slice(0, dash === -1 ? undefined : dash);
|
|
36
|
+
const suffix = dash === -1 ? label : label.slice(dash + 1);
|
|
37
|
+
const type = DEFAULT_LABEL_TYPES[suffix.toUpperCase()];
|
|
38
|
+
if ((prefix === 'B' || prefix === 'I') && type !== undefined) {
|
|
39
|
+
return { prefix, type };
|
|
40
|
+
}
|
|
41
|
+
return { prefix: 'O' };
|
|
42
|
+
}
|
|
43
|
+
/** Decode predictions + aligned spans into merged entity spans. */
|
|
44
|
+
export function decodeEntities(text, predictions, aligned) {
|
|
45
|
+
const spans = [];
|
|
46
|
+
let open = null;
|
|
47
|
+
const close = () => {
|
|
48
|
+
if (open !== null && open.located && open.end > open.start) {
|
|
49
|
+
spans.push({
|
|
50
|
+
type: open.type,
|
|
51
|
+
start: open.start,
|
|
52
|
+
end: open.end,
|
|
53
|
+
text: text.slice(open.start, open.end),
|
|
54
|
+
score: open.score,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
open = null;
|
|
58
|
+
};
|
|
59
|
+
for (let i = 0; i < predictions.length; i++) {
|
|
60
|
+
const pred = predictions[i];
|
|
61
|
+
const span = aligned[i];
|
|
62
|
+
if (span === undefined)
|
|
63
|
+
break; // defensive: prediction/alignment mismatch
|
|
64
|
+
const { prefix, type } = labelParts(pred.label);
|
|
65
|
+
if (prefix === 'O' || type === undefined) {
|
|
66
|
+
close();
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
const continues = open !== null && open.type === type && prefix === 'I';
|
|
70
|
+
if (continues && open !== null) {
|
|
71
|
+
if (span.located) {
|
|
72
|
+
if (!open.located)
|
|
73
|
+
open.start = span.start; // first located piece
|
|
74
|
+
open.end = span.end;
|
|
75
|
+
open.located = true;
|
|
76
|
+
}
|
|
77
|
+
open.score = Math.min(open.score, pred.score);
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
close();
|
|
81
|
+
open = {
|
|
82
|
+
type,
|
|
83
|
+
start: span.start,
|
|
84
|
+
end: span.end,
|
|
85
|
+
score: pred.score,
|
|
86
|
+
located: span.located,
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
close();
|
|
91
|
+
return spans.map(trimSpan(text)).filter((s) => s !== null);
|
|
92
|
+
}
|
|
93
|
+
/** Trim surrounding whitespace the model occasionally absorbs into a span. */
|
|
94
|
+
function trimSpan(text) {
|
|
95
|
+
return (s) => {
|
|
96
|
+
let { start, end } = s;
|
|
97
|
+
while (start < end && /\s/.test(text[start]))
|
|
98
|
+
start += 1;
|
|
99
|
+
while (end > start && /\s/.test(text[end - 1]))
|
|
100
|
+
end -= 1;
|
|
101
|
+
if (end <= start)
|
|
102
|
+
return null;
|
|
103
|
+
if (start === s.start && end === s.end)
|
|
104
|
+
return s;
|
|
105
|
+
return { ...s, start, end, text: text.slice(start, end) };
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
//# sourceMappingURL=merge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"merge.js","sourceRoot":"","sources":["../../../src/ner/merge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAKH,0EAA0E;AAC1E,MAAM,mBAAmB,GAA4C;IACnE,GAAG,EAAE,QAAQ;IACb,MAAM,EAAE,QAAQ;IAChB,GAAG,EAAE,KAAK;IACV,GAAG,EAAE,UAAU;IACf,QAAQ,EAAE,UAAU;IACpB,GAAG,EAAE,UAAU;CAChB,CAAC;AAUF,SAAS,UAAU,CAAC,KAAa;IAC/B,IAAI,KAAK,KAAK,GAAG,IAAI,KAAK,KAAK,EAAE;QAAE,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC;IAC1D,MAAM,IAAI,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAChC,MAAM,MAAM,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IAC9D,MAAM,MAAM,GAAG,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC;IAC3D,MAAM,IAAI,GAAG,mBAAmB,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,CAAC;IACvD,IAAI,CAAC,MAAM,KAAK,GAAG,IAAI,MAAM,KAAK,GAAG,CAAC,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QAC7D,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;IAC1B,CAAC;IACD,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC;AACzB,CAAC;AAED,mEAAmE;AACnE,MAAM,UAAU,cAAc,CAC5B,IAAY,EACZ,WAAuC,EACvC,OAAgC;IAEhC,MAAM,KAAK,GAAc,EAAE,CAAC;IAC5B,IAAI,IAAI,GAAgB,IAAI,CAAC;IAE7B,MAAM,KAAK,GAAG,GAAS,EAAE;QACvB,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,KAAK,EAAE,CAAC;YAC3D,KAAK,CAAC,IAAI,CAAC;gBACT,IAAI,EAAE,IAAI,CAAC,IAAI;gBACf,KAAK,EAAE,IAAI,CAAC,KAAK;gBACjB,GAAG,EAAE,IAAI,CAAC,GAAG;gBACb,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC;gBACtC,KAAK,EAAE,IAAI,CAAC,KAAK;aAClB,CAAC,CAAC;QACL,CAAC;QACD,IAAI,GAAG,IAAI,CAAC;IACd,CAAC,CAAC;IAEF,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,WAAW,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QAC5C,MAAM,IAAI,GAAG,WAAW,CAAC,CAAC,CAAE,CAAC;QAC7B,MAAM,IAAI,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;QACxB,IAAI,IAAI,KAAK,SAAS;YAAE,MAAM,CAAC,2CAA2C;QAC1E,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAEhD,IAAI,MAAM,KAAK,GAAG,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;YACzC,KAAK,EAAE,CAAC;YACR,SAAS;QACX,CAAC;QAED,MAAM,SAAS,GAAG,IAAI,KAAK,IAAI,IAAI,IAAI,CAAC,IAAI,KAAK,IAAI,IAAI,MAAM,KAAK,GAAG,CAAC;QACxE,IAAI,SAAS,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;YAC/B,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;gBACjB,IAAI,CAAC,IAAI,CAAC,OAAO;oBAAE,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,sBAAsB;gBAClE,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC;gBACpB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;YACtB,CAAC;YACD,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;QAChD,CAAC;aAAM,CAAC;YACN,KAAK,EAAE,CAAC;YACR,IAAI,GAAG;gBACL,IAAI;gBACJ,KAAK,EAAE,IAAI,CAAC,KAAK;gBACjB,GAAG,EAAE,IAAI,CAAC,GAAG;gBACb,KAAK,EAAE,IAAI,CAAC,KAAK;gBACjB,OAAO,EAAE,IAAI,CAAC,OAAO;aACtB,CAAC;QACJ,CAAC;IACH,CAAC;IACD,KAAK,EAAE,CAAC;IAER,OAAO,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAgB,EAAE,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC;AAC3E,CAAC;AAED,8EAA8E;AAC9E,SAAS,QAAQ,CAAC,IAAY;IAC5B,OAAO,CAAC,CAAC,EAAE,EAAE;QACX,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;QACvB,OAAO,KAAK,GAAG,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAE,CAAC;YAAE,KAAK,IAAI,CAAC,CAAC;QAC1D,OAAO,GAAG,GAAG,KAAK,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,CAAE,CAAC;YAAE,GAAG,IAAI,CAAC,CAAC;QAC1D,IAAI,GAAG,IAAI,KAAK;YAAE,OAAO,IAAI,CAAC;QAC9B,IAAI,KAAK,KAAK,CAAC,CAAC,KAAK,IAAI,GAAG,KAAK,CAAC,CAAC,GAAG;YAAE,OAAO,CAAC,CAAC;QACjD,OAAO,EAAE,GAAG,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,GAAG,CAAC,EAAE,CAAC;IAC5D,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* runStage2.ts — produce Stage 2 candidates in the pipeline's shared shape.
|
|
3
|
+
*
|
|
4
|
+
* Mirrors the Stage 1 runner's contract: detection runs on NORMALIZED text
|
|
5
|
+
* and every candidate carries its exact ORIGINAL span, resolved through the
|
|
6
|
+
* Stage 0 offset map with mapNormalizedSpan (never raw map indexing — see
|
|
7
|
+
* the M1 offset-map contract).
|
|
8
|
+
*
|
|
9
|
+
* rawConfidence is the model's softmax score, unchanged and explicitly
|
|
10
|
+
* uncalibrated — the eval measures what those scores are worth per bucket,
|
|
11
|
+
* and Stage 4 (M8) calibrates. Inventing a mapping here would launder an
|
|
12
|
+
* unmeasured number into a measured-looking one.
|
|
13
|
+
*/
|
|
14
|
+
import type { NormalizationResult } from '../types.js';
|
|
15
|
+
import type { NerRecognizer, Stage2Candidate } from './types.js';
|
|
16
|
+
export declare function runStage2(normalization: NormalizationResult, engine: NerRecognizer): Promise<Stage2Candidate[]>;
|
|
17
|
+
//# sourceMappingURL=runStage2.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runStage2.d.ts","sourceRoot":"","sources":["../../../src/ner/runStage2.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAEvD,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAOjE,wBAAsB,SAAS,CAC7B,aAAa,EAAE,mBAAmB,EAClC,MAAM,EAAE,aAAa,GACpB,OAAO,CAAC,eAAe,EAAE,CAAC,CAwB5B"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* runStage2.ts — produce Stage 2 candidates in the pipeline's shared shape.
|
|
3
|
+
*
|
|
4
|
+
* Mirrors the Stage 1 runner's contract: detection runs on NORMALIZED text
|
|
5
|
+
* and every candidate carries its exact ORIGINAL span, resolved through the
|
|
6
|
+
* Stage 0 offset map with mapNormalizedSpan (never raw map indexing — see
|
|
7
|
+
* the M1 offset-map contract).
|
|
8
|
+
*
|
|
9
|
+
* rawConfidence is the model's softmax score, unchanged and explicitly
|
|
10
|
+
* uncalibrated — the eval measures what those scores are worth per bucket,
|
|
11
|
+
* and Stage 4 (M8) calibrates. Inventing a mapping here would launder an
|
|
12
|
+
* unmeasured number into a measured-looking one.
|
|
13
|
+
*/
|
|
14
|
+
import { mapNormalizedSpan } from '../offsetMap.js';
|
|
15
|
+
/** Collapse interior whitespace so trivial layout variants share a key. */
|
|
16
|
+
function canonicalName(text) {
|
|
17
|
+
return text.replace(/\s+/g, ' ').trim();
|
|
18
|
+
}
|
|
19
|
+
export async function runStage2(normalization, engine) {
|
|
20
|
+
const { normalizedText, offsetMap } = normalization;
|
|
21
|
+
const spans = await engine.recognize(normalizedText);
|
|
22
|
+
return spans.map((span) => {
|
|
23
|
+
const original = mapNormalizedSpan(offsetMap, span.start, span.end);
|
|
24
|
+
return {
|
|
25
|
+
text: span.text,
|
|
26
|
+
type: span.type,
|
|
27
|
+
start: span.start,
|
|
28
|
+
end: span.end,
|
|
29
|
+
originalStart: original.start,
|
|
30
|
+
originalEnd: original.end,
|
|
31
|
+
rawConfidence: span.score,
|
|
32
|
+
stage: 'stage2-ner',
|
|
33
|
+
detectorId: `ner:${engine.id}`,
|
|
34
|
+
sensitive: true,
|
|
35
|
+
canonical: canonicalName(span.text),
|
|
36
|
+
metadata: { model: engine.id },
|
|
37
|
+
// Carried rather than re-looked-up: the hit was computed where the
|
|
38
|
+
// gazetteers live, which may be a different process from this one.
|
|
39
|
+
...(span.gazetteer === undefined ? {} : { gazetteer: span.gazetteer }),
|
|
40
|
+
};
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=runStage2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runStage2.js","sourceRoot":"","sources":["../../../src/ner/runStage2.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAGpD,2EAA2E;AAC3E,SAAS,aAAa,CAAC,IAAY;IACjC,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;AAC1C,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,SAAS,CAC7B,aAAkC,EAClC,MAAqB;IAErB,MAAM,EAAE,cAAc,EAAE,SAAS,EAAE,GAAG,aAAa,CAAC;IACpD,MAAM,KAAK,GAAG,MAAM,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;IAErD,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;QACxB,MAAM,QAAQ,GAAG,iBAAiB,CAAC,SAAS,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC;QACpE,OAAO;YACL,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,GAAG,EAAE,IAAI,CAAC,GAAG;YACb,aAAa,EAAE,QAAQ,CAAC,KAAK;YAC7B,WAAW,EAAE,QAAQ,CAAC,GAAG;YACzB,aAAa,EAAE,IAAI,CAAC,KAAK;YACzB,KAAK,EAAE,YAAqB;YAC5B,UAAU,EAAE,OAAO,MAAM,CAAC,EAAE,EAAE;YAC9B,SAAS,EAAE,IAAI;YACf,SAAS,EAAE,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC;YACnC,QAAQ,EAAE,EAAE,KAAK,EAAE,MAAM,CAAC,EAAE,EAAE;YAC9B,mEAAmE;YACnE,mEAAmE;YACnE,GAAG,CAAC,IAAI,CAAC,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,IAAI,CAAC,SAAS,EAAE,CAAC;SACvE,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stage 2b — gazetteer corroboration, attached to the spans it corroborates.
|
|
3
|
+
*
|
|
4
|
+
* ─────────────────────────────────────────────────────────────────────────
|
|
5
|
+
* WHY THIS FILE EXISTS, WHICH IS A CORRECTION RATHER THAN A NEW FEATURE
|
|
6
|
+
*
|
|
7
|
+
* SPEC.md places the gazetteers in STAGE 2: "Bundled compressed lookup sets,
|
|
8
|
+
* checked in parallel with the model." The lookup had drifted into Stage 3's
|
|
9
|
+
* scorer, where it ran as one context signal among many.
|
|
10
|
+
*
|
|
11
|
+
* That placement was invisible until the extension was built, and then it was
|
|
12
|
+
* expensive in a way nothing else made visible. Stage 3 runs in the CONTENT
|
|
13
|
+
* SCRIPT. Its scorer statically imported the gazetteer module, so 3.4 MB of
|
|
14
|
+
* base64 Bloom filters were linked into a bundle that is parsed on every page
|
|
15
|
+
* load of all three sites — to serve PERSON, ORG and LOCATION candidates,
|
|
16
|
+
* which only Stage 2 produces, and which cannot exist at all in a build with
|
|
17
|
+
* no model attached.
|
|
18
|
+
*
|
|
19
|
+
* Moving the lookup here is not a size optimisation. It restores the stage
|
|
20
|
+
* boundary SPEC drew, and the size follows from that: the gazetteers now live
|
|
21
|
+
* on the same side of the process boundary as the model, because they answer
|
|
22
|
+
* questions only the model can ask.
|
|
23
|
+
*
|
|
24
|
+
* BEHAVIOUR IS UNCHANGED, and that is checkable rather than asserted: no
|
|
25
|
+
* Stage 1 detector declares PERSON, ORG or LOCATION (31 types, verified by
|
|
26
|
+
* enumeration), so no Stage 1 candidate could ever have reached the lookup in
|
|
27
|
+
* Stage 3. The contribution Stage 3 emits is byte-identical; it is now built
|
|
28
|
+
* from a hit computed here instead of one computed there.
|
|
29
|
+
* ─────────────────────────────────────────────────────────────────────────
|
|
30
|
+
*/
|
|
31
|
+
import type { GazetteerType } from '../gazetteer/index.js';
|
|
32
|
+
import type { NerEntityType, NerSpan } from './types.js';
|
|
33
|
+
/**
|
|
34
|
+
* The model's label set and the gazetteer's are the same three types.
|
|
35
|
+
*
|
|
36
|
+
* Asserted at COMPILE time rather than guarded at run time. The obvious
|
|
37
|
+
* implementation calls `isGazetteerType(span.type)` before each lookup - but
|
|
38
|
+
* `NerSpan.type` is already exactly those three, so that branch can never be
|
|
39
|
+
* false. A check that cannot fail reads as a safety property and is not one;
|
|
40
|
+
* this fails the BUILD if either union ever gains a member the other lacks,
|
|
41
|
+
* which is the moment the guard would have started mattering.
|
|
42
|
+
*/
|
|
43
|
+
type MissingFromGazetteer = Exclude<NerEntityType, GazetteerType>;
|
|
44
|
+
type MissingFromNer = Exclude<GazetteerType, NerEntityType>;
|
|
45
|
+
export type Stage2bTypesAgree = [MissingFromGazetteer, MissingFromNer] extends [never, never] ? true : never;
|
|
46
|
+
/**
|
|
47
|
+
* Attach gazetteer corroboration to each span.
|
|
48
|
+
*
|
|
49
|
+
* A miss attaches nothing rather than attaching an absent hit: "not in the
|
|
50
|
+
* gazetteer" is not evidence against a name — the sets are large but nowhere
|
|
51
|
+
* near complete — and a field distinguishing "looked and found nothing" from
|
|
52
|
+
* "did not look" would invite a caller to treat the first as a negative
|
|
53
|
+
* signal. `useGazetteers: false` and a genuine miss are meant to be
|
|
54
|
+
* indistinguishable downstream, because they justify the same conclusion:
|
|
55
|
+
* nothing was corroborated.
|
|
56
|
+
*/
|
|
57
|
+
export declare function attachGazetteerHits(spans: readonly NerSpan[]): NerSpan[];
|
|
58
|
+
export {};
|
|
59
|
+
//# sourceMappingURL=stage2b.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stage2b.d.ts","sourceRoot":"","sources":["../../../src/ner/stage2b.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,KAAK,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAEzD;;;;;;;;;GASG;AACH,KAAK,oBAAoB,GAAG,OAAO,CAAC,aAAa,EAAE,aAAa,CAAC,CAAC;AAClE,KAAK,cAAc,GAAG,OAAO,CAAC,aAAa,EAAE,aAAa,CAAC,CAAC;AAI5D,MAAM,MAAM,iBAAiB,GAAG,CAAC,oBAAoB,EAAE,cAAc,CAAC,SAAS,CAAC,KAAK,EAAE,KAAK,CAAC,GACzF,IAAI,GACJ,KAAK,CAAC;AAIV;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,SAAS,OAAO,EAAE,GAAG,OAAO,EAAE,CAKxE"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stage 2b — gazetteer corroboration, attached to the spans it corroborates.
|
|
3
|
+
*
|
|
4
|
+
* ─────────────────────────────────────────────────────────────────────────
|
|
5
|
+
* WHY THIS FILE EXISTS, WHICH IS A CORRECTION RATHER THAN A NEW FEATURE
|
|
6
|
+
*
|
|
7
|
+
* SPEC.md places the gazetteers in STAGE 2: "Bundled compressed lookup sets,
|
|
8
|
+
* checked in parallel with the model." The lookup had drifted into Stage 3's
|
|
9
|
+
* scorer, where it ran as one context signal among many.
|
|
10
|
+
*
|
|
11
|
+
* That placement was invisible until the extension was built, and then it was
|
|
12
|
+
* expensive in a way nothing else made visible. Stage 3 runs in the CONTENT
|
|
13
|
+
* SCRIPT. Its scorer statically imported the gazetteer module, so 3.4 MB of
|
|
14
|
+
* base64 Bloom filters were linked into a bundle that is parsed on every page
|
|
15
|
+
* load of all three sites — to serve PERSON, ORG and LOCATION candidates,
|
|
16
|
+
* which only Stage 2 produces, and which cannot exist at all in a build with
|
|
17
|
+
* no model attached.
|
|
18
|
+
*
|
|
19
|
+
* Moving the lookup here is not a size optimisation. It restores the stage
|
|
20
|
+
* boundary SPEC drew, and the size follows from that: the gazetteers now live
|
|
21
|
+
* on the same side of the process boundary as the model, because they answer
|
|
22
|
+
* questions only the model can ask.
|
|
23
|
+
*
|
|
24
|
+
* BEHAVIOUR IS UNCHANGED, and that is checkable rather than asserted: no
|
|
25
|
+
* Stage 1 detector declares PERSON, ORG or LOCATION (31 types, verified by
|
|
26
|
+
* enumeration), so no Stage 1 candidate could ever have reached the lookup in
|
|
27
|
+
* Stage 3. The contribution Stage 3 emits is byte-identical; it is now built
|
|
28
|
+
* from a hit computed here instead of one computed there.
|
|
29
|
+
* ─────────────────────────────────────────────────────────────────────────
|
|
30
|
+
*/
|
|
31
|
+
import { lookupGazetteer } from '../gazetteer/index.js';
|
|
32
|
+
const _typesAgree = true;
|
|
33
|
+
void _typesAgree;
|
|
34
|
+
/**
|
|
35
|
+
* Attach gazetteer corroboration to each span.
|
|
36
|
+
*
|
|
37
|
+
* A miss attaches nothing rather than attaching an absent hit: "not in the
|
|
38
|
+
* gazetteer" is not evidence against a name — the sets are large but nowhere
|
|
39
|
+
* near complete — and a field distinguishing "looked and found nothing" from
|
|
40
|
+
* "did not look" would invite a caller to treat the first as a negative
|
|
41
|
+
* signal. `useGazetteers: false` and a genuine miss are meant to be
|
|
42
|
+
* indistinguishable downstream, because they justify the same conclusion:
|
|
43
|
+
* nothing was corroborated.
|
|
44
|
+
*/
|
|
45
|
+
export function attachGazetteerHits(spans) {
|
|
46
|
+
return spans.map((span) => {
|
|
47
|
+
const hit = lookupGazetteer(span.text, span.type);
|
|
48
|
+
return hit === undefined ? span : { ...span, gazetteer: hit };
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=stage2b.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stage2b.js","sourceRoot":"","sources":["../../../src/ner/stage2b.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAsBxD,MAAM,WAAW,GAAsB,IAAI,CAAC;AAC5C,KAAK,WAAW,CAAC;AAEjB;;;;;;;;;;GAUG;AACH,MAAM,UAAU,mBAAmB,CAAC,KAAyB;IAC3D,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;QACxB,MAAM,GAAG,GAAG,eAAe,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;QAClD,OAAO,GAAG,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,SAAS,EAAE,GAAG,EAAE,CAAC;IAChE,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* transformersClassifier.ts — the Transformers.js/ONNX-backed
|
|
3
|
+
* TokenClassifier. Runs identically in Node (onnxruntime-node) and in a
|
|
4
|
+
* browser Web Worker (onnxruntime-web/WASM); hosting it in a worker is the
|
|
5
|
+
* consumer's concern (extension, M9), which keeps this module free of any
|
|
6
|
+
* environment-specific API.
|
|
7
|
+
*
|
|
8
|
+
* ZERO NETWORK BY DEFAULT: remote model fetching is opt-in
|
|
9
|
+
* (`allowRemoteModels`), used only by build-time tooling (today the eval
|
|
10
|
+
* benchmark and CLI; the extension's bundling step at M9). Production
|
|
11
|
+
* consumers load from the bundled cache and never touch the network — the
|
|
12
|
+
* SPEC non-negotiable.
|
|
13
|
+
*
|
|
14
|
+
* This module is exported through the dedicated `./ner-transformers` entry
|
|
15
|
+
* point, NOT the package root, so consumers who never run Stage 2 never
|
|
16
|
+
* load the ONNX runtime.
|
|
17
|
+
*/
|
|
18
|
+
import type { TokenClassifier } from './types.js';
|
|
19
|
+
export interface TransformersClassifierOptions {
|
|
20
|
+
/** HF repo id, e.g. 'Xenova/distilbert-base-multilingual-cased-ner-hrl'. */
|
|
21
|
+
readonly model: string;
|
|
22
|
+
/** Weight precision: 'fp32' | 'fp16' | 'q8' | 'int8' | 'uint8' | …. */
|
|
23
|
+
readonly dtype?: string;
|
|
24
|
+
/** Where model files live (bundle dir in production, cache in tooling). */
|
|
25
|
+
readonly cacheDir?: string;
|
|
26
|
+
/** Allow downloading missing models. Build-time tooling ONLY. */
|
|
27
|
+
readonly allowRemoteModels?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Pinned repo revision (commit hash). HF commits are content-addressed,
|
|
30
|
+
* so a pinned revision pins the exact model bytes — the integrity story
|
|
31
|
+
* for build-time bundling. Default 'main' is acceptable only in
|
|
32
|
+
* exploratory tooling.
|
|
33
|
+
*/
|
|
34
|
+
readonly revision?: string;
|
|
35
|
+
/** Short id for candidate metadata; defaults to model@dtype. */
|
|
36
|
+
readonly id?: string;
|
|
37
|
+
/**
|
|
38
|
+
* Per-window character budget. Default 400: the models' 512-token limit
|
|
39
|
+
* divided by the worst-case one-token-per-character ratio (CJK), with
|
|
40
|
+
* headroom for specials and subword expansion of unusual codepoints.
|
|
41
|
+
*/
|
|
42
|
+
readonly maxInputChars?: number;
|
|
43
|
+
}
|
|
44
|
+
export declare function createTransformersClassifier(options: TransformersClassifierOptions): Promise<TokenClassifier>;
|
|
45
|
+
//# sourceMappingURL=transformersClassifier.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transformersClassifier.d.ts","sourceRoot":"","sources":["../../../src/ner/transformersClassifier.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,OAAO,KAAK,EAAE,eAAe,EAAmB,MAAM,YAAY,CAAC;AAEnE,MAAM,WAAW,6BAA6B;IAC5C,4EAA4E;IAC5E,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,uEAAuE;IACvE,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,2EAA2E;IAC3E,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,iEAAiE;IACjE,QAAQ,CAAC,iBAAiB,CAAC,EAAE,OAAO,CAAC;IACrC;;;;;OAKG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,gEAAgE;IAChE,QAAQ,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC;IACrB;;;;OAIG;IACH,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;CACjC;AAUD,wBAAsB,4BAA4B,CAChD,OAAO,EAAE,6BAA6B,GACrC,OAAO,CAAC,eAAe,CAAC,CAqB1B"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* transformersClassifier.ts — the Transformers.js/ONNX-backed
|
|
3
|
+
* TokenClassifier. Runs identically in Node (onnxruntime-node) and in a
|
|
4
|
+
* browser Web Worker (onnxruntime-web/WASM); hosting it in a worker is the
|
|
5
|
+
* consumer's concern (extension, M9), which keeps this module free of any
|
|
6
|
+
* environment-specific API.
|
|
7
|
+
*
|
|
8
|
+
* ZERO NETWORK BY DEFAULT: remote model fetching is opt-in
|
|
9
|
+
* (`allowRemoteModels`), used only by build-time tooling (today the eval
|
|
10
|
+
* benchmark and CLI; the extension's bundling step at M9). Production
|
|
11
|
+
* consumers load from the bundled cache and never touch the network — the
|
|
12
|
+
* SPEC non-negotiable.
|
|
13
|
+
*
|
|
14
|
+
* This module is exported through the dedicated `./ner-transformers` entry
|
|
15
|
+
* point, NOT the package root, so consumers who never run Stage 2 never
|
|
16
|
+
* load the ONNX runtime.
|
|
17
|
+
*/
|
|
18
|
+
import { env, pipeline } from '@huggingface/transformers';
|
|
19
|
+
const DEFAULT_MAX_INPUT_CHARS = 400;
|
|
20
|
+
export async function createTransformersClassifier(options) {
|
|
21
|
+
if (options.cacheDir !== undefined)
|
|
22
|
+
env.cacheDir = options.cacheDir;
|
|
23
|
+
env.allowRemoteModels = options.allowRemoteModels ?? false;
|
|
24
|
+
const dtype = options.dtype ?? 'q8';
|
|
25
|
+
const nerPipeline = await pipeline('token-classification', options.model, {
|
|
26
|
+
dtype: dtype, // the runtime validates; its literal union lags its own docs
|
|
27
|
+
...(options.revision !== undefined ? { revision: options.revision } : {}),
|
|
28
|
+
});
|
|
29
|
+
const id = options.id ?? `${options.model.split('/').pop() ?? options.model}@${dtype}`;
|
|
30
|
+
const maxInputChars = options.maxInputChars ?? DEFAULT_MAX_INPUT_CHARS;
|
|
31
|
+
return {
|
|
32
|
+
id,
|
|
33
|
+
maxInputChars,
|
|
34
|
+
async classify(text) {
|
|
35
|
+
const raw = (await nerPipeline(text, { ignore_labels: [] }));
|
|
36
|
+
return raw.map((t) => ({ label: t.entity, score: t.score, piece: t.word }));
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=transformersClassifier.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transformersClassifier.js","sourceRoot":"","sources":["../../../src/ner/transformersClassifier.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAmC1D,MAAM,uBAAuB,GAAG,GAAG,CAAC;AAEpC,MAAM,CAAC,KAAK,UAAU,4BAA4B,CAChD,OAAsC;IAEtC,IAAI,OAAO,CAAC,QAAQ,KAAK,SAAS;QAAE,GAAG,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;IACpE,GAAG,CAAC,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,IAAI,KAAK,CAAC;IAE3D,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,IAAI,IAAI,CAAC;IACpC,MAAM,WAAW,GAAG,MAAM,QAAQ,CAAC,sBAAsB,EAAE,OAAO,CAAC,KAAK,EAAE;QACxE,KAAK,EAAE,KAAc,EAAE,6DAA6D;QACpF,GAAG,CAAC,OAAO,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC1E,CAAC,CAAC;IAEH,MAAM,EAAE,GAAG,OAAO,CAAC,EAAE,IAAI,GAAG,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,IAAI,OAAO,CAAC,KAAK,IAAI,KAAK,EAAE,CAAC;IACvF,MAAM,aAAa,GAAG,OAAO,CAAC,aAAa,IAAI,uBAAuB,CAAC;IAEvE,OAAO;QACL,EAAE;QACF,aAAa;QACb,KAAK,CAAC,QAAQ,CAAC,IAAY;YACzB,MAAM,GAAG,GAAG,CAAC,MAAM,WAAW,CAAC,IAAI,EAAE,EAAE,aAAa,EAAE,EAAE,EAAE,CAAC,CAA8B,CAAC;YAC1F,OAAO,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;QAC9E,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stage 2 (multilingual NER) — shared types.
|
|
3
|
+
*
|
|
4
|
+
* The model runtime is INJECTED behind `TokenClassifier`, so the pure parts
|
|
5
|
+
* of Stage 2 (piece→character alignment, BIO decoding, chunking, timeout
|
|
6
|
+
* discipline, candidate shaping) are testable without a model and the
|
|
7
|
+
* engine stays environment-agnostic. The Transformers.js-backed classifier
|
|
8
|
+
* lives in `transformersClassifier.ts`, exported through its own package
|
|
9
|
+
* entry point so that consumers who never run NER never load the runtime.
|
|
10
|
+
*/
|
|
11
|
+
import type { Stage1Candidate } from '../detect/types.js';
|
|
12
|
+
import type { GazetteerHit } from '../gazetteer/index.js';
|
|
13
|
+
/** One model token prediction, in input order, special tokens excluded. */
|
|
14
|
+
export interface TokenPrediction {
|
|
15
|
+
/** Raw model label, e.g. 'B-PER', 'I-ORG', 'O'. */
|
|
16
|
+
readonly label: string;
|
|
17
|
+
/** Model softmax score for that label. */
|
|
18
|
+
readonly score: number;
|
|
19
|
+
/**
|
|
20
|
+
* The token's surface piece as the runtime reports it: WordPiece
|
|
21
|
+
* continuations keep their '##' prefix; SentencePiece markers ('▁') may
|
|
22
|
+
* or may not be present — the aligner handles both.
|
|
23
|
+
*/
|
|
24
|
+
readonly piece: string;
|
|
25
|
+
}
|
|
26
|
+
/** The injected model runtime. */
|
|
27
|
+
export interface TokenClassifier {
|
|
28
|
+
/** Identifies the model in candidate metadata, e.g. 'distilmbert-ner-hrl@q8'. */
|
|
29
|
+
readonly id: string;
|
|
30
|
+
/**
|
|
31
|
+
* Safe per-call input size in CHARACTERS. Text longer than this must be
|
|
32
|
+
* windowed by the caller: transformer runtimes silently truncate past
|
|
33
|
+
* their token limit, and silent truncation would be silent fail-open.
|
|
34
|
+
* The floor of one token per character (CJK) makes chars the safe unit.
|
|
35
|
+
*/
|
|
36
|
+
readonly maxInputChars: number;
|
|
37
|
+
/** Classify one window of text. Pieces arrive in input order. */
|
|
38
|
+
classify(text: string): Promise<readonly TokenPrediction[]>;
|
|
39
|
+
}
|
|
40
|
+
export type NerEntityType = 'PERSON' | 'ORG' | 'LOCATION';
|
|
41
|
+
/** A merged entity span in NORMALIZED-text coordinates. */
|
|
42
|
+
export interface NerSpan {
|
|
43
|
+
readonly type: NerEntityType;
|
|
44
|
+
readonly start: number;
|
|
45
|
+
readonly end: number;
|
|
46
|
+
readonly text: string;
|
|
47
|
+
/** Minimum token score across the entity — the conservative aggregate. */
|
|
48
|
+
readonly score: number;
|
|
49
|
+
/**
|
|
50
|
+
* Stage 2b corroboration, when the gazetteer knows this name.
|
|
51
|
+
*
|
|
52
|
+
* Attached HERE rather than looked up in Stage 3 because SPEC places the
|
|
53
|
+
* gazetteers in Stage 2 — "checked in parallel with the model" — and
|
|
54
|
+
* because the sets are only meaningful for the types the model produces.
|
|
55
|
+
* See ner/stage2b.ts for what that placement was costing.
|
|
56
|
+
*
|
|
57
|
+
* Absent on a miss. "Not in the gazetteer" is not evidence against a name.
|
|
58
|
+
*/
|
|
59
|
+
readonly gazetteer?: GazetteerHit;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* What Stage 2 needs from whatever performs recognition.
|
|
63
|
+
*
|
|
64
|
+
* An interface rather than the concrete `NerEngine` because the engine may not
|
|
65
|
+
* be in the same PROCESS as the pipeline. The extension runs the model in an
|
|
66
|
+
* offscreen document - a content script cannot compile WebAssembly under the
|
|
67
|
+
* host page's policy - so its Stage 2 is a proxy that forwards `recognize`
|
|
68
|
+
* across a message port and returns the spans that come back.
|
|
69
|
+
*
|
|
70
|
+
* Declared here, next to the span it returns, so that `runStage2` and
|
|
71
|
+
* `detect` can name it without importing `engine.ts`. That matters: engine.ts
|
|
72
|
+
* pulls in Stage 2b and therefore the gazetteers, and a value import of it
|
|
73
|
+
* from the pipeline would link 3.4 MB of Bloom filters into every bundle that
|
|
74
|
+
* runs detection, including the one that has no model at all.
|
|
75
|
+
*/
|
|
76
|
+
export interface NerRecognizer {
|
|
77
|
+
/** Model identity, recorded on every candidate this produces. */
|
|
78
|
+
readonly id: string;
|
|
79
|
+
/** Pay initialization cost before first real use. */
|
|
80
|
+
warmup(): Promise<void>;
|
|
81
|
+
/** Spans in the given text's own coordinates. */
|
|
82
|
+
recognize(text: string): Promise<NerSpan[]>;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Stage 2 candidates share Stage 1's shape (SPEC: one candidate contract
|
|
86
|
+
* for the whole pipeline), differing only in the stage tag.
|
|
87
|
+
*/
|
|
88
|
+
export interface Stage2Candidate extends Omit<Stage1Candidate, 'stage'> {
|
|
89
|
+
readonly stage: 'stage2-ner';
|
|
90
|
+
/** Stage 2b corroboration, carried through to Stage 3's scorer. */
|
|
91
|
+
readonly gazetteer?: GazetteerHit;
|
|
92
|
+
}
|
|
93
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/ner/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAE1D,2EAA2E;AAC3E,MAAM,WAAW,eAAe;IAC9B,mDAAmD;IACnD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,0CAA0C;IAC1C,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB;;;;OAIG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AAED,kCAAkC;AAClC,MAAM,WAAW,eAAe;IAC9B,iFAAiF;IACjF,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB;;;;;OAKG;IACH,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,iEAAiE;IACjE,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,eAAe,EAAE,CAAC,CAAC;CAC7D;AAED,MAAM,MAAM,aAAa,GAAG,QAAQ,GAAG,KAAK,GAAG,UAAU,CAAC;AAE1D,2DAA2D;AAC3D,MAAM,WAAW,OAAO;IACtB,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;IAC7B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,0EAA0E;IAC1E,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB;;;;;;;;;OASG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,YAAY,CAAC;CACnC;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,WAAW,aAAa;IAC5B,iEAAiE;IACjE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,qDAAqD;IACrD,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACxB,iDAAiD;IACjD,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;CAC7C;AAED;;;GAGG;AACH,MAAM,WAAW,eAAgB,SAAQ,IAAI,CAAC,eAAe,EAAE,OAAO,CAAC;IACrE,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC;IAC7B,mEAAmE;IACnE,QAAQ,CAAC,SAAS,CAAC,EAAE,YAAY,CAAC;CACnC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stage 2 (multilingual NER) — shared types.
|
|
3
|
+
*
|
|
4
|
+
* The model runtime is INJECTED behind `TokenClassifier`, so the pure parts
|
|
5
|
+
* of Stage 2 (piece→character alignment, BIO decoding, chunking, timeout
|
|
6
|
+
* discipline, candidate shaping) are testable without a model and the
|
|
7
|
+
* engine stays environment-agnostic. The Transformers.js-backed classifier
|
|
8
|
+
* lives in `transformersClassifier.ts`, exported through its own package
|
|
9
|
+
* entry point so that consumers who never run NER never load the runtime.
|
|
10
|
+
*/
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/ner/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stage 0 normalization: the composed transform pipeline.
|
|
3
|
+
*
|
|
4
|
+
* Order (each step optional via NormalizationOptions, all on by default):
|
|
5
|
+
*
|
|
6
|
+
* 1. strip invisibles — zero-width & bidi controls are pure noise and
|
|
7
|
+
* interfere with everything downstream
|
|
8
|
+
* 2. NFKC (per grapheme) — compatibility folding with an exact map
|
|
9
|
+
* 3. selective homoglyph — fold ONLY script-anomalous characters
|
|
10
|
+
* folding (see homoglyphFold.ts for the full rationale)
|
|
11
|
+
* 3b. NFKC again, only when folding changed something: a folded character
|
|
12
|
+
* must compose with a following combining mark exactly as a native one
|
|
13
|
+
* would (e.g. Cyrillic а + U+0301 → folded "a" + U+0301 → "á"),
|
|
14
|
+
* otherwise normalizing already-normalized text would not be a no-op
|
|
15
|
+
* 4. whitespace/punct — exotic spaces, dashes, quotes → ASCII forms
|
|
16
|
+
*
|
|
17
|
+
* Each transform independently produces { text, map }; the final offset map
|
|
18
|
+
* is the COMPOSITION of the per-stage maps (see offsetMap.ts for the map
|
|
19
|
+
* format and its invariants). Composing small verified maps is far easier to
|
|
20
|
+
* get right than building one map through four simultaneous transforms.
|
|
21
|
+
*/
|
|
22
|
+
import type { NormalizationOptions, NormalizationResult } from './types.js';
|
|
23
|
+
export declare function normalize(text: string, options?: NormalizationOptions): NormalizationResult;
|
|
24
|
+
//# sourceMappingURL=normalization.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalization.d.ts","sourceRoot":"","sources":["../../src/normalization.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,OAAO,KAAK,EAAE,oBAAoB,EAAE,mBAAmB,EAAwB,MAAM,YAAY,CAAC;AAelG,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,oBAAoB,GAAG,mBAAmB,CAkF3F"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { composeMaps, identityMap, buildReverseMap, mapNormalizedSpan, } from './offsetMap.js';
|
|
2
|
+
import { detectScripts } from './scripts.js';
|
|
3
|
+
import { stripInvisibles } from './transforms/stripInvisibles.js';
|
|
4
|
+
import { nfkcByGrapheme } from './transforms/nfkc.js';
|
|
5
|
+
import { foldHomoglyphs } from './transforms/homoglyphFold.js';
|
|
6
|
+
import { normalizeWhitespacePunct } from './transforms/whitespacePunct.js';
|
|
7
|
+
import { foldDigits } from './transforms/foldDigits.js';
|
|
8
|
+
export function normalize(text, options) {
|
|
9
|
+
const opts = {
|
|
10
|
+
stripInvisibles: true,
|
|
11
|
+
nfkc: true,
|
|
12
|
+
homoglyphFold: true,
|
|
13
|
+
whitespacePunct: true,
|
|
14
|
+
foldDigits: true,
|
|
15
|
+
...options,
|
|
16
|
+
};
|
|
17
|
+
/** The text after the transforms applied so far. */
|
|
18
|
+
let current = text;
|
|
19
|
+
/**
|
|
20
|
+
* Composed map: current index → ORIGINAL index. null means "identity so
|
|
21
|
+
* far" — kept symbolic so untouched text (the common case) never pays for
|
|
22
|
+
* map allocation or composition.
|
|
23
|
+
*/
|
|
24
|
+
let cumulative = null;
|
|
25
|
+
const transformations = [];
|
|
26
|
+
const apply = (step) => {
|
|
27
|
+
const result = step(current);
|
|
28
|
+
if (result === null)
|
|
29
|
+
return false;
|
|
30
|
+
for (const change of result.changes) {
|
|
31
|
+
// The step reports ranges in ITS input's coordinates; map them back to
|
|
32
|
+
// original-text coordinates through the maps of the earlier steps.
|
|
33
|
+
// mapNormalizedSpan (not plain lookup) so a change inside an earlier
|
|
34
|
+
// expansion widens to the whole original cluster.
|
|
35
|
+
const span = cumulative
|
|
36
|
+
? mapNormalizedSpan(cumulative, change.start, change.end)
|
|
37
|
+
: { start: change.start, end: change.end };
|
|
38
|
+
transformations.push({
|
|
39
|
+
kind: change.kind,
|
|
40
|
+
originalStart: span.start,
|
|
41
|
+
originalEnd: span.end,
|
|
42
|
+
original: text.slice(span.start, span.end),
|
|
43
|
+
replacement: change.after,
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
cumulative = cumulative ? composeMaps(cumulative, result.map) : result.map;
|
|
47
|
+
current = result.text;
|
|
48
|
+
return true;
|
|
49
|
+
};
|
|
50
|
+
// Per-cluster NFKC must run to a FIXPOINT: one pass's output can contain
|
|
51
|
+
// clusters that only became composable by being placed next to each other
|
|
52
|
+
// (the canonical case is Hangul compatibility jamo — ㅍ and ㅓ are separate
|
|
53
|
+
// clusters, normalize to the conjoining jamo ᄑ + ᅥ, and only THOSE form a
|
|
54
|
+
// single cluster that composes to 퍼 on the next look). One extra pass
|
|
55
|
+
// settles it in practice; the cap is a defensive bound, and the fuzz suite
|
|
56
|
+
// asserts both termination and idempotency.
|
|
57
|
+
const applyNfkcToFixpoint = () => {
|
|
58
|
+
for (let i = 0; i < 8 && apply(nfkcByGrapheme); i++) {
|
|
59
|
+
// apply() advanced the pipeline; loop until it reports no change.
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
if (opts.stripInvisibles)
|
|
63
|
+
apply(stripInvisibles);
|
|
64
|
+
if (opts.nfkc)
|
|
65
|
+
applyNfkcToFixpoint();
|
|
66
|
+
if (opts.homoglyphFold) {
|
|
67
|
+
const folded = apply(foldHomoglyphs);
|
|
68
|
+
// 3b — see the file header. Only needed when a fold actually happened,
|
|
69
|
+
// and only meaningful when the NFKC step is enabled at all.
|
|
70
|
+
if (folded && opts.nfkc)
|
|
71
|
+
applyNfkcToFixpoint();
|
|
72
|
+
}
|
|
73
|
+
if (opts.whitespacePunct)
|
|
74
|
+
apply(normalizeWhitespacePunct);
|
|
75
|
+
// Last, and after homoglyph folding on purpose: folding digits changes a
|
|
76
|
+
// token's script census, and doing it earlier would alter the
|
|
77
|
+
// dominant-script decision homoglyph folding depends on. ASCII digits are
|
|
78
|
+
// NFKC-stable, so no further normalization pass is owed.
|
|
79
|
+
if (opts.foldDigits)
|
|
80
|
+
apply(foldDigits);
|
|
81
|
+
const offsetMap = cumulative ?? identityMap(text.length);
|
|
82
|
+
return {
|
|
83
|
+
normalizedText: current,
|
|
84
|
+
offsetMap,
|
|
85
|
+
reverseMap: buildReverseMap(offsetMap, text.length),
|
|
86
|
+
scripts: detectScripts(current),
|
|
87
|
+
transformations,
|
|
88
|
+
originalLength: text.length,
|
|
89
|
+
normalizedLength: current.length,
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=normalization.js.map
|