Files
SnowLuma/.pnpm-store/v11/files/47/c2f8163ab54d5af7c6c8b098268a955a48c54374535d97422b2e7da379d26539f085cb2eafcb2d1fc782bdd2c540a50d7ba6acb8b65a3b7aec36953e360573
T
TanTan 2a69b23b47
Dev Build / cleanup (push) Waiting to run
Dev Build / typecheck (push) Waiting to run
docs: 仓库链接指向本镜像仓库
2026-11-13 09:27:07 +08:00

31 lines
838 B
Plaintext

import { REFERENCE_YEAR, MIN_YEAR_SPACE } from '../../data/const.mjs';
var regexMatcher = ({
regexName,
regexMatch,
token
}) => {
const charClassBases = {
alphaLower: 26,
alphaUpper: 26,
alpha: 52,
alphanumeric: 62,
digits: 10,
symbols: 33
};
if (regexName in charClassBases) {
return charClassBases[regexName] ** token.length;
}
// TODO add more regex types for example special dates like 09.11
switch (regexName) {
case 'recentYear':
// conservative estimate of year space: num years from REFERENCE_YEAR.
// if year is close to REFERENCE_YEAR, estimate a year space of MIN_YEAR_SPACE.
return Math.max(Math.abs(parseInt(regexMatch[0], 10) - REFERENCE_YEAR), MIN_YEAR_SPACE);
}
return 0;
};
export { regexMatcher as default };
//# sourceMappingURL=scoring.mjs.map