diff --git a/JavaScript/.babelrc b/JavaScript/.babelrc deleted file mode 100644 index 3d6405f288..0000000000 --- a/JavaScript/.babelrc +++ /dev/null @@ -1,13 +0,0 @@ -{ - "presets": [ - [ - "@ava/stage-4", - { - "modules": false - } - ] - ], - "plugins": [ - "external-helpers" - ] -} \ No newline at end of file diff --git a/JavaScript/.eslintrc.js b/JavaScript/.eslintrc.js deleted file mode 100644 index c3b936988c..0000000000 --- a/JavaScript/.eslintrc.js +++ /dev/null @@ -1,35 +0,0 @@ -module.exports = { - parser: '@typescript-eslint/parser', // Specifies the ESLint parser - plugins: [ - '@typescript-eslint', - 'only-warn' - ], - extends: [ - 'plugin:@typescript-eslint/recommended', - 'prettier', - 'prettier/@typescript-eslint' - ], - parserOptions: { - ecmaVersion: 2018, // Allows for the parsing of modern ECMAScript features - sourceType: 'module', // Allows for the use of imports - ecmaFeatures: { - impliedStrict: true - }, - }, - rules: { - '@typescript-eslint/explicit-member-accessibility': 'off', - '@typescript-eslint/no-namespace': 'off', - '@typescript-eslint/interface-name-prefix': 'off', - '@typescript-eslint/no-object-literal-type-assertion': 'off', - '@typescript-eslint/explicit-function-return-type': ["error", {allowExpressions: true}], - 'eqeqeq': ["error", "smart"], - 'radix': 'error', - 'no-var': "error", - "one-var": ["error", { var: "never", let: "never", const: "never" }], - 'curly': ["error"], - "spaced-comment": ["warn", "always"], - 'semi': 'error', - 'brace-style': ["error", "stroustrup"], - 'indent': ['error', 4] - }, -}; diff --git a/JavaScript/.gitignore b/JavaScript/.gitignore deleted file mode 100644 index d9741d5385..0000000000 --- a/JavaScript/.gitignore +++ /dev/null @@ -1,13 +0,0 @@ -node_modules -coverage -.nyc_output -.DS_Store -*.log -.idea -dist -compiled -.awcache -!.vscode/ -.vscode/* -!.vscode/extensions.json -!.vscode/settings.json \ No newline at end of file diff --git a/JavaScript/.vscode/extensions.json b/JavaScript/.vscode/extensions.json deleted file mode 100644 index 7d0473afa7..0000000000 --- a/JavaScript/.vscode/extensions.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "recommendations": [ - "dbaeumer.vscode-eslint", - ] -} \ No newline at end of file diff --git a/JavaScript/.vscode/launch.json b/JavaScript/.vscode/launch.json deleted file mode 100644 index 4216ac77b3..0000000000 --- a/JavaScript/.vscode/launch.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "version": "0.2.0", - "configurations": [ - { - "type": "node", - "request": "launch", - "name": "Debug Tests", - "program": "${workspaceRoot}/node_modules/ava/profile.js", - "preLaunchTask": "tsc", - "args": [ - "test/index.js" - ], - "console": "internalConsole" - } - ] -} \ No newline at end of file diff --git a/JavaScript/.vscode/settings.json b/JavaScript/.vscode/settings.json deleted file mode 100644 index c3e6844137..0000000000 --- a/JavaScript/.vscode/settings.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "eslint.validate": [ - "javascript", - "javascriptreact", - "typescript", - "typescriptreact" - ] -} \ No newline at end of file diff --git a/JavaScript/.vscode/tasks.json b/JavaScript/.vscode/tasks.json deleted file mode 100644 index be8590f937..0000000000 --- a/JavaScript/.vscode/tasks.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "version": "2.0.0", - - // The command is tsc. Assumes that tsc has been installed using npm install -g typescript - "command": "tsc", - - // use the standard tsc problem matcher to find compile problems - // in the output. - "problemMatcher": "$tsc", - "tasks": [ - { - "label": "tsc", - "type": "shell", - "command": "tsc", - "problemMatcher": "$tsc", - "group": "build" - } - ] -} diff --git a/JavaScript/README.md b/JavaScript/README.md deleted file mode 100644 index cf3e33f843..0000000000 --- a/JavaScript/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# Microsoft.Recognizers.Text for JavaScript - -Please check the [main README](https://github.com/Microsoft/Recognizers-Text/tree/master/JavaScript/packages/recognizers-text-suite) for more details. \ No newline at end of file diff --git a/JavaScript/build.ci.cmd b/JavaScript/build.ci.cmd deleted file mode 100644 index 85b3bcf6ae..0000000000 --- a/JavaScript/build.ci.cmd +++ /dev/null @@ -1,33 +0,0 @@ -ECHO ==============================JAVASCRIPT BUILD START============================== - -ECHO. -ECHO # Building Javascript platform - -REM Check Node/NPM installation -WHERE /q node -IF ERRORLEVEL 1 ( - ECHO Node.js executable not found. Please install it from https://nodejs.org/ - EXIT /B -) -WHERE /q npm -IF ERRORLEVEL 1 ( - ECHO NPM executable not found. Please install it from https://nodejs.org/ - EXIT /B -) - -REM Dependencies -ECHO. -ECHO # Installing dependencies -CALL npm i - -REM Build Packages -ECHO. -ECHO # Building - npm run build -CALL npm run build - -IF %ERRORLEVEL% NEQ 0 ( - ECHO # Failed to build JavaScript Project. - EXIT /b %ERRORLEVEL% -) - -ECHO ============================== JAVASCRIPT BUILD END ============================== \ No newline at end of file diff --git a/JavaScript/build.cmd b/JavaScript/build.cmd deleted file mode 100644 index 9c922badb3..0000000000 --- a/JavaScript/build.cmd +++ /dev/null @@ -1,5 +0,0 @@ -@ECHO off - -REM This is only used for local build. It executes the same build and test scripts than the CI server. - -build.ci.cmd & tests.ci.cmd \ No newline at end of file diff --git a/JavaScript/build.sh b/JavaScript/build.sh deleted file mode 100755 index 1f6fb2e1ca..0000000000 --- a/JavaScript/build.sh +++ /dev/null @@ -1,10 +0,0 @@ -echo // Building Javacript platform - -echo // Installing dependencies -npm i - -echo // Building - npm run build -npm run build - -echo // Running tests - npm run test -npm run test \ No newline at end of file diff --git a/JavaScript/lerna.json b/JavaScript/lerna.json deleted file mode 100644 index 0cad591f5e..0000000000 --- a/JavaScript/lerna.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "lerna": "2.11.0", - "packages": [ - "packages/recognizers-*", - "packages/datatypes-date-time" - ], - "version": "1.3.0" -} diff --git a/JavaScript/package-lock.json b/JavaScript/package-lock.json deleted file mode 100644 index 5915178d5c..0000000000 --- a/JavaScript/package-lock.json +++ /dev/null @@ -1,10918 +0,0 @@ -{ - "requires": true, - "lockfileVersion": 1, - "dependencies": { - "@ava/babel-plugin-throws-helper": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/@ava/babel-plugin-throws-helper/-/babel-plugin-throws-helper-3.0.0.tgz", - "integrity": "sha512-mN9UolOs4WX09QkheU1ELkVy2WPnwonlO3XMdN8JF8fQqRVgVTR21xDbvEOUsbwz6Zwjq7ji9yzyjuXqDPalxg==" - }, - "@ava/babel-preset-stage-4": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/@ava/babel-preset-stage-4/-/babel-preset-stage-4-3.0.0.tgz", - "integrity": "sha512-uI5UBx++UsckkfnbF0HH6jvTIvM4r/Kxt1ROO2YXKu5H15sScAtxUIAHiUVbPIw24zPqz/PlF3xxlIDuyFzlQw==", - "requires": { - "@babel/plugin-proposal-async-generator-functions": "^7.2.0", - "@babel/plugin-proposal-optional-catch-binding": "^7.2.0", - "@babel/plugin-transform-dotall-regex": "^7.4.3", - "@babel/plugin-transform-modules-commonjs": "^7.4.3" - } - }, - "@ava/babel-preset-transform-test-files": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/@ava/babel-preset-transform-test-files/-/babel-preset-transform-test-files-5.0.0.tgz", - "integrity": "sha512-rqgyQwkT0+j2JzYP51dOv80u33rzAvjBtXRzUON+7+6u26mjoudRXci2+1s18rat8r4uOlZfbzm114YS6pwmYw==", - "requires": { - "@ava/babel-plugin-throws-helper": "^3.0.0", - "babel-plugin-espower": "^3.0.1" - } - }, - "@babel/code-frame": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.0.0.tgz", - "integrity": "sha512-OfC2uemaknXr87bdLUkWog7nYuliM9Ij5HUcajsVcMCpQrcLmtxRbVFTIqmcSkSeYRBFBRxs2FiUqFJDLdiebA==", - "requires": { - "@babel/highlight": "^7.0.0" - } - }, - "@babel/core": { - "version": "7.5.4", - "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.5.4.tgz", - "integrity": "sha512-+DaeBEpYq6b2+ZmHx3tHspC+ZRflrvLqwfv8E3hNr5LVQoyBnL8RPKSBCg+rK2W2My9PWlujBiqd0ZPsR9Q6zQ==", - "requires": { - "@babel/code-frame": "^7.0.0", - "@babel/generator": "^7.5.0", - "@babel/helpers": "^7.5.4", - "@babel/parser": "^7.5.0", - "@babel/template": "^7.4.4", - "@babel/traverse": "^7.5.0", - "@babel/types": "^7.5.0", - "convert-source-map": "^1.1.0", - "debug": "^4.1.0", - "json5": "^2.1.0", - "lodash": "^4.17.11", - "resolve": "^1.3.2", - "semver": "^5.4.1", - "source-map": "^0.5.0" - }, - "dependencies": { - "@babel/generator": { - "version": "7.5.0", - "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.5.0.tgz", - "integrity": "sha512-1TTVrt7J9rcG5PMjvO7VEG3FrEoEJNHxumRq66GemPmzboLWtIjjcJgk8rokuAS7IiRSpgVSu5Vb9lc99iJkOA==", - "requires": { - "@babel/types": "^7.5.0", - "jsesc": "^2.5.1", - "lodash": "^4.17.11", - "source-map": "^0.5.0", - "trim-right": "^1.0.1" - } - }, - "@babel/helper-split-export-declaration": { - "version": "7.4.4", - "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.4.4.tgz", - "integrity": "sha512-Ro/XkzLf3JFITkW6b+hNxzZ1n5OQ80NvIUdmHspih1XAhtN3vPTuUFT4eQnela+2MaZ5ulH+iyP513KJrxbN7Q==", - "requires": { - "@babel/types": "^7.4.4" - } - }, - "@babel/parser": { - "version": "7.5.0", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.5.0.tgz", - "integrity": "sha512-I5nW8AhGpOXGCCNYGc+p7ExQIBxRFnS2fd/d862bNOKvmoEPjYPcfIjsfdy0ujagYOIYPczKgD9l3FsgTkAzKA==" - }, - "@babel/template": { - "version": "7.4.4", - "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.4.4.tgz", - "integrity": "sha512-CiGzLN9KgAvgZsnivND7rkA+AeJ9JB0ciPOD4U59GKbQP2iQl+olF1l76kJOupqidozfZ32ghwBEJDhnk9MEcw==", - "requires": { - "@babel/code-frame": "^7.0.0", - "@babel/parser": "^7.4.4", - "@babel/types": "^7.4.4" - } - }, - "@babel/traverse": { - "version": "7.5.0", - "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.5.0.tgz", - "integrity": "sha512-SnA9aLbyOCcnnbQEGwdfBggnc142h/rbqqsXcaATj2hZcegCl903pUD/lfpsNBlBSuWow/YDfRyJuWi2EPR5cg==", - "requires": { - "@babel/code-frame": "^7.0.0", - "@babel/generator": "^7.5.0", - "@babel/helper-function-name": "^7.1.0", - "@babel/helper-split-export-declaration": "^7.4.4", - "@babel/parser": "^7.5.0", - "@babel/types": "^7.5.0", - "debug": "^4.1.0", - "globals": "^11.1.0", - "lodash": "^4.17.11" - } - }, - "@babel/types": { - "version": "7.5.0", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.5.0.tgz", - "integrity": "sha512-UFpDVqRABKsW01bvw7/wSUe56uy6RXM5+VJibVVAybDGxEW25jdwiFJEf7ASvSaC7sN7rbE/l3cLp2izav+CtQ==", - "requires": { - "esutils": "^2.0.2", - "lodash": "^4.17.11", - "to-fast-properties": "^2.0.0" - } - }, - "debug": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", - "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", - "requires": { - "ms": "^2.1.1" - } - }, - "globals": { - "version": "11.12.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz", - "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==" - }, - "jsesc": { - "version": "2.5.2", - "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz", - "integrity": "sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA==" - }, - "json5": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/json5/-/json5-2.1.0.tgz", - "integrity": "sha512-8Mh9h6xViijj36g7Dxi+Y4S6hNGV96vcJZr/SrlHh1LR/pEn/8j/+qIBbs44YKl69Lrfctp4QD+AdWLTMqEZAQ==", - "requires": { - "minimist": "^1.2.0" - } - }, - "minimist": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", - "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" - }, - "to-fast-properties": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz", - "integrity": "sha1-3F5pjL0HkmW8c+A3doGk5Og/YW4=" - } - } - }, - "@babel/generator": { - "version": "7.3.3", - "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.3.3.tgz", - "integrity": "sha512-aEADYwRRZjJyMnKN7llGIlircxTCofm3dtV5pmY6ob18MSIuipHpA2yZWkPlycwu5HJcx/pADS3zssd8eY7/6A==", - "requires": { - "@babel/types": "^7.3.3", - "jsesc": "^2.5.1", - "lodash": "^4.17.11", - "source-map": "^0.5.0", - "trim-right": "^1.0.1" - }, - "dependencies": { - "jsesc": { - "version": "2.5.2", - "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz", - "integrity": "sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA==" - }, - "lodash": { - "version": "4.17.11", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz", - "integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==" - } - } - }, - "@babel/helper-annotate-as-pure": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/@babel/helper-annotate-as-pure/-/helper-annotate-as-pure-7.0.0.tgz", - "integrity": "sha512-3UYcJUj9kvSLbLbUIfQTqzcy5VX7GRZ/CCDrnOaZorFFM01aXp1+GJwuFGV4NDDoAS+mOUyHcO6UD/RfqOks3Q==", - "requires": { - "@babel/types": "^7.0.0" - } - }, - "@babel/helper-function-name": { - "version": "7.1.0", - "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.1.0.tgz", - "integrity": "sha512-A95XEoCpb3TO+KZzJ4S/5uW5fNe26DjBGqf1o9ucyLyCmi1dXq/B3c8iaWTfBk3VvetUxl16e8tIrd5teOCfGw==", - "requires": { - "@babel/helper-get-function-arity": "^7.0.0", - "@babel/template": "^7.1.0", - "@babel/types": "^7.0.0" - } - }, - "@babel/helper-get-function-arity": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/@babel/helper-get-function-arity/-/helper-get-function-arity-7.0.0.tgz", - "integrity": "sha512-r2DbJeg4svYvt3HOS74U4eWKsUAMRH01Z1ds1zx8KNTPtpTL5JAsdFv8BNyOpVqdFhHkkRDIg5B4AsxmkjAlmQ==", - "requires": { - "@babel/types": "^7.0.0" - } - }, - "@babel/helper-module-imports": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.0.0.tgz", - "integrity": "sha512-aP/hlLq01DWNEiDg4Jn23i+CXxW/owM4WpDLFUbpjxe4NS3BhLVZQ5i7E0ZrxuQ/vwekIeciyamgB1UIYxxM6A==", - "requires": { - "@babel/types": "^7.0.0" - } - }, - "@babel/helper-module-transforms": { - "version": "7.4.4", - "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.4.4.tgz", - "integrity": "sha512-3Z1yp8TVQf+B4ynN7WoHPKS8EkdTbgAEy0nU0rs/1Kw4pDgmvYH3rz3aI11KgxKCba2cn7N+tqzV1mY2HMN96w==", - "requires": { - "@babel/helper-module-imports": "^7.0.0", - "@babel/helper-simple-access": "^7.1.0", - "@babel/helper-split-export-declaration": "^7.4.4", - "@babel/template": "^7.4.4", - "@babel/types": "^7.4.4", - "lodash": "^4.17.11" - }, - "dependencies": { - "@babel/helper-split-export-declaration": { - "version": "7.4.4", - "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.4.4.tgz", - "integrity": "sha512-Ro/XkzLf3JFITkW6b+hNxzZ1n5OQ80NvIUdmHspih1XAhtN3vPTuUFT4eQnela+2MaZ5ulH+iyP513KJrxbN7Q==", - "requires": { - "@babel/types": "^7.4.4" - } - }, - "@babel/parser": { - "version": "7.5.0", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.5.0.tgz", - "integrity": "sha512-I5nW8AhGpOXGCCNYGc+p7ExQIBxRFnS2fd/d862bNOKvmoEPjYPcfIjsfdy0ujagYOIYPczKgD9l3FsgTkAzKA==" - }, - "@babel/template": { - "version": "7.4.4", - "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.4.4.tgz", - "integrity": "sha512-CiGzLN9KgAvgZsnivND7rkA+AeJ9JB0ciPOD4U59GKbQP2iQl+olF1l76kJOupqidozfZ32ghwBEJDhnk9MEcw==", - "requires": { - "@babel/code-frame": "^7.0.0", - "@babel/parser": "^7.4.4", - "@babel/types": "^7.4.4" - } - }, - "@babel/types": { - "version": "7.5.0", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.5.0.tgz", - "integrity": "sha512-UFpDVqRABKsW01bvw7/wSUe56uy6RXM5+VJibVVAybDGxEW25jdwiFJEf7ASvSaC7sN7rbE/l3cLp2izav+CtQ==", - "requires": { - "esutils": "^2.0.2", - "lodash": "^4.17.11", - "to-fast-properties": "^2.0.0" - } - }, - "to-fast-properties": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz", - "integrity": "sha1-3F5pjL0HkmW8c+A3doGk5Og/YW4=" - } - } - }, - "@babel/helper-plugin-utils": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.0.0.tgz", - "integrity": "sha512-CYAOUCARwExnEixLdB6sDm2dIJ/YgEAKDM1MOeMeZu9Ld/bDgVo8aiWrXwcY7OBh+1Ea2uUcVRcxKk0GJvW7QA==" - }, - "@babel/helper-regex": { - "version": "7.4.4", - "resolved": "https://registry.npmjs.org/@babel/helper-regex/-/helper-regex-7.4.4.tgz", - "integrity": "sha512-Y5nuB/kESmR3tKjU8Nkn1wMGEx1tjJX076HBMeL3XLQCu6vA/YRzuTW0bbb+qRnXvQGn+d6Rx953yffl8vEy7Q==", - "requires": { - "lodash": "^4.17.11" - } - }, - "@babel/helper-remap-async-to-generator": { - "version": "7.1.0", - "resolved": "https://registry.npmjs.org/@babel/helper-remap-async-to-generator/-/helper-remap-async-to-generator-7.1.0.tgz", - "integrity": "sha512-3fOK0L+Fdlg8S5al8u/hWE6vhufGSn0bN09xm2LXMy//REAF8kDCrYoOBKYmA8m5Nom+sV9LyLCwrFynA8/slg==", - "requires": { - "@babel/helper-annotate-as-pure": "^7.0.0", - "@babel/helper-wrap-function": "^7.1.0", - "@babel/template": "^7.1.0", - "@babel/traverse": "^7.1.0", - "@babel/types": "^7.0.0" - } - }, - "@babel/helper-simple-access": { - "version": "7.1.0", - "resolved": "https://registry.npmjs.org/@babel/helper-simple-access/-/helper-simple-access-7.1.0.tgz", - "integrity": "sha512-Vk+78hNjRbsiu49zAPALxTb+JUQCz1aolpd8osOF16BGnLtseD21nbHgLPGUwrXEurZgiCOUmvs3ExTu4F5x6w==", - "requires": { - "@babel/template": "^7.1.0", - "@babel/types": "^7.0.0" - } - }, - "@babel/helper-split-export-declaration": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.0.0.tgz", - "integrity": "sha512-MXkOJqva62dfC0w85mEf/LucPPS/1+04nmmRMPEBUB++hiiThQ2zPtX/mEWQ3mtzCEjIJvPY8nuwxXtQeQwUag==", - "requires": { - "@babel/types": "^7.0.0" - } - }, - "@babel/helper-wrap-function": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/@babel/helper-wrap-function/-/helper-wrap-function-7.2.0.tgz", - "integrity": "sha512-o9fP1BZLLSrYlxYEYyl2aS+Flun5gtjTIG8iln+XuEzQTs0PLagAGSXUcqruJwD5fM48jzIEggCKpIfWTcR7pQ==", - "requires": { - "@babel/helper-function-name": "^7.1.0", - "@babel/template": "^7.1.0", - "@babel/traverse": "^7.1.0", - "@babel/types": "^7.2.0" - } - }, - "@babel/helpers": { - "version": "7.5.4", - "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.5.4.tgz", - "integrity": "sha512-6LJ6xwUEJP51w0sIgKyfvFMJvIb9mWAfohJp0+m6eHJigkFdcH8duZ1sfhn0ltJRzwUIT/yqqhdSfRpCpL7oow==", - "requires": { - "@babel/template": "^7.4.4", - "@babel/traverse": "^7.5.0", - "@babel/types": "^7.5.0" - }, - "dependencies": { - "@babel/generator": { - "version": "7.5.0", - "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.5.0.tgz", - "integrity": "sha512-1TTVrt7J9rcG5PMjvO7VEG3FrEoEJNHxumRq66GemPmzboLWtIjjcJgk8rokuAS7IiRSpgVSu5Vb9lc99iJkOA==", - "requires": { - "@babel/types": "^7.5.0", - "jsesc": "^2.5.1", - "lodash": "^4.17.11", - "source-map": "^0.5.0", - "trim-right": "^1.0.1" - } - }, - "@babel/helper-split-export-declaration": { - "version": "7.4.4", - "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.4.4.tgz", - "integrity": "sha512-Ro/XkzLf3JFITkW6b+hNxzZ1n5OQ80NvIUdmHspih1XAhtN3vPTuUFT4eQnela+2MaZ5ulH+iyP513KJrxbN7Q==", - "requires": { - "@babel/types": "^7.4.4" - } - }, - "@babel/parser": { - "version": "7.5.0", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.5.0.tgz", - "integrity": "sha512-I5nW8AhGpOXGCCNYGc+p7ExQIBxRFnS2fd/d862bNOKvmoEPjYPcfIjsfdy0ujagYOIYPczKgD9l3FsgTkAzKA==" - }, - "@babel/template": { - "version": "7.4.4", - "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.4.4.tgz", - "integrity": "sha512-CiGzLN9KgAvgZsnivND7rkA+AeJ9JB0ciPOD4U59GKbQP2iQl+olF1l76kJOupqidozfZ32ghwBEJDhnk9MEcw==", - "requires": { - "@babel/code-frame": "^7.0.0", - "@babel/parser": "^7.4.4", - "@babel/types": "^7.4.4" - } - }, - "@babel/traverse": { - "version": "7.5.0", - "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.5.0.tgz", - "integrity": "sha512-SnA9aLbyOCcnnbQEGwdfBggnc142h/rbqqsXcaATj2hZcegCl903pUD/lfpsNBlBSuWow/YDfRyJuWi2EPR5cg==", - "requires": { - "@babel/code-frame": "^7.0.0", - "@babel/generator": "^7.5.0", - "@babel/helper-function-name": "^7.1.0", - "@babel/helper-split-export-declaration": "^7.4.4", - "@babel/parser": "^7.5.0", - "@babel/types": "^7.5.0", - "debug": "^4.1.0", - "globals": "^11.1.0", - "lodash": "^4.17.11" - } - }, - "@babel/types": { - "version": "7.5.0", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.5.0.tgz", - "integrity": "sha512-UFpDVqRABKsW01bvw7/wSUe56uy6RXM5+VJibVVAybDGxEW25jdwiFJEf7ASvSaC7sN7rbE/l3cLp2izav+CtQ==", - "requires": { - "esutils": "^2.0.2", - "lodash": "^4.17.11", - "to-fast-properties": "^2.0.0" - } - }, - "debug": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", - "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", - "requires": { - "ms": "^2.1.1" - } - }, - "globals": { - "version": "11.12.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz", - "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==" - }, - "jsesc": { - "version": "2.5.2", - "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz", - "integrity": "sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA==" - }, - "to-fast-properties": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz", - "integrity": "sha1-3F5pjL0HkmW8c+A3doGk5Og/YW4=" - } - } - }, - "@babel/highlight": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.0.0.tgz", - "integrity": "sha512-UFMC4ZeFC48Tpvj7C8UgLvtkaUuovQX+5xNWrsIoMG8o2z+XFKjKaN9iVmS84dPwVN00W4wPmqvYoZF3EGAsfw==", - "requires": { - "chalk": "^2.0.0", - "esutils": "^2.0.2", - "js-tokens": "^4.0.0" - }, - "dependencies": { - "js-tokens": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", - "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==" - } - } - }, - "@babel/parser": { - "version": "7.3.3", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.3.3.tgz", - "integrity": "sha512-xsH1CJoln2r74hR+y7cg2B5JCPaTh+Hd+EbBRk9nWGSNspuo6krjhX0Om6RnRQuIvFq8wVXCLKH3kwKDYhanSg==" - }, - "@babel/plugin-proposal-async-generator-functions": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-async-generator-functions/-/plugin-proposal-async-generator-functions-7.2.0.tgz", - "integrity": "sha512-+Dfo/SCQqrwx48ptLVGLdE39YtWRuKc/Y9I5Fy0P1DDBB9lsAHpjcEJQt+4IifuSOSTLBKJObJqMvaO1pIE8LQ==", - "requires": { - "@babel/helper-plugin-utils": "^7.0.0", - "@babel/helper-remap-async-to-generator": "^7.1.0", - "@babel/plugin-syntax-async-generators": "^7.2.0" - } - }, - "@babel/plugin-proposal-optional-catch-binding": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-optional-catch-binding/-/plugin-proposal-optional-catch-binding-7.2.0.tgz", - "integrity": "sha512-mgYj3jCcxug6KUcX4OBoOJz3CMrwRfQELPQ5560F70YQUBZB7uac9fqaWamKR1iWUzGiK2t0ygzjTScZnVz75g==", - "requires": { - "@babel/helper-plugin-utils": "^7.0.0", - "@babel/plugin-syntax-optional-catch-binding": "^7.2.0" - } - }, - "@babel/plugin-syntax-async-generators": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-async-generators/-/plugin-syntax-async-generators-7.2.0.tgz", - "integrity": "sha512-1ZrIRBv2t0GSlcwVoQ6VgSLpLgiN/FVQUzt9znxo7v2Ov4jJrs8RY8tv0wvDmFN3qIdMKWrmMMW6yZ0G19MfGg==", - "requires": { - "@babel/helper-plugin-utils": "^7.0.0" - } - }, - "@babel/plugin-syntax-object-rest-spread": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-object-rest-spread/-/plugin-syntax-object-rest-spread-7.2.0.tgz", - "integrity": "sha512-t0JKGgqk2We+9may3t0xDdmneaXmyxq0xieYcKHxIsrJO64n1OiMWNUtc5gQK1PA0NpdCRrtZp4z+IUaKugrSA==", - "requires": { - "@babel/helper-plugin-utils": "^7.0.0" - } - }, - "@babel/plugin-syntax-optional-catch-binding": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-optional-catch-binding/-/plugin-syntax-optional-catch-binding-7.2.0.tgz", - "integrity": "sha512-bDe4xKNhb0LI7IvZHiA13kff0KEfaGX/Hv4lMA9+7TEc63hMNvfKo6ZFpXhKuEp+II/q35Gc4NoMeDZyaUbj9w==", - "requires": { - "@babel/helper-plugin-utils": "^7.0.0" - } - }, - "@babel/plugin-transform-dotall-regex": { - "version": "7.4.4", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-dotall-regex/-/plugin-transform-dotall-regex-7.4.4.tgz", - "integrity": "sha512-P05YEhRc2h53lZDjRPk/OektxCVevFzZs2Gfjd545Wde3k+yFDbXORgl2e0xpbq8mLcKJ7Idss4fAg0zORN/zg==", - "requires": { - "@babel/helper-plugin-utils": "^7.0.0", - "@babel/helper-regex": "^7.4.4", - "regexpu-core": "^4.5.4" - }, - "dependencies": { - "regexpu-core": { - "version": "4.5.4", - "resolved": "https://registry.npmjs.org/regexpu-core/-/regexpu-core-4.5.4.tgz", - "integrity": "sha512-BtizvGtFQKGPUcTy56o3nk1bGRp4SZOTYrDtGNlqCQufptV5IkkLN6Emw+yunAJjzf+C9FQFtvq7IoA3+oMYHQ==", - "requires": { - "regenerate": "^1.4.0", - "regenerate-unicode-properties": "^8.0.2", - "regjsgen": "^0.5.0", - "regjsparser": "^0.6.0", - "unicode-match-property-ecmascript": "^1.0.4", - "unicode-match-property-value-ecmascript": "^1.1.0" - } - }, - "regjsgen": { - "version": "0.5.0", - "resolved": "https://registry.npmjs.org/regjsgen/-/regjsgen-0.5.0.tgz", - "integrity": "sha512-RnIrLhrXCX5ow/E5/Mh2O4e/oa1/jW0eaBKTSy3LaCj+M3Bqvm97GWDp2yUtzIs4LEn65zR2yiYGFqb2ApnzDA==" - }, - "regjsparser": { - "version": "0.6.0", - "resolved": "https://registry.npmjs.org/regjsparser/-/regjsparser-0.6.0.tgz", - "integrity": "sha512-RQ7YyokLiQBomUJuUG8iGVvkgOLxwyZM8k6d3q5SAXpg4r5TZJZigKFvC6PpD+qQ98bCDC5YelPeA3EucDoNeQ==", - "requires": { - "jsesc": "~0.5.0" - } - } - } - }, - "@babel/plugin-transform-modules-commonjs": { - "version": "7.5.0", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-commonjs/-/plugin-transform-modules-commonjs-7.5.0.tgz", - "integrity": "sha512-xmHq0B+ytyrWJvQTc5OWAC4ii6Dhr0s22STOoydokG51JjWhyYo5mRPXoi+ZmtHQhZZwuXNN+GG5jy5UZZJxIQ==", - "requires": { - "@babel/helper-module-transforms": "^7.4.4", - "@babel/helper-plugin-utils": "^7.0.0", - "@babel/helper-simple-access": "^7.1.0", - "babel-plugin-dynamic-import-node": "^2.3.0" - } - }, - "@babel/template": { - "version": "7.2.2", - "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.2.2.tgz", - "integrity": "sha512-zRL0IMM02AUDwghf5LMSSDEz7sBCO2YnNmpg3uWTZj/v1rcG2BmQUvaGU8GhU8BvfMh1k2KIAYZ7Ji9KXPUg7g==", - "requires": { - "@babel/code-frame": "^7.0.0", - "@babel/parser": "^7.2.2", - "@babel/types": "^7.2.2" - } - }, - "@babel/traverse": { - "version": "7.2.3", - "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.2.3.tgz", - "integrity": "sha512-Z31oUD/fJvEWVR0lNZtfgvVt512ForCTNKYcJBGbPb1QZfve4WGH8Wsy7+Mev33/45fhP/hwQtvgusNdcCMgSw==", - "requires": { - "@babel/code-frame": "^7.0.0", - "@babel/generator": "^7.2.2", - "@babel/helper-function-name": "^7.1.0", - "@babel/helper-split-export-declaration": "^7.0.0", - "@babel/parser": "^7.2.3", - "@babel/types": "^7.2.2", - "debug": "^4.1.0", - "globals": "^11.1.0", - "lodash": "^4.17.10" - }, - "dependencies": { - "debug": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", - "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", - "requires": { - "ms": "^2.1.1" - } - }, - "globals": { - "version": "11.11.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-11.11.0.tgz", - "integrity": "sha512-WHq43gS+6ufNOEqlrDBxVEbb8ntfXrfAUU2ZOpCxrBdGKW3gyv8mCxAfIBD0DroPKGrJ2eSsXsLtY9MPntsyTw==" - } - } - }, - "@babel/types": { - "version": "7.3.3", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.3.3.tgz", - "integrity": "sha512-2tACZ80Wg09UnPg5uGAOUvvInaqLk3l/IAhQzlxLQOIXacr6bMsra5SH6AWw/hIDRCSbCdHP2KzSOD+cT7TzMQ==", - "requires": { - "esutils": "^2.0.2", - "lodash": "^4.17.11", - "to-fast-properties": "^2.0.0" - }, - "dependencies": { - "lodash": { - "version": "4.17.11", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz", - "integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==" - }, - "to-fast-properties": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz", - "integrity": "sha1-3F5pjL0HkmW8c+A3doGk5Og/YW4=" - } - } - }, - "@concordance/react": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/@concordance/react/-/react-2.0.0.tgz", - "integrity": "sha512-huLSkUuM2/P+U0uy2WwlKuixMsTODD8p4JVQBI4VKeopkiN0C7M3N9XYVawb4M+4spN5RrO/eLhk7KoQX6nsfA==", - "requires": { - "arrify": "^1.0.1" - } - }, - "@microsoft/recognizers-text": { - "version": "file:packages/recognizers-text" - }, - "@microsoft/recognizers-text-choice": { - "version": "file:packages/recognizers-choice", - "requires": { - "@microsoft/recognizers-text": "~1.3.0", - "grapheme-splitter": "^1.0.2" - }, - "dependencies": { - "@microsoft/recognizers-text": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/@microsoft/recognizers-text/-/recognizers-text-1.3.0.tgz", - "integrity": "sha512-0gUhtS/0qSF6veB3Olu55IuJ0Skwg4u1IbJX9KFj1QeK8z6cw69/p637IPD2NgXLlXCy2HEqLvUW/mgbDp3rWg==" - } - } - }, - "@microsoft/recognizers-text-data-types-timex-expression": { - "version": "file:packages/datatypes-date-time" - }, - "@microsoft/recognizers-text-date-time": { - "version": "file:packages/recognizers-date-time", - "requires": { - "@microsoft/recognizers-text": "~1.3.0", - "@microsoft/recognizers-text-number": "~1.3.0", - "@microsoft/recognizers-text-number-with-unit": "~1.3.0", - "lodash.isequal": "^4.5.0", - "lodash.tonumber": "^4.0.3" - }, - "dependencies": { - "@microsoft/recognizers-text": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/@microsoft/recognizers-text/-/recognizers-text-1.3.0.tgz", - "integrity": "sha512-0gUhtS/0qSF6veB3Olu55IuJ0Skwg4u1IbJX9KFj1QeK8z6cw69/p637IPD2NgXLlXCy2HEqLvUW/mgbDp3rWg==" - }, - "@microsoft/recognizers-text-number": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/@microsoft/recognizers-text-number/-/recognizers-text-number-1.3.0.tgz", - "integrity": "sha512-KVFxvaXW9E7UkuF0EYCghvCn0u+N5L7bBXeP4IKB6fXkQd6GAZ9zNA2Acdm9lJzCRxcsBYFbRLcRMrPHwAa32w==", - "requires": { - "@microsoft/recognizers-text": "~1.3.0", - "bignumber.js": "^7.2.1", - "lodash.escaperegexp": "^4.1.2", - "lodash.sortby": "^4.7.0", - "lodash.trimend": "^4.5.1" - } - }, - "@microsoft/recognizers-text-number-with-unit": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/@microsoft/recognizers-text-number-with-unit/-/recognizers-text-number-with-unit-1.3.0.tgz", - "integrity": "sha512-FxBD1ZQLvr4c+ssVyqUjblg+i21GbzIsDEHd5VWon5wg+2qrqixlmP1mXsXG+iGRV3qqeZCtTFdqkwJ3MWhovA==", - "requires": { - "@microsoft/recognizers-text": "~1.3.0", - "@microsoft/recognizers-text-number": "~1.3.0", - "lodash.escaperegexp": "^4.1.2", - "lodash.last": "^3.0.0", - "lodash.max": "^4.0.1" - } - } - } - }, - "@microsoft/recognizers-text-number": { - "version": "file:packages/recognizers-number", - "requires": { - "@microsoft/recognizers-text": "~1.3.0", - "bignumber.js": "^7.2.1", - "lodash.escaperegexp": "^4.1.2", - "lodash.sortby": "^4.7.0", - "lodash.trimend": "^4.5.1" - }, - "dependencies": { - "@microsoft/recognizers-text": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/@microsoft/recognizers-text/-/recognizers-text-1.3.0.tgz", - "integrity": "sha512-0gUhtS/0qSF6veB3Olu55IuJ0Skwg4u1IbJX9KFj1QeK8z6cw69/p637IPD2NgXLlXCy2HEqLvUW/mgbDp3rWg==" - } - } - }, - "@microsoft/recognizers-text-number-with-unit": { - "version": "file:packages/recognizers-number-with-unit", - "requires": { - "@microsoft/recognizers-text": "~1.3.0", - "@microsoft/recognizers-text-number": "~1.3.0", - "lodash.escaperegexp": "^4.1.2", - "lodash.last": "^3.0.0", - "lodash.max": "^4.0.1" - }, - "dependencies": { - "@microsoft/recognizers-text": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/@microsoft/recognizers-text/-/recognizers-text-1.3.0.tgz", - "integrity": "sha512-0gUhtS/0qSF6veB3Olu55IuJ0Skwg4u1IbJX9KFj1QeK8z6cw69/p637IPD2NgXLlXCy2HEqLvUW/mgbDp3rWg==" - }, - "@microsoft/recognizers-text-number": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/@microsoft/recognizers-text-number/-/recognizers-text-number-1.3.0.tgz", - "integrity": "sha512-KVFxvaXW9E7UkuF0EYCghvCn0u+N5L7bBXeP4IKB6fXkQd6GAZ9zNA2Acdm9lJzCRxcsBYFbRLcRMrPHwAa32w==", - "requires": { - "@microsoft/recognizers-text": "~1.3.0", - "bignumber.js": "^7.2.1", - "lodash.escaperegexp": "^4.1.2", - "lodash.sortby": "^4.7.0", - "lodash.trimend": "^4.5.1" - } - } - } - }, - "@microsoft/recognizers-text-sequence": { - "version": "file:packages/recognizers-sequence", - "requires": { - "@microsoft/recognizers-text": "~1.3.0", - "grapheme-splitter": "^1.0.2" - }, - "dependencies": { - "@microsoft/recognizers-text": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/@microsoft/recognizers-text/-/recognizers-text-1.3.0.tgz", - "integrity": "sha512-0gUhtS/0qSF6veB3Olu55IuJ0Skwg4u1IbJX9KFj1QeK8z6cw69/p637IPD2NgXLlXCy2HEqLvUW/mgbDp3rWg==" - } - } - }, - "@microsoft/recognizers-text-suite": { - "version": "file:packages/recognizers-text-suite", - "requires": { - "@microsoft/recognizers-text": "~1.3.0", - "@microsoft/recognizers-text-choice": "~1.3.0", - "@microsoft/recognizers-text-data-types-timex-expression": "~1.3.0", - "@microsoft/recognizers-text-date-time": "~1.3.0", - "@microsoft/recognizers-text-number": "~1.3.0", - "@microsoft/recognizers-text-number-with-unit": "~1.3.0", - "@microsoft/recognizers-text-sequence": "~1.3.0" - }, - "dependencies": { - "@microsoft/recognizers-text": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/@microsoft/recognizers-text/-/recognizers-text-1.3.0.tgz", - "integrity": "sha512-0gUhtS/0qSF6veB3Olu55IuJ0Skwg4u1IbJX9KFj1QeK8z6cw69/p637IPD2NgXLlXCy2HEqLvUW/mgbDp3rWg==" - }, - "@microsoft/recognizers-text-choice": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/@microsoft/recognizers-text-choice/-/recognizers-text-choice-1.3.0.tgz", - "integrity": "sha512-I2LQAJJ9TJthJYWZNzooJD6+5KUkr+H+m54XpjY+vKjR81DPVFUL/SWZVyv+cC7eePFwrDv3gUnkXYS+Lp0hmA==", - "requires": { - "@microsoft/recognizers-text": "~1.3.0", - "grapheme-splitter": "^1.0.2" - } - }, - "@microsoft/recognizers-text-data-types-timex-expression": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/@microsoft/recognizers-text-data-types-timex-expression/-/recognizers-text-data-types-timex-expression-1.3.0.tgz", - "integrity": "sha512-REHUXmMUI1jL3b9v+aSdzKxLxRdejsfg9McYRxY3LW0Gu4UbwD7Q+K6mtSo40cwg8uh6fiV9GY8hDuKXHH6dVA==" - }, - "@microsoft/recognizers-text-date-time": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/@microsoft/recognizers-text-date-time/-/recognizers-text-date-time-1.3.0.tgz", - "integrity": "sha512-bgw4TS726maTg53M6SQRHQOzOH0za0zmBWnnGo0wQdbDfK+bgq5aeDSD4k/HhXvfkOD6zzRd3+tG3Dqyp/kFaQ==", - "requires": { - "@microsoft/recognizers-text": "~1.3.0", - "@microsoft/recognizers-text-number": "~1.3.0", - "@microsoft/recognizers-text-number-with-unit": "~1.3.0", - "lodash.isequal": "^4.5.0", - "lodash.tonumber": "^4.0.3" - } - }, - "@microsoft/recognizers-text-number": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/@microsoft/recognizers-text-number/-/recognizers-text-number-1.3.0.tgz", - "integrity": "sha512-KVFxvaXW9E7UkuF0EYCghvCn0u+N5L7bBXeP4IKB6fXkQd6GAZ9zNA2Acdm9lJzCRxcsBYFbRLcRMrPHwAa32w==", - "requires": { - "@microsoft/recognizers-text": "~1.3.0", - "bignumber.js": "^7.2.1", - "lodash.escaperegexp": "^4.1.2", - "lodash.sortby": "^4.7.0", - "lodash.trimend": "^4.5.1" - } - }, - "@microsoft/recognizers-text-number-with-unit": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/@microsoft/recognizers-text-number-with-unit/-/recognizers-text-number-with-unit-1.3.0.tgz", - "integrity": "sha512-FxBD1ZQLvr4c+ssVyqUjblg+i21GbzIsDEHd5VWon5wg+2qrqixlmP1mXsXG+iGRV3qqeZCtTFdqkwJ3MWhovA==", - "requires": { - "@microsoft/recognizers-text": "~1.3.0", - "@microsoft/recognizers-text-number": "~1.3.0", - "lodash.escaperegexp": "^4.1.2", - "lodash.last": "^3.0.0", - "lodash.max": "^4.0.1" - } - }, - "@microsoft/recognizers-text-sequence": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/@microsoft/recognizers-text-sequence/-/recognizers-text-sequence-1.3.0.tgz", - "integrity": "sha512-LXZ9AakClrdPVfEphCJFETjw6n8w/LwW1Yoj9ZKcGI9PGvH6RR+haS4GSZuHeMhEacmaa3NkzD+I44qYIvym8Q==", - "requires": { - "@microsoft/recognizers-text": "~1.3.0", - "grapheme-splitter": "^1.0.2" - } - } - } - }, - "@nodelib/fs.scandir": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.1.tgz", - "integrity": "sha512-NT/skIZjgotDSiXs0WqYhgcuBKhUMgfekCmCGtkUAiLqZdOnrdjmZr9wRl3ll64J9NF79uZ4fk16Dx0yMc/Xbg==", - "requires": { - "@nodelib/fs.stat": "2.0.1", - "run-parallel": "^1.1.9" - } - }, - "@nodelib/fs.stat": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-2.0.1.tgz", - "integrity": "sha512-+RqhBlLn6YRBGOIoVYthsG0J9dfpO79eJyN7BYBkZJtfqrBwf2KK+rD/M/yjZR6WBmIhAgOV7S60eCgaSWtbFw==" - }, - "@nodelib/fs.walk": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/@nodelib/fs.walk/-/fs.walk-1.2.2.tgz", - "integrity": "sha512-J/DR3+W12uCzAJkw7niXDcqcKBg6+5G5Q/ZpThpGNzAUz70eOR6RV4XnnSN01qHZiVl0eavoxJsBypQoKsV2QQ==", - "requires": { - "@nodelib/fs.scandir": "2.1.1", - "fastq": "^1.6.0" - } - }, - "@sindresorhus/is": { - "version": "0.14.0", - "resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-0.14.0.tgz", - "integrity": "sha512-9NET910DNaIPngYnLLPeg+Ogzqsi9uM4mSboU5y6p8S5DzMTVEsJZrawi+BoDNUVBa2DhJqQYUFvMDfgU062LQ==" - }, - "@szmarczak/http-timer": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/@szmarczak/http-timer/-/http-timer-1.1.2.tgz", - "integrity": "sha512-XIB2XbzHTN6ieIjfIMV9hlVcfPU26s2vafYWQcZHWXHOxiaRZYEDKEwdl129Zyg50+foYV2jCgtrqSA6qNuNSA==", - "requires": { - "defer-to-connect": "^1.0.1" - } - }, - "@types/eslint-visitor-keys": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/@types/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz", - "integrity": "sha512-OCutwjDZ4aFS6PB1UZ988C4YgwlBHJd6wCeQqaLdmadZ/7e+w79+hbMUFC1QXDNCmdyoRfAFdm0RypzwR+Qpag==" - }, - "@types/events": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/@types/events/-/events-3.0.0.tgz", - "integrity": "sha512-EaObqwIvayI5a8dCzhFrjKzVwKLxjoG9T6Ppd5CEo07LRKfQ8Yokw54r5+Wq7FaBQ+yXRvQAYPrHwya1/UFt9g==" - }, - "@types/glob": { - "version": "7.1.1", - "resolved": "https://registry.npmjs.org/@types/glob/-/glob-7.1.1.tgz", - "integrity": "sha512-1Bh06cbWJUHMC97acuD6UMG29nMt0Aqz1vF3guLfG+kHHJhy3AyohZFFxYk2f7Q1SQIrNwvncxAE0N/9s70F2w==", - "requires": { - "@types/events": "*", - "@types/minimatch": "*", - "@types/node": "*" - } - }, - "@types/js-yaml": { - "version": "3.11.1", - "resolved": "https://registry.npmjs.org/@types/js-yaml/-/js-yaml-3.11.1.tgz", - "integrity": "sha512-M5qhhfuTt4fwHGqqANNQilp3Htb5cHwBxlMHDUw/TYRVkEp3s3IIFSH3Fe9HIAeEtnO4p3SSowLmCVavdRYfpw==" - }, - "@types/lodash": { - "version": "4.14.108", - "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.108.tgz", - "integrity": "sha512-WD2vUOKfBBVHxWUV9iMR9RMfpuf8HquxWeAq2yqGVL7Nc4JW2+sQama0pREMqzNI3Tutj0PyxYUJwuoxxvX+xA==" - }, - "@types/lodash.escaperegexp": { - "version": "4.1.3", - "resolved": "https://registry.npmjs.org/@types/lodash.escaperegexp/-/lodash.escaperegexp-4.1.3.tgz", - "integrity": "sha1-MUTcsKvd/jTquoTRivrofVTvb0M=", - "requires": { - "@types/lodash": "*" - } - }, - "@types/lodash.isequal": { - "version": "4.5.2", - "resolved": "https://registry.npmjs.org/@types/lodash.isequal/-/lodash.isequal-4.5.2.tgz", - "integrity": "sha1-rb3/Z/fJVu1wMAnlRmo07t2wtxI=", - "requires": { - "@types/lodash": "*" - } - }, - "@types/lodash.last": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/@types/lodash.last/-/lodash.last-3.0.3.tgz", - "integrity": "sha1-6r5noO9Q8WZUBnYtu1+gnc7z4xo=", - "requires": { - "@types/lodash": "*" - } - }, - "@types/lodash.max": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/@types/lodash.max/-/lodash.max-4.0.3.tgz", - "integrity": "sha1-6ZqFCT9sflrqr3uupGfNMZzOyzY=", - "requires": { - "@types/lodash": "*" - } - }, - "@types/lodash.sortby": { - "version": "4.7.3", - "resolved": "https://registry.npmjs.org/@types/lodash.sortby/-/lodash.sortby-4.7.3.tgz", - "integrity": "sha1-0fen/ZVSRuaFp1QawYTcBYxVPrU=", - "requires": { - "@types/lodash": "*" - } - }, - "@types/lodash.tonumber": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/@types/lodash.tonumber/-/lodash.tonumber-4.0.3.tgz", - "integrity": "sha1-1mqrZPwA9Soiy1dirLsEt74ou5M=", - "requires": { - "@types/lodash": "*" - } - }, - "@types/lodash.trimend": { - "version": "4.5.3", - "resolved": "https://registry.npmjs.org/@types/lodash.trimend/-/lodash.trimend-4.5.3.tgz", - "integrity": "sha1-9gobVUi9YzwIMJVVPn5ICW0tT0c=", - "requires": { - "@types/lodash": "*" - } - }, - "@types/minimatch": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/@types/minimatch/-/minimatch-3.0.3.tgz", - "integrity": "sha512-tHq6qdbT9U1IRSGf14CL0pUlULksvY9OZ+5eEgl1N7t+OA3tGvNpxJCzuKQlsNgCVwbAs670L1vcVQi8j9HjnA==" - }, - "@types/node": { - "version": "10.12.15", - "resolved": "https://registry.npmjs.org/@types/node/-/node-10.12.15.tgz", - "integrity": "sha512-9kROxduaN98QghwwHmxXO2Xz3MaWf+I1sLVAA6KJDF5xix+IyXVhds0MAfdNwtcpSrzhaTsNB0/jnL86fgUhqA==" - }, - "@types/npm": { - "version": "2.0.29", - "resolved": "https://registry.npmjs.org/@types/npm/-/npm-2.0.29.tgz", - "integrity": "sha1-ATonidaxEDnr+O56S12v7UNQRhw=", - "requires": { - "@types/node": "*" - } - }, - "@typescript-eslint/eslint-plugin": { - "version": "1.11.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-1.11.0.tgz", - "integrity": "sha512-mXv9ccCou89C8/4avKHuPB2WkSZyY/XcTQUXd5LFZAcLw1I3mWYVjUu6eS9Ja0QkP/ClolbcW9tb3Ov/pMdcqw==", - "requires": { - "@typescript-eslint/experimental-utils": "1.11.0", - "eslint-utils": "^1.3.1", - "functional-red-black-tree": "^1.0.1", - "regexpp": "^2.0.1", - "tsutils": "^3.7.0" - }, - "dependencies": { - "tsutils": { - "version": "3.14.0", - "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.14.0.tgz", - "integrity": "sha512-SmzGbB0l+8I0QwsPgjooFRaRvHLBLNYM8SeQ0k6rtNDru5sCGeLJcZdwilNndN+GysuFjF5EIYgN8GfFG6UeUw==", - "requires": { - "tslib": "^1.8.1" - } - } - } - }, - "@typescript-eslint/experimental-utils": { - "version": "1.11.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-1.11.0.tgz", - "integrity": "sha512-7LbfaqF6B8oa8cp/315zxKk8FFzosRzzhF8Kn/ZRsRsnpm7Qcu25cR/9RnAQo5utZ2KIWVgaALr+ZmcbG47ruw==", - "requires": { - "@typescript-eslint/typescript-estree": "1.11.0", - "eslint-scope": "^4.0.0" - } - }, - "@typescript-eslint/parser": { - "version": "1.11.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-1.11.0.tgz", - "integrity": "sha512-5xBExyXaxVyczrZvbRKEXvaTUFFq7gIM9BynXukXZE0zF3IQP/FxF4mPmmh3gJ9egafZFqByCpPTFm3dk4SY7Q==", - "requires": { - "@types/eslint-visitor-keys": "^1.0.0", - "@typescript-eslint/experimental-utils": "1.11.0", - "@typescript-eslint/typescript-estree": "1.11.0", - "eslint-visitor-keys": "^1.0.0" - } - }, - "@typescript-eslint/typescript-estree": { - "version": "1.11.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-1.11.0.tgz", - "integrity": "sha512-fquUHF5tAx1sM2OeRCC7wVxFd1iMELWMGCzOSmJ3pLzArj9+kRixdlC4d5MncuzXpjEqc6045p3KwM0o/3FuUA==", - "requires": { - "lodash.unescape": "4.0.1", - "semver": "5.5.0" - } - }, - "JSONStream": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-1.3.2.tgz", - "integrity": "sha1-wQI3G27Dp887hHygDCC7D85Mbeo=", - "requires": { - "jsonparse": "^1.2.0", - "through": ">=2.2.7 <3" - } - }, - "accepts": { - "version": "1.3.5", - "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.5.tgz", - "integrity": "sha1-63d99gEXI6OxTopywIBcjoZ0a9I=", - "requires": { - "mime-types": "~2.1.18", - "negotiator": "0.6.1" - } - }, - "accessory": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/accessory/-/accessory-1.1.0.tgz", - "integrity": "sha1-eDPpg5oy3tdtJgIfNqQXB6Ug9ZM=", - "requires": { - "ap": "~0.2.0", - "balanced-match": "~0.2.0", - "dot-parts": "~1.0.0" - }, - "dependencies": { - "balanced-match": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-0.2.1.tgz", - "integrity": "sha1-e8ZYtL7WHu5CStdPdfXD4sTfPMc=" - } - } - }, - "acorn": { - "version": "7.1.1", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.1.1.tgz", - "integrity": "sha512-add7dgA5ppRPxCFJoAGfMDi7PIBXq1RtGo7BhbLaxwrXPOmw8gq48Y9ozT01hUKy9byMjlR20EJhu5zlkErEkg==" - }, - "acorn-jsx": { - "version": "5.0.2", - "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.0.2.tgz", - "integrity": "sha512-tiNTrP1MP0QrChmD2DdupCr6HWSFeKVw5d/dHTu4Y7rkAkRhU/Dt7dphAfIUyxtHpl/eBVip5uTNSpQJHylpAw==" - }, - "acorn-node": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/acorn-node/-/acorn-node-1.3.0.tgz", - "integrity": "sha512-efP54n3d1aLfjL2UMdaXa6DsswwzJeI5rqhbFvXMrKiJ6eJFpf+7R0zN7t8IC+XKn2YOAFAv6xbBNgHUkoHWLw==", - "requires": { - "acorn": "^5.4.1", - "xtend": "^4.0.1" - }, - "dependencies": { - "acorn": { - "version": "5.5.3", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.5.3.tgz", - "integrity": "sha512-jd5MkIUlbbmb07nXH0DT3y7rDVtkzDi4XZOUVWAer8ajmF/DTSSbl5oNFyDOl/OXA33Bl79+ypHhl2pN20VeOQ==" - } - } - }, - "add-stream": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/add-stream/-/add-stream-1.0.0.tgz", - "integrity": "sha1-anmQQ3ynNtXhKI25K9MmbV9csqo=" - }, - "ajv": { - "version": "6.10.2", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.10.2.tgz", - "integrity": "sha512-TXtUUEYHuaTEbLZWIKUr5pmBuhDLy+8KYtPYdcV8qC+pOZL+NKqYwvWSRrVXHn+ZmRRAu8vJTAznH7Oag6RVRw==", - "requires": { - "fast-deep-equal": "^2.0.1", - "fast-json-stable-stringify": "^2.0.0", - "json-schema-traverse": "^0.4.1", - "uri-js": "^4.2.2" - } - }, - "amdefine": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/amdefine/-/amdefine-1.0.1.tgz", - "integrity": "sha1-SlKCrBZHKek2Gbz9OtFR+BfOkfU=", - "optional": true - }, - "ansi-align": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/ansi-align/-/ansi-align-3.0.0.tgz", - "integrity": "sha512-ZpClVKqXN3RGBmKibdfWzqCY4lnjEuoNzU5T0oEFpfd/z5qJHVarukridD4juLO2FXMiwUQxr9WqQtaYa8XRYw==", - "requires": { - "string-width": "^3.0.0" - }, - "dependencies": { - "ansi-regex": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", - "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==" - }, - "string-width": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz", - "integrity": "sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w==", - "requires": { - "emoji-regex": "^7.0.1", - "is-fullwidth-code-point": "^2.0.0", - "strip-ansi": "^5.1.0" - } - }, - "strip-ansi": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", - "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", - "requires": { - "ansi-regex": "^4.1.0" - } - } - } - }, - "ansi-escapes": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-3.2.0.tgz", - "integrity": "sha512-cBhpre4ma+U0T1oM5fXg7Dy1Jw7zzwv7lt/GoCpr+hDQJoYnKVPLL4dCvSEFMmQurOQvSrwT7SL/DAlhBI97RQ==" - }, - "ansi-regex": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", - "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=" - }, - "ansi-styles": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", - "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", - "requires": { - "color-convert": "^1.9.0" - } - }, - "anymatch": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.0.3.tgz", - "integrity": "sha512-c6IvoeBECQlMVuYUjSwimnhmztImpErfxJzWZhIQinIvQWoGOnB0dLIgifbPHQt5heS6mNlaZG16f06H3C8t1g==", - "requires": { - "normalize-path": "^3.0.0", - "picomatch": "^2.0.4" - } - }, - "ap": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/ap/-/ap-0.2.0.tgz", - "integrity": "sha1-rglCYAspkS8NKxTsYMRejzMLYRA=" - }, - "aproba": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/aproba/-/aproba-1.2.0.tgz", - "integrity": "sha512-Y9J6ZjXtoYh8RnXVCMOU/ttDmk1aBjunq9vO0ta5x85WDQiQfUF9sIPBITdbiiIVcBo03Hi3jMxigBtsddlXRw==" - }, - "are-we-there-yet": { - "version": "1.1.5", - "resolved": "https://registry.npmjs.org/are-we-there-yet/-/are-we-there-yet-1.1.5.tgz", - "integrity": "sha512-5hYdAkZlcG8tOLujVDTgCT+uPX0VnpAH28gWsLfzpXYm7wP6mp5Q/gYyR7YQ0cKVJcXJnl3j2kpBan13PtQf6w==", - "requires": { - "delegates": "^1.0.0", - "readable-stream": "^2.0.6" - } - }, - "argparse": { - "version": "1.0.10", - "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", - "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", - "requires": { - "sprintf-js": "~1.0.2" - } - }, - "arr-diff": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-4.0.0.tgz", - "integrity": "sha1-1kYQdP6/7HHn4VI1dhoyml3HxSA=" - }, - "arr-flatten": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/arr-flatten/-/arr-flatten-1.1.0.tgz", - "integrity": "sha1-NgSLv/TntH4TZkQxbJlmnqWukfE=" - }, - "arr-union": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/arr-union/-/arr-union-3.1.0.tgz", - "integrity": "sha1-45sJrqne+Gao8gbiiK9jkZuuOcQ=" - }, - "array-filter": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/array-filter/-/array-filter-0.0.1.tgz", - "integrity": "sha1-fajPLiZijtcygDWB/SH2fKzS7uw=" - }, - "array-find-index": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/array-find-index/-/array-find-index-1.0.2.tgz", - "integrity": "sha1-3wEKoSh+Fku9pvlyOwqWoexBh6E=" - }, - "array-flatten": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", - "integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=" - }, - "array-ify": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/array-ify/-/array-ify-1.0.0.tgz", - "integrity": "sha1-nlKHYrSpBmrRY6aWKjZEGOlibs4=" - }, - "array-map": { - "version": "0.0.0", - "resolved": "https://registry.npmjs.org/array-map/-/array-map-0.0.0.tgz", - "integrity": "sha1-iKK6tz0c97zVwbEYoAP2b2ZfpmI=" - }, - "array-reduce": { - "version": "0.0.0", - "resolved": "https://registry.npmjs.org/array-reduce/-/array-reduce-0.0.0.tgz", - "integrity": "sha1-FziZ0//Rx9k4PkR5Ul2+J4yrXys=" - }, - "array-union": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/array-union/-/array-union-1.0.2.tgz", - "integrity": "sha1-mjRBDk9OPaI96jdb5b5w8kd47Dk=", - "requires": { - "array-uniq": "^1.0.1" - } - }, - "array-uniq": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/array-uniq/-/array-uniq-1.0.3.tgz", - "integrity": "sha1-r2rId6Jcx/dOBYiUdThY39sk/bY=" - }, - "array-unique": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.3.2.tgz", - "integrity": "sha1-qJS3XUvE9s1nnvMkSp/Y9Gri1Cg=" - }, - "arrify": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/arrify/-/arrify-1.0.1.tgz", - "integrity": "sha1-iYUI2iIm84DfkEcoRWhJwVAaSw0=" - }, - "asn1.js": { - "version": "4.10.1", - "resolved": "https://registry.npmjs.org/asn1.js/-/asn1.js-4.10.1.tgz", - "integrity": "sha512-p32cOF5q0Zqs9uBiONKYLm6BClCoBCM5O9JfeUSlnQLBTxYdTK+pW+nXflm8UkKd2UYlEbYz5qEi0JuZR9ckSw==", - "requires": { - "bn.js": "^4.0.0", - "inherits": "^2.0.1", - "minimalistic-assert": "^1.0.0" - } - }, - "assert": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/assert/-/assert-1.4.1.tgz", - "integrity": "sha1-mZEtWRg2tab1s0XA8H7vwI/GXZE=", - "requires": { - "util": "0.10.3" - } - }, - "assertion-error": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", - "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==" - }, - "assign-symbols": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/assign-symbols/-/assign-symbols-1.0.0.tgz", - "integrity": "sha1-WWZ/QfrdTyDMvCu5a41Pf3jsA2c=" - }, - "astral-regex": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/astral-regex/-/astral-regex-1.0.0.tgz", - "integrity": "sha512-+Ryf6g3BKoRc7jfp7ad8tM4TtMiaWvbF/1/sQcZPkkS7ag3D5nMBCe2UfOTONtAkaG0tO0ij3C5Lwmf1EiyjHg==" - }, - "astw": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/astw/-/astw-2.2.0.tgz", - "integrity": "sha1-e9QXhNMkk5h66yOba04cV6hzuRc=", - "requires": { - "acorn": "^4.0.3" - }, - "dependencies": { - "acorn": { - "version": "4.0.13", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-4.0.13.tgz", - "integrity": "sha1-EFSVrlNh1pe9GVyCUZLhrX8lN4c=" - } - } - }, - "async": { - "version": "1.5.2", - "resolved": "https://registry.npmjs.org/async/-/async-1.5.2.tgz", - "integrity": "sha1-7GphrlZIDAw8skHJVhjiCJL5Zyo=" - }, - "atob": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/atob/-/atob-2.1.1.tgz", - "integrity": "sha1-ri1acpR38onWDdf5amMUoi3Wwio=" - }, - "ava": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/ava/-/ava-2.2.0.tgz", - "integrity": "sha512-lROj3eQ8L4ZjfiN5P8UGekEQLfKmseGMtat6pUOHgJLEb2K1kT0ZpR/IlWwuytjvwO6nZpzpD+QsTW/XiayIgg==", - "requires": { - "@ava/babel-preset-stage-4": "^3.0.0", - "@ava/babel-preset-transform-test-files": "^5.0.0", - "@babel/core": "^7.5.0", - "@babel/generator": "^7.5.0", - "@babel/plugin-syntax-async-generators": "^7.2.0", - "@babel/plugin-syntax-object-rest-spread": "^7.2.0", - "@babel/plugin-syntax-optional-catch-binding": "^7.2.0", - "@concordance/react": "^2.0.0", - "ansi-escapes": "^4.2.0", - "ansi-styles": "^4.0.0", - "arr-flatten": "^1.1.0", - "array-union": "^2.1.0", - "array-uniq": "^2.1.0", - "arrify": "^2.0.1", - "bluebird": "^3.5.5", - "chalk": "^2.4.2", - "chokidar": "^3.0.2", - "chunkd": "^1.0.0", - "ci-parallel-vars": "^1.0.0", - "clean-stack": "^2.1.0", - "clean-yaml-object": "^0.1.0", - "cli-cursor": "^3.1.0", - "cli-truncate": "^2.0.0", - "code-excerpt": "^2.1.1", - "common-path-prefix": "^1.0.0", - "concordance": "^4.0.0", - "convert-source-map": "^1.6.0", - "currently-unhandled": "^0.4.1", - "debug": "^4.1.1", - "del": "^4.1.1", - "dot-prop": "^5.1.0", - "emittery": "^0.4.1", - "empower-core": "^1.2.0", - "equal-length": "^1.0.0", - "escape-string-regexp": "^2.0.0", - "esm": "^3.2.25", - "figures": "^3.0.0", - "find-up": "^4.1.0", - "get-port": "^5.0.0", - "globby": "^10.0.1", - "ignore-by-default": "^1.0.0", - "import-local": "^3.0.1", - "indent-string": "^4.0.0", - "is-ci": "^2.0.0", - "is-error": "^2.2.2", - "is-observable": "^2.0.0", - "is-plain-object": "^3.0.0", - "is-promise": "^2.1.0", - "lodash": "^4.17.11", - "loud-rejection": "^2.1.0", - "make-dir": "^3.0.0", - "matcher": "^2.0.0", - "md5-hex": "^3.0.0", - "meow": "^5.0.0", - "micromatch": "^4.0.2", - "ms": "^2.1.2", - "observable-to-promise": "^1.0.0", - "ora": "^3.4.0", - "package-hash": "^4.0.0", - "pkg-conf": "^3.1.0", - "plur": "^3.1.1", - "pretty-ms": "^5.0.0", - "require-precompiled": "^0.1.0", - "resolve-cwd": "^3.0.0", - "slash": "^3.0.0", - "source-map-support": "^0.5.12", - "stack-utils": "^1.0.2", - "strip-ansi": "^5.2.0", - "strip-bom-buf": "^2.0.0", - "supertap": "^1.0.0", - "supports-color": "^7.0.0", - "trim-off-newlines": "^1.0.1", - "trim-right": "^1.0.1", - "unique-temp-dir": "^1.0.0", - "update-notifier": "^3.0.1", - "write-file-atomic": "^3.0.0" - }, - "dependencies": { - "@babel/generator": { - "version": "7.5.0", - "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.5.0.tgz", - "integrity": "sha512-1TTVrt7J9rcG5PMjvO7VEG3FrEoEJNHxumRq66GemPmzboLWtIjjcJgk8rokuAS7IiRSpgVSu5Vb9lc99iJkOA==", - "requires": { - "@babel/types": "^7.5.0", - "jsesc": "^2.5.1", - "lodash": "^4.17.11", - "source-map": "^0.5.0", - "trim-right": "^1.0.1" - } - }, - "@babel/types": { - "version": "7.5.0", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.5.0.tgz", - "integrity": "sha512-UFpDVqRABKsW01bvw7/wSUe56uy6RXM5+VJibVVAybDGxEW25jdwiFJEf7ASvSaC7sN7rbE/l3cLp2izav+CtQ==", - "requires": { - "esutils": "^2.0.2", - "lodash": "^4.17.11", - "to-fast-properties": "^2.0.0" - } - }, - "ansi-escapes": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-4.2.0.tgz", - "integrity": "sha512-0+VX4uhi8m3aNbzoqKmkAVOEj6uQzcUHXoFPkKjhZPTpGRUBqVh930KbB6PS4zIyDZccphlLIYlu8nsjFzkXwg==", - "requires": { - "type-fest": "^0.5.2" - } - }, - "ansi-regex": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", - "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==" - }, - "ansi-styles": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.0.0.tgz", - "integrity": "sha512-8zjUtFJ3db/QoPXuuEMloS2AUf79/yeyttJ7Abr3hteopJu9HK8vsgGviGUMq+zyA6cZZO6gAyZoMTF6TgaEjA==", - "requires": { - "color-convert": "^2.0.0" - } - }, - "array-union": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/array-union/-/array-union-2.1.0.tgz", - "integrity": "sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==" - }, - "array-uniq": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/array-uniq/-/array-uniq-2.1.0.tgz", - "integrity": "sha512-bdHxtev7FN6+MXI1YFW0Q8mQ8dTJc2S8AMfju+ZR77pbg2yAdVyDlwkaUI7Har0LyOMRFPHrJ9lYdyjZZswdlQ==" - }, - "arrify": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/arrify/-/arrify-2.0.1.tgz", - "integrity": "sha512-3duEwti880xqi4eAMN8AyR4a0ByT90zoYdLlevfrvU43vb0YZwZVfxOgxWrLXXXpyugL0hNZc9G6BiB5B3nUug==" - }, - "camelcase": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-4.1.0.tgz", - "integrity": "sha1-1UVjW+HjPFQmScaRc+Xeas+uNN0=" - }, - "camelcase-keys": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/camelcase-keys/-/camelcase-keys-4.2.0.tgz", - "integrity": "sha1-oqpfsa9oh1glnDLBQUJteJI7m3c=", - "requires": { - "camelcase": "^4.1.0", - "map-obj": "^2.0.0", - "quick-lru": "^1.0.0" - } - }, - "chalk": { - "version": "2.4.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", - "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", - "requires": { - "ansi-styles": "^3.2.1", - "escape-string-regexp": "^1.0.5", - "supports-color": "^5.3.0" - }, - "dependencies": { - "ansi-styles": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", - "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", - "requires": { - "color-convert": "^1.9.0" - } - }, - "color-convert": { - "version": "1.9.3", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", - "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", - "requires": { - "color-name": "1.1.3" - } - }, - "color-name": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", - "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=" - }, - "escape-string-regexp": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", - "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=" - }, - "supports-color": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", - "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", - "requires": { - "has-flag": "^3.0.0" - } - } - } - }, - "ci-info": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-2.0.0.tgz", - "integrity": "sha512-5tK7EtrZ0N+OLFMthtqOj4fI2Jeb88C4CAZPu25LDVUgXJ0A3Js4PMGqrn0JU1W0Mh1/Z8wZzYPxqUrXeBboCQ==" - }, - "cli-cursor": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-3.1.0.tgz", - "integrity": "sha512-I/zHAwsKf9FqGoXM4WWRACob9+SNukZTd94DWF57E4toouRulbCxcUh6RKUEOQlYTHJnzkPMySvPNaaSLNfLZw==", - "requires": { - "restore-cursor": "^3.1.0" - } - }, - "color-convert": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.0.tgz", - "integrity": "sha512-hzTicsCJIHdxih9+2aLR1tNGZX5qSJGRHDPVwSY26tVrEf55XNajLOBWz2UuWSIergszA09/bqnOiHyqx9fxQg==", - "requires": { - "color-name": "~1.1.4" - } - }, - "color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" - }, - "convert-source-map": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.6.0.tgz", - "integrity": "sha512-eFu7XigvxdZ1ETfbgPBohgyQ/Z++C0eEhTor0qRwBw9unw+L0/6V8wkSuGgzdThkiS5lSpdptOQPD8Ak40a+7A==", - "requires": { - "safe-buffer": "~5.1.1" - } - }, - "debug": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", - "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", - "requires": { - "ms": "^2.1.1" - } - }, - "escape-string-regexp": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-2.0.0.tgz", - "integrity": "sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w==" - }, - "figures": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/figures/-/figures-3.0.0.tgz", - "integrity": "sha512-HKri+WoWoUgr83pehn/SIgLOMZ9nAWC6dcGj26RY2R4F50u4+RTUz0RCrUlOV3nKRAICW1UGzyb+kcX2qK1S/g==", - "requires": { - "escape-string-regexp": "^1.0.5" - }, - "dependencies": { - "escape-string-regexp": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", - "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=" - } - } - }, - "find-up": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", - "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", - "requires": { - "locate-path": "^5.0.0", - "path-exists": "^4.0.0" - } - }, - "get-port": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/get-port/-/get-port-5.0.0.tgz", - "integrity": "sha512-imzMU0FjsZqNa6BqOjbbW6w5BivHIuQKopjpPqcnx0AVHJQKCxK1O+Ab3OrVXhrekqfVMjwA9ZYu062R+KcIsQ==", - "requires": { - "type-fest": "^0.3.0" - }, - "dependencies": { - "type-fest": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.3.1.tgz", - "integrity": "sha512-cUGJnCdr4STbePCgqNFbpVNCepa+kAVohJs1sLhxzdH+gnEoOd8VhbYa7pD3zZYGiURWM2xzEII3fQcRizDkYQ==" - } - } - }, - "glob": { - "version": "7.1.4", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.4.tgz", - "integrity": "sha512-hkLPepehmnKk41pUGm3sYxoFs/umurYfYJCerbXEyFIWcAzvpipAgVkBqqT9RBKMGjnq6kMuyYwha6csxbiM1A==", - "requires": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.0.4", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" - } - }, - "globby": { - "version": "10.0.1", - "resolved": "https://registry.npmjs.org/globby/-/globby-10.0.1.tgz", - "integrity": "sha512-sSs4inE1FB2YQiymcmTv6NWENryABjUNPeWhOvmn4SjtKybglsyPZxFB3U1/+L1bYi0rNZDqCLlHyLYDl1Pq5A==", - "requires": { - "@types/glob": "^7.1.1", - "array-union": "^2.1.0", - "dir-glob": "^3.0.1", - "fast-glob": "^3.0.3", - "glob": "^7.1.3", - "ignore": "^5.1.1", - "merge2": "^1.2.3", - "slash": "^3.0.0" - } - }, - "indent-string": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/indent-string/-/indent-string-4.0.0.tgz", - "integrity": "sha512-EdDDZu4A2OyIK7Lr/2zG+w5jmbuk1DVBnEwREQvBzspBJkCEbRa8GxU1lghYcaGJCnRWibjDXlq779X1/y5xwg==" - }, - "is-ci": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/is-ci/-/is-ci-2.0.0.tgz", - "integrity": "sha512-YfJT7rkpQB0updsdHLGWrvhBJfcfzNNawYDNIyQXJz0IViGf75O8EBPKSdvw2rF+LGCsX4FZ8tcr3b19LcZq4w==", - "requires": { - "ci-info": "^2.0.0" - } - }, - "is-plain-object": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-3.0.0.tgz", - "integrity": "sha512-tZIpofR+P05k8Aocp7UI/2UTa9lTJSebCXpFFoR9aibpokDj/uXBsJ8luUu0tTVYKkMU6URDUuOfJZ7koewXvg==", - "requires": { - "isobject": "^4.0.0" - } - }, - "isobject": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/isobject/-/isobject-4.0.0.tgz", - "integrity": "sha512-S/2fF5wH8SJA/kmwr6HYhK/RI/OkhD84k8ntalo0iJjZikgq1XFvR5M8NPT1x5F7fBwCG3qHfnzeP/Vh/ZxCUA==" - }, - "jsesc": { - "version": "2.5.2", - "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz", - "integrity": "sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA==" - }, - "load-json-file": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-4.0.0.tgz", - "integrity": "sha1-L19Fq5HjMhYjT9U62rZo607AmTs=", - "requires": { - "graceful-fs": "^4.1.2", - "parse-json": "^4.0.0", - "pify": "^3.0.0", - "strip-bom": "^3.0.0" - } - }, - "locate-path": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", - "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", - "requires": { - "p-locate": "^4.1.0" - } - }, - "loud-rejection": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/loud-rejection/-/loud-rejection-2.1.0.tgz", - "integrity": "sha512-g/6MQxUXYHeVqZ4PGpPL1fS1fOvlXoi7bay0pizmjAd/3JhyXwxzwrnr74yzdmhuerlslbRJ3x7IOXzFz0cE5w==", - "requires": { - "currently-unhandled": "^0.4.1", - "signal-exit": "^3.0.2" - } - }, - "make-dir": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.0.0.tgz", - "integrity": "sha512-grNJDhb8b1Jm1qeqW5R/O63wUo4UXo2v2HMic6YT9i/HBlF93S8jkMgH7yugvY9ABDShH4VZMn8I+U8+fCNegw==", - "requires": { - "semver": "^6.0.0" - } - }, - "map-obj": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/map-obj/-/map-obj-2.0.0.tgz", - "integrity": "sha1-plzSkIepJZi4eRJXpSPgISIqwfk=" - }, - "meow": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/meow/-/meow-5.0.0.tgz", - "integrity": "sha512-CbTqYU17ABaLefO8vCU153ZZlprKYWDljcndKKDCFcYQITzWCXZAVk4QMFZPgvzrnUQ3uItnIE/LoUOwrT15Ig==", - "requires": { - "camelcase-keys": "^4.0.0", - "decamelize-keys": "^1.0.0", - "loud-rejection": "^1.0.0", - "minimist-options": "^3.0.1", - "normalize-package-data": "^2.3.4", - "read-pkg-up": "^3.0.0", - "redent": "^2.0.0", - "trim-newlines": "^2.0.0", - "yargs-parser": "^10.0.0" - }, - "dependencies": { - "loud-rejection": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/loud-rejection/-/loud-rejection-1.6.0.tgz", - "integrity": "sha1-W0b4AUft7leIcPCG0Eghz5mOVR8=", - "requires": { - "currently-unhandled": "^0.4.1", - "signal-exit": "^3.0.0" - } - } - } - }, - "mimic-fn": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz", - "integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==" - }, - "ms": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", - "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" - }, - "onetime": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/onetime/-/onetime-5.1.0.tgz", - "integrity": "sha512-5NcSkPHhwTVFIQN+TUqXoS5+dlElHXdpAWu9I0HP20YOtIi+aZ0Ct82jdlILDxjLEAWwvm+qj1m6aEtsDVmm6Q==", - "requires": { - "mimic-fn": "^2.1.0" - } - }, - "p-limit": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.2.0.tgz", - "integrity": "sha512-pZbTJpoUsCzV48Mc9Nh51VbwO0X9cuPFE8gYwx9BTCt9SF8/b7Zljd2fVgOxhIF/HDTKgpVzs+GPhyKfjLLFRQ==", - "requires": { - "p-try": "^2.0.0" - } - }, - "p-locate": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", - "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", - "requires": { - "p-limit": "^2.2.0" - } - }, - "p-try": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", - "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==" - }, - "parse-json": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-4.0.0.tgz", - "integrity": "sha1-vjX1Qlvh9/bHRxhPmKeIy5lHfuA=", - "requires": { - "error-ex": "^1.3.1", - "json-parse-better-errors": "^1.0.1" - } - }, - "path-exists": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", - "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==" - }, - "path-type": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/path-type/-/path-type-3.0.0.tgz", - "integrity": "sha512-T2ZUsdZFHgA3u4e5PfPbjd7HDDpxPnQb5jN0SrDsjNSuVXHJqtwTnWqG0B1jZrgmJ/7lj1EmVIByWt1gxGkWvg==", - "requires": { - "pify": "^3.0.0" - } - }, - "pify": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/pify/-/pify-3.0.0.tgz", - "integrity": "sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY=" - }, - "read-pkg": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-3.0.0.tgz", - "integrity": "sha1-nLxoaXj+5l0WwA4rGcI3/Pbjg4k=", - "requires": { - "load-json-file": "^4.0.0", - "normalize-package-data": "^2.3.2", - "path-type": "^3.0.0" - } - }, - "read-pkg-up": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-3.0.0.tgz", - "integrity": "sha1-PtSWaF26D4/hGNBpHcUfSh/5bwc=", - "requires": { - "find-up": "^2.0.0", - "read-pkg": "^3.0.0" - }, - "dependencies": { - "find-up": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-2.1.0.tgz", - "integrity": "sha1-RdG35QbHF93UgndaK3eSCjwMV6c=", - "requires": { - "locate-path": "^2.0.0" - } - }, - "locate-path": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-2.0.0.tgz", - "integrity": "sha1-K1aLJl7slExtnA3pw9u7ygNUzY4=", - "requires": { - "p-locate": "^2.0.0", - "path-exists": "^3.0.0" - } - }, - "p-limit": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-1.3.0.tgz", - "integrity": "sha512-vvcXsLAJ9Dr5rQOPk7toZQZJApBl2K4J6dANSsEuh6QI41JYcsS/qhTGa9ErIUUgK3WNQoJYvylxvjqmiqEA9Q==", - "requires": { - "p-try": "^1.0.0" - } - }, - "p-locate": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-2.0.0.tgz", - "integrity": "sha1-IKAQOyIqcMj9OcwuWAaA893l7EM=", - "requires": { - "p-limit": "^1.1.0" - } - }, - "p-try": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/p-try/-/p-try-1.0.0.tgz", - "integrity": "sha1-y8ec26+P1CKOE/Yh8rGiN8GyB7M=" - }, - "path-exists": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", - "integrity": "sha1-zg6+ql94yxiSXqfYENe1mwEP1RU=" - } - } - }, - "redent": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/redent/-/redent-2.0.0.tgz", - "integrity": "sha1-wbIAe0LVfrE4kHmzyDM2OdXhzKo=", - "requires": { - "indent-string": "^3.0.0", - "strip-indent": "^2.0.0" - }, - "dependencies": { - "indent-string": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/indent-string/-/indent-string-3.2.0.tgz", - "integrity": "sha1-Sl/W0nzDMvN+VBmlBNu4NxBckok=" - } - } - }, - "restore-cursor": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-3.1.0.tgz", - "integrity": "sha512-l+sSefzHpj5qimhFSE5a8nufZYAM3sBSVMAPtYkmC+4EH2anSGaEMXSD0izRQbu9nfyQ9y5JrVmp7E8oZrUjvA==", - "requires": { - "onetime": "^5.1.0", - "signal-exit": "^3.0.2" - } - }, - "semver": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.2.0.tgz", - "integrity": "sha512-jdFC1VdUGT/2Scgbimf7FSx9iJLXoqfglSF+gJeuNWVpiE37OIbc1jywR/GJyFdz3mnkz2/id0L0J/cr0izR5A==" - }, - "slash": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", - "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==" - }, - "source-map-support": { - "version": "0.5.12", - "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.12.tgz", - "integrity": "sha512-4h2Pbvyy15EE02G+JOZpUCmqWJuqrs+sEkzewTm++BPi7Hvn/HwcqLAcNxYAyI0x13CpPPn+kMjl+hplXMHITQ==", - "requires": { - "buffer-from": "^1.0.0", - "source-map": "^0.6.0" - }, - "dependencies": { - "source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==" - } - } - }, - "strip-ansi": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", - "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", - "requires": { - "ansi-regex": "^4.1.0" - } - }, - "strip-indent": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/strip-indent/-/strip-indent-2.0.0.tgz", - "integrity": "sha1-XvjbKV0B5u1sv3qrlpmNeCJSe2g=" - }, - "to-fast-properties": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz", - "integrity": "sha1-3F5pjL0HkmW8c+A3doGk5Og/YW4=" - }, - "trim-newlines": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/trim-newlines/-/trim-newlines-2.0.0.tgz", - "integrity": "sha1-tAPQuRvlDDMd/EuC7s6yLD3hbSA=" - }, - "write-file-atomic": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-3.0.0.tgz", - "integrity": "sha512-EIgkf60l2oWsffja2Sf2AL384dx328c0B+cIYPTQq5q2rOYuDV00/iPFBOUiDKKwKMOhkymH8AidPaRvzfxY+Q==", - "requires": { - "imurmurhash": "^0.1.4", - "is-typedarray": "^1.0.0", - "signal-exit": "^3.0.2", - "typedarray-to-buffer": "^3.1.5" - } - }, - "yargs-parser": { - "version": "10.1.0", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-10.1.0.tgz", - "integrity": "sha512-VCIyR1wJoEBZUqk5PA+oOBF6ypbwh5aNB3I50guxAL/quggdfs4TtNHQrSazFA3fYZ+tEqfs0zIGlv0c/rgjbQ==", - "requires": { - "camelcase": "^4.1.0" - } - } - } - }, - "ava-spec": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/ava-spec/-/ava-spec-1.1.1.tgz", - "integrity": "sha1-kkw1YZNJWV0+yCDOoYHWnxnEDVA=", - "requires": { - "fn-name": "^2.0.1", - "option-chain": "^0.1.0" - }, - "dependencies": { - "option-chain": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/option-chain/-/option-chain-0.1.1.tgz", - "integrity": "sha1-6bgR4AbxwPVIAvKClb/Ilw+Nz70=", - "requires": { - "object-assign": "^4.0.1" - } - } - } - }, - "babel-code-frame": { - "version": "6.26.0", - "resolved": "https://registry.npmjs.org/babel-code-frame/-/babel-code-frame-6.26.0.tgz", - "integrity": "sha1-Y/1D99weO7fONZR9uP42mj9Yx0s=", - "requires": { - "chalk": "^1.1.3", - "esutils": "^2.0.2", - "js-tokens": "^3.0.2" - }, - "dependencies": { - "ansi-styles": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", - "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=" - }, - "chalk": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", - "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", - "requires": { - "ansi-styles": "^2.2.1", - "escape-string-regexp": "^1.0.2", - "has-ansi": "^2.0.0", - "strip-ansi": "^3.0.0", - "supports-color": "^2.0.0" - } - }, - "strip-ansi": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", - "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", - "requires": { - "ansi-regex": "^2.0.0" - } - }, - "supports-color": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", - "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=" - } - } - }, - "babel-core": { - "version": "6.26.3", - "resolved": "https://registry.npmjs.org/babel-core/-/babel-core-6.26.3.tgz", - "integrity": "sha512-6jyFLuDmeidKmUEb3NM+/yawG0M2bDZ9Z1qbZP59cyHLz8kYGKYwpJP0UwUKKUiTRNvxfLesJnTedqczP7cTDA==", - "requires": { - "babel-code-frame": "^6.26.0", - "babel-generator": "^6.26.0", - "babel-helpers": "^6.24.1", - "babel-messages": "^6.23.0", - "babel-register": "^6.26.0", - "babel-runtime": "^6.26.0", - "babel-template": "^6.26.0", - "babel-traverse": "^6.26.0", - "babel-types": "^6.26.0", - "babylon": "^6.18.0", - "convert-source-map": "^1.5.1", - "debug": "^2.6.9", - "json5": "^0.5.1", - "lodash": "^4.17.4", - "minimatch": "^3.0.4", - "path-is-absolute": "^1.0.1", - "private": "^0.1.8", - "slash": "^1.0.0", - "source-map": "^0.5.7" - } - }, - "babel-eslint": { - "version": "10.0.2", - "resolved": "https://registry.npmjs.org/babel-eslint/-/babel-eslint-10.0.2.tgz", - "integrity": "sha512-UdsurWPtgiPgpJ06ryUnuaSXC2s0WoSZnQmEpbAH65XZSdwowgN5MvyP7e88nW07FYXv72erVtpBkxyDVKhH1Q==", - "requires": { - "@babel/code-frame": "^7.0.0", - "@babel/parser": "^7.0.0", - "@babel/traverse": "^7.0.0", - "@babel/types": "^7.0.0", - "eslint-scope": "3.7.1", - "eslint-visitor-keys": "^1.0.0" - }, - "dependencies": { - "eslint-scope": { - "version": "3.7.1", - "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-3.7.1.tgz", - "integrity": "sha1-PWPD7f2gLgbgGkUq2IyqzHzctug=", - "requires": { - "esrecurse": "^4.1.0", - "estraverse": "^4.1.1" - } - } - } - }, - "babel-generator": { - "version": "6.26.1", - "resolved": "https://registry.npmjs.org/babel-generator/-/babel-generator-6.26.1.tgz", - "integrity": "sha512-HyfwY6ApZj7BYTcJURpM5tznulaBvyio7/0d4zFOeMPUmfxkCjHocCuoLa2SAGzBI8AREcH3eP3758F672DppA==", - "requires": { - "babel-messages": "^6.23.0", - "babel-runtime": "^6.26.0", - "babel-types": "^6.26.0", - "detect-indent": "^4.0.0", - "jsesc": "^1.3.0", - "lodash": "^4.17.4", - "source-map": "^0.5.7", - "trim-right": "^1.0.1" - }, - "dependencies": { - "jsesc": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-1.3.0.tgz", - "integrity": "sha1-RsP+yMGJKxKwgz25vHYiF226s0s=" - } - } - }, - "babel-helper-bindify-decorators": { - "version": "6.24.1", - "resolved": "https://registry.npmjs.org/babel-helper-bindify-decorators/-/babel-helper-bindify-decorators-6.24.1.tgz", - "integrity": "sha1-FMGeXxQte0fxmlJDHlKxzLxAozA=", - "requires": { - "babel-runtime": "^6.22.0", - "babel-traverse": "^6.24.1", - "babel-types": "^6.24.1" - } - }, - "babel-helper-builder-binary-assignment-operator-visitor": { - "version": "6.24.1", - "resolved": "https://registry.npmjs.org/babel-helper-builder-binary-assignment-operator-visitor/-/babel-helper-builder-binary-assignment-operator-visitor-6.24.1.tgz", - "integrity": "sha1-zORReto1b0IgvK6KAsKzRvmlZmQ=", - "requires": { - "babel-helper-explode-assignable-expression": "^6.24.1", - "babel-runtime": "^6.22.0", - "babel-types": "^6.24.1" - } - }, - "babel-helper-call-delegate": { - "version": "6.24.1", - "resolved": "https://registry.npmjs.org/babel-helper-call-delegate/-/babel-helper-call-delegate-6.24.1.tgz", - "integrity": "sha1-7Oaqzdx25Bw0YfiL/Fdb0Nqi340=", - "requires": { - "babel-helper-hoist-variables": "^6.24.1", - "babel-runtime": "^6.22.0", - "babel-traverse": "^6.24.1", - "babel-types": "^6.24.1" - } - }, - "babel-helper-define-map": { - "version": "6.26.0", - "resolved": "https://registry.npmjs.org/babel-helper-define-map/-/babel-helper-define-map-6.26.0.tgz", - "integrity": "sha1-pfVtq0GiX5fstJjH66ypgZ+Vvl8=", - "requires": { - "babel-helper-function-name": "^6.24.1", - "babel-runtime": "^6.26.0", - "babel-types": "^6.26.0", - "lodash": "^4.17.4" - } - }, - "babel-helper-explode-assignable-expression": { - "version": "6.24.1", - "resolved": "https://registry.npmjs.org/babel-helper-explode-assignable-expression/-/babel-helper-explode-assignable-expression-6.24.1.tgz", - "integrity": "sha1-8luCz33BBDPFX3BZLVdGQArCLKo=", - "requires": { - "babel-runtime": "^6.22.0", - "babel-traverse": "^6.24.1", - "babel-types": "^6.24.1" - } - }, - "babel-helper-explode-class": { - "version": "6.24.1", - "resolved": "https://registry.npmjs.org/babel-helper-explode-class/-/babel-helper-explode-class-6.24.1.tgz", - "integrity": "sha1-fcKjkQ3uAHBW4eMdZAztPVTqqes=", - "requires": { - "babel-helper-bindify-decorators": "^6.24.1", - "babel-runtime": "^6.22.0", - "babel-traverse": "^6.24.1", - "babel-types": "^6.24.1" - } - }, - "babel-helper-function-name": { - "version": "6.24.1", - "resolved": "https://registry.npmjs.org/babel-helper-function-name/-/babel-helper-function-name-6.24.1.tgz", - "integrity": "sha1-00dbjAPtmCQqJbSDUasYOZ01gKk=", - "requires": { - "babel-helper-get-function-arity": "^6.24.1", - "babel-runtime": "^6.22.0", - "babel-template": "^6.24.1", - "babel-traverse": "^6.24.1", - "babel-types": "^6.24.1" - } - }, - "babel-helper-get-function-arity": { - "version": "6.24.1", - "resolved": "https://registry.npmjs.org/babel-helper-get-function-arity/-/babel-helper-get-function-arity-6.24.1.tgz", - "integrity": "sha1-j3eCqpNAfEHTqlCQj4mwMbG2hT0=", - "requires": { - "babel-runtime": "^6.22.0", - "babel-types": "^6.24.1" - } - }, - "babel-helper-hoist-variables": { - "version": "6.24.1", - "resolved": "https://registry.npmjs.org/babel-helper-hoist-variables/-/babel-helper-hoist-variables-6.24.1.tgz", - "integrity": "sha1-HssnaJydJVE+rbyZFKc/VAi+enY=", - "requires": { - "babel-runtime": "^6.22.0", - "babel-types": "^6.24.1" - } - }, - "babel-helper-optimise-call-expression": { - "version": "6.24.1", - "resolved": "https://registry.npmjs.org/babel-helper-optimise-call-expression/-/babel-helper-optimise-call-expression-6.24.1.tgz", - "integrity": "sha1-96E0J7qfc/j0+pk8VKl4gtEkQlc=", - "requires": { - "babel-runtime": "^6.22.0", - "babel-types": "^6.24.1" - } - }, - "babel-helper-regex": { - "version": "6.26.0", - "resolved": "https://registry.npmjs.org/babel-helper-regex/-/babel-helper-regex-6.26.0.tgz", - "integrity": "sha1-MlxZ+QL4LyS3T6zu0DY5VPZJXnI=", - "requires": { - "babel-runtime": "^6.26.0", - "babel-types": "^6.26.0", - "lodash": "^4.17.4" - } - }, - "babel-helper-remap-async-to-generator": { - "version": "6.24.1", - "resolved": "https://registry.npmjs.org/babel-helper-remap-async-to-generator/-/babel-helper-remap-async-to-generator-6.24.1.tgz", - "integrity": "sha1-XsWBgnrXI/7N04HxySg5BnbkVRs=", - "requires": { - "babel-helper-function-name": "^6.24.1", - "babel-runtime": "^6.22.0", - "babel-template": "^6.24.1", - "babel-traverse": "^6.24.1", - "babel-types": "^6.24.1" - } - }, - "babel-helper-replace-supers": { - "version": "6.24.1", - "resolved": "https://registry.npmjs.org/babel-helper-replace-supers/-/babel-helper-replace-supers-6.24.1.tgz", - "integrity": "sha1-v22/5Dk40XNpohPKiov3S2qQqxo=", - "requires": { - "babel-helper-optimise-call-expression": "^6.24.1", - "babel-messages": "^6.23.0", - "babel-runtime": "^6.22.0", - "babel-template": "^6.24.1", - "babel-traverse": "^6.24.1", - "babel-types": "^6.24.1" - } - }, - "babel-helpers": { - "version": "6.24.1", - "resolved": "https://registry.npmjs.org/babel-helpers/-/babel-helpers-6.24.1.tgz", - "integrity": "sha1-NHHenK7DiOXIUOWX5Yom3fN2ArI=", - "requires": { - "babel-runtime": "^6.22.0", - "babel-template": "^6.24.1" - } - }, - "babel-messages": { - "version": "6.23.0", - "resolved": "https://registry.npmjs.org/babel-messages/-/babel-messages-6.23.0.tgz", - "integrity": "sha1-8830cDhYA1sqKVHG7F7fbGLyYw4=", - "requires": { - "babel-runtime": "^6.22.0" - } - }, - "babel-plugin-check-es2015-constants": { - "version": "6.22.0", - "resolved": "https://registry.npmjs.org/babel-plugin-check-es2015-constants/-/babel-plugin-check-es2015-constants-6.22.0.tgz", - "integrity": "sha1-NRV7EBQm/S/9PaP3XH0ekYNbv4o=", - "requires": { - "babel-runtime": "^6.22.0" - } - }, - "babel-plugin-dynamic-import-node": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/babel-plugin-dynamic-import-node/-/babel-plugin-dynamic-import-node-2.3.0.tgz", - "integrity": "sha512-o6qFkpeQEBxcqt0XYlWzAVxNCSCZdUgcR8IRlhD/8DylxjjO4foPcvTW0GGKa/cVt3rvxZ7o5ippJ+/0nvLhlQ==", - "requires": { - "object.assign": "^4.1.0" - } - }, - "babel-plugin-espower": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/babel-plugin-espower/-/babel-plugin-espower-3.0.1.tgz", - "integrity": "sha512-Ms49U7VIAtQ/TtcqRbD6UBmJBUCSxiC3+zPc+eGqxKUIFO1lTshyEDRUjhoAbd2rWfwYf3cZ62oXozrd8W6J0A==", - "requires": { - "@babel/generator": "^7.0.0", - "@babel/parser": "^7.0.0", - "call-matcher": "^1.0.0", - "core-js": "^2.0.0", - "espower-location-detector": "^1.0.0", - "espurify": "^1.6.0", - "estraverse": "^4.1.1" - } - }, - "babel-plugin-external-helpers": { - "version": "6.22.0", - "resolved": "https://registry.npmjs.org/babel-plugin-external-helpers/-/babel-plugin-external-helpers-6.22.0.tgz", - "integrity": "sha1-IoX0iwK9Xe3oUXXK+MYuhq3M76E=", - "requires": { - "babel-runtime": "^6.22.0" - } - }, - "babel-plugin-syntax-async-functions": { - "version": "6.13.0", - "resolved": "https://registry.npmjs.org/babel-plugin-syntax-async-functions/-/babel-plugin-syntax-async-functions-6.13.0.tgz", - "integrity": "sha1-ytnK0RkbWtY0vzCuCHI5HgZHvpU=" - }, - "babel-plugin-syntax-async-generators": { - "version": "6.13.0", - "resolved": "https://registry.npmjs.org/babel-plugin-syntax-async-generators/-/babel-plugin-syntax-async-generators-6.13.0.tgz", - "integrity": "sha1-a8lj67FuzLrmuStZbrfzXDQqi5o=" - }, - "babel-plugin-syntax-class-constructor-call": { - "version": "6.18.0", - "resolved": "https://registry.npmjs.org/babel-plugin-syntax-class-constructor-call/-/babel-plugin-syntax-class-constructor-call-6.18.0.tgz", - "integrity": "sha1-nLnTn+Q8hgC+yBRkVt3L1OGnZBY=" - }, - "babel-plugin-syntax-class-properties": { - "version": "6.13.0", - "resolved": "https://registry.npmjs.org/babel-plugin-syntax-class-properties/-/babel-plugin-syntax-class-properties-6.13.0.tgz", - "integrity": "sha1-1+sjt5oxf4VDlixQW4J8fWysJ94=" - }, - "babel-plugin-syntax-decorators": { - "version": "6.13.0", - "resolved": "https://registry.npmjs.org/babel-plugin-syntax-decorators/-/babel-plugin-syntax-decorators-6.13.0.tgz", - "integrity": "sha1-MSVjtNvePMgGzuPkFszurd0RrAs=" - }, - "babel-plugin-syntax-do-expressions": { - "version": "6.13.0", - "resolved": "https://registry.npmjs.org/babel-plugin-syntax-do-expressions/-/babel-plugin-syntax-do-expressions-6.13.0.tgz", - "integrity": "sha1-V0d1YTmqJtOQ0JQQsDdEugfkeW0=" - }, - "babel-plugin-syntax-dynamic-import": { - "version": "6.18.0", - "resolved": "https://registry.npmjs.org/babel-plugin-syntax-dynamic-import/-/babel-plugin-syntax-dynamic-import-6.18.0.tgz", - "integrity": "sha1-jWomIpyDdFqZgqRBBRVyyqF5sdo=" - }, - "babel-plugin-syntax-exponentiation-operator": { - "version": "6.13.0", - "resolved": "https://registry.npmjs.org/babel-plugin-syntax-exponentiation-operator/-/babel-plugin-syntax-exponentiation-operator-6.13.0.tgz", - "integrity": "sha1-nufoM3KQ2pUoggGmpX9BcDF4MN4=" - }, - "babel-plugin-syntax-export-extensions": { - "version": "6.13.0", - "resolved": "https://registry.npmjs.org/babel-plugin-syntax-export-extensions/-/babel-plugin-syntax-export-extensions-6.13.0.tgz", - "integrity": "sha1-cKFITw+QiaToStRLrDU8lbmxJyE=" - }, - "babel-plugin-syntax-function-bind": { - "version": "6.13.0", - "resolved": "https://registry.npmjs.org/babel-plugin-syntax-function-bind/-/babel-plugin-syntax-function-bind-6.13.0.tgz", - "integrity": "sha1-SMSV8Xe98xqYHnMvVa3AvdJgH0Y=" - }, - "babel-plugin-syntax-object-rest-spread": { - "version": "6.13.0", - "resolved": "https://registry.npmjs.org/babel-plugin-syntax-object-rest-spread/-/babel-plugin-syntax-object-rest-spread-6.13.0.tgz", - "integrity": "sha1-/WU28rzhODb/o6VFjEkDpZe7O/U=" - }, - "babel-plugin-syntax-trailing-function-commas": { - "version": "6.22.0", - "resolved": "https://registry.npmjs.org/babel-plugin-syntax-trailing-function-commas/-/babel-plugin-syntax-trailing-function-commas-6.22.0.tgz", - "integrity": "sha1-ugNgk3+NBuQBgKQ/4NVhb/9TLPM=" - }, - "babel-plugin-transform-async-generator-functions": { - "version": "6.24.1", - "resolved": "https://registry.npmjs.org/babel-plugin-transform-async-generator-functions/-/babel-plugin-transform-async-generator-functions-6.24.1.tgz", - "integrity": "sha1-8FiQAUX9PpkHpt3yjaWfIVJYpds=", - "requires": { - "babel-helper-remap-async-to-generator": "^6.24.1", - "babel-plugin-syntax-async-generators": "^6.5.0", - "babel-runtime": "^6.22.0" - } - }, - "babel-plugin-transform-async-to-generator": { - "version": "6.24.1", - "resolved": "https://registry.npmjs.org/babel-plugin-transform-async-to-generator/-/babel-plugin-transform-async-to-generator-6.24.1.tgz", - "integrity": "sha1-ZTbjeK/2yx1VF6wOQOs+n8jQh2E=", - "requires": { - "babel-helper-remap-async-to-generator": "^6.24.1", - "babel-plugin-syntax-async-functions": "^6.8.0", - "babel-runtime": "^6.22.0" - } - }, - "babel-plugin-transform-class-constructor-call": { - "version": "6.24.1", - "resolved": "https://registry.npmjs.org/babel-plugin-transform-class-constructor-call/-/babel-plugin-transform-class-constructor-call-6.24.1.tgz", - "integrity": "sha1-gNwoVQWsBn3LjWxl4vbxGrd2Xvk=", - "requires": { - "babel-plugin-syntax-class-constructor-call": "^6.18.0", - "babel-runtime": "^6.22.0", - "babel-template": "^6.24.1" - } - }, - "babel-plugin-transform-class-properties": { - "version": "6.24.1", - "resolved": "https://registry.npmjs.org/babel-plugin-transform-class-properties/-/babel-plugin-transform-class-properties-6.24.1.tgz", - "integrity": "sha1-anl2PqYdM9NvN7YRqp3vgagbRqw=", - "requires": { - "babel-helper-function-name": "^6.24.1", - "babel-plugin-syntax-class-properties": "^6.8.0", - "babel-runtime": "^6.22.0", - "babel-template": "^6.24.1" - } - }, - "babel-plugin-transform-decorators": { - "version": "6.24.1", - "resolved": "https://registry.npmjs.org/babel-plugin-transform-decorators/-/babel-plugin-transform-decorators-6.24.1.tgz", - "integrity": "sha1-eIAT2PjGtSIr33s0Q5Df13Vp4k0=", - "requires": { - "babel-helper-explode-class": "^6.24.1", - "babel-plugin-syntax-decorators": "^6.13.0", - "babel-runtime": "^6.22.0", - "babel-template": "^6.24.1", - "babel-types": "^6.24.1" - } - }, - "babel-plugin-transform-do-expressions": { - "version": "6.22.0", - "resolved": "https://registry.npmjs.org/babel-plugin-transform-do-expressions/-/babel-plugin-transform-do-expressions-6.22.0.tgz", - "integrity": "sha1-KMyvkoEtlJws0SgfaQyP3EaK6bs=", - "requires": { - "babel-plugin-syntax-do-expressions": "^6.8.0", - "babel-runtime": "^6.22.0" - } - }, - "babel-plugin-transform-es2015-arrow-functions": { - "version": "6.22.0", - "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-arrow-functions/-/babel-plugin-transform-es2015-arrow-functions-6.22.0.tgz", - "integrity": "sha1-RSaSy3EdX3ncf4XkQM5BufJE0iE=", - "requires": { - "babel-runtime": "^6.22.0" - } - }, - "babel-plugin-transform-es2015-block-scoped-functions": { - "version": "6.22.0", - "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-block-scoped-functions/-/babel-plugin-transform-es2015-block-scoped-functions-6.22.0.tgz", - "integrity": "sha1-u8UbSflk1wy42OC5ToICRs46YUE=", - "requires": { - "babel-runtime": "^6.22.0" - } - }, - "babel-plugin-transform-es2015-block-scoping": { - "version": "6.26.0", - "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-block-scoping/-/babel-plugin-transform-es2015-block-scoping-6.26.0.tgz", - "integrity": "sha1-1w9SmcEwjQXBL0Y4E7CgnnOxiV8=", - "requires": { - "babel-runtime": "^6.26.0", - "babel-template": "^6.26.0", - "babel-traverse": "^6.26.0", - "babel-types": "^6.26.0", - "lodash": "^4.17.4" - } - }, - "babel-plugin-transform-es2015-classes": { - "version": "6.24.1", - "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-classes/-/babel-plugin-transform-es2015-classes-6.24.1.tgz", - "integrity": "sha1-WkxYpQyclGHlZLSyo7+ryXolhNs=", - "requires": { - "babel-helper-define-map": "^6.24.1", - "babel-helper-function-name": "^6.24.1", - "babel-helper-optimise-call-expression": "^6.24.1", - "babel-helper-replace-supers": "^6.24.1", - "babel-messages": "^6.23.0", - "babel-runtime": "^6.22.0", - "babel-template": "^6.24.1", - "babel-traverse": "^6.24.1", - "babel-types": "^6.24.1" - } - }, - "babel-plugin-transform-es2015-computed-properties": { - "version": "6.24.1", - "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-computed-properties/-/babel-plugin-transform-es2015-computed-properties-6.24.1.tgz", - "integrity": "sha1-b+Ko0WiV1WNPTNmZttNICjCBWbM=", - "requires": { - "babel-runtime": "^6.22.0", - "babel-template": "^6.24.1" - } - }, - "babel-plugin-transform-es2015-destructuring": { - "version": "6.23.0", - "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-destructuring/-/babel-plugin-transform-es2015-destructuring-6.23.0.tgz", - "integrity": "sha1-mXux8auWf2gtKwh2/jWNYOdlxW0=", - "requires": { - "babel-runtime": "^6.22.0" - } - }, - "babel-plugin-transform-es2015-duplicate-keys": { - "version": "6.24.1", - "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-duplicate-keys/-/babel-plugin-transform-es2015-duplicate-keys-6.24.1.tgz", - "integrity": "sha1-c+s9MQypaePvnskcU3QabxV2Qj4=", - "requires": { - "babel-runtime": "^6.22.0", - "babel-types": "^6.24.1" - } - }, - "babel-plugin-transform-es2015-for-of": { - "version": "6.23.0", - "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-for-of/-/babel-plugin-transform-es2015-for-of-6.23.0.tgz", - "integrity": "sha1-9HyVsrYT3x0+zC/bdXNiPHUkhpE=", - "requires": { - "babel-runtime": "^6.22.0" - } - }, - "babel-plugin-transform-es2015-function-name": { - "version": "6.24.1", - "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-function-name/-/babel-plugin-transform-es2015-function-name-6.24.1.tgz", - "integrity": "sha1-g0yJhTvDaxrw86TF26qU/Y6sqos=", - "requires": { - "babel-helper-function-name": "^6.24.1", - "babel-runtime": "^6.22.0", - "babel-types": "^6.24.1" - } - }, - "babel-plugin-transform-es2015-literals": { - "version": "6.22.0", - "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-literals/-/babel-plugin-transform-es2015-literals-6.22.0.tgz", - "integrity": "sha1-T1SgLWzWbPkVKAAZox0xklN3yi4=", - "requires": { - "babel-runtime": "^6.22.0" - } - }, - "babel-plugin-transform-es2015-modules-amd": { - "version": "6.24.1", - "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-modules-amd/-/babel-plugin-transform-es2015-modules-amd-6.24.1.tgz", - "integrity": "sha1-Oz5UAXI5hC1tGcMBHEvS8AoA0VQ=", - "requires": { - "babel-plugin-transform-es2015-modules-commonjs": "^6.24.1", - "babel-runtime": "^6.22.0", - "babel-template": "^6.24.1" - } - }, - "babel-plugin-transform-es2015-modules-commonjs": { - "version": "6.26.2", - "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-modules-commonjs/-/babel-plugin-transform-es2015-modules-commonjs-6.26.2.tgz", - "integrity": "sha512-CV9ROOHEdrjcwhIaJNBGMBCodN+1cfkwtM1SbUHmvyy35KGT7fohbpOxkE2uLz1o6odKK2Ck/tz47z+VqQfi9Q==", - "requires": { - "babel-plugin-transform-strict-mode": "^6.24.1", - "babel-runtime": "^6.26.0", - "babel-template": "^6.26.0", - "babel-types": "^6.26.0" - } - }, - "babel-plugin-transform-es2015-modules-systemjs": { - "version": "6.24.1", - "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-modules-systemjs/-/babel-plugin-transform-es2015-modules-systemjs-6.24.1.tgz", - "integrity": "sha1-/4mhQrkRmpBhlfXxBuzzBdlAfSM=", - "requires": { - "babel-helper-hoist-variables": "^6.24.1", - "babel-runtime": "^6.22.0", - "babel-template": "^6.24.1" - } - }, - "babel-plugin-transform-es2015-modules-umd": { - "version": "6.24.1", - "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-modules-umd/-/babel-plugin-transform-es2015-modules-umd-6.24.1.tgz", - "integrity": "sha1-rJl+YoXNGO1hdq22B9YCNErThGg=", - "requires": { - "babel-plugin-transform-es2015-modules-amd": "^6.24.1", - "babel-runtime": "^6.22.0", - "babel-template": "^6.24.1" - } - }, - "babel-plugin-transform-es2015-object-super": { - "version": "6.24.1", - "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-object-super/-/babel-plugin-transform-es2015-object-super-6.24.1.tgz", - "integrity": "sha1-JM72muIcuDp/hgPa0CH1cusnj40=", - "requires": { - "babel-helper-replace-supers": "^6.24.1", - "babel-runtime": "^6.22.0" - } - }, - "babel-plugin-transform-es2015-parameters": { - "version": "6.24.1", - "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-parameters/-/babel-plugin-transform-es2015-parameters-6.24.1.tgz", - "integrity": "sha1-V6w1GrScrxSpfNE7CfZv3wpiXys=", - "requires": { - "babel-helper-call-delegate": "^6.24.1", - "babel-helper-get-function-arity": "^6.24.1", - "babel-runtime": "^6.22.0", - "babel-template": "^6.24.1", - "babel-traverse": "^6.24.1", - "babel-types": "^6.24.1" - } - }, - "babel-plugin-transform-es2015-shorthand-properties": { - "version": "6.24.1", - "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-shorthand-properties/-/babel-plugin-transform-es2015-shorthand-properties-6.24.1.tgz", - "integrity": "sha1-JPh11nIch2YbvZmkYi5R8U3jiqA=", - "requires": { - "babel-runtime": "^6.22.0", - "babel-types": "^6.24.1" - } - }, - "babel-plugin-transform-es2015-spread": { - "version": "6.22.0", - "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-spread/-/babel-plugin-transform-es2015-spread-6.22.0.tgz", - "integrity": "sha1-1taKmfia7cRTbIGlQujdnxdG+NE=", - "requires": { - "babel-runtime": "^6.22.0" - } - }, - "babel-plugin-transform-es2015-sticky-regex": { - "version": "6.24.1", - "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-sticky-regex/-/babel-plugin-transform-es2015-sticky-regex-6.24.1.tgz", - "integrity": "sha1-AMHNsaynERLN8M9hJsLta0V8zbw=", - "requires": { - "babel-helper-regex": "^6.24.1", - "babel-runtime": "^6.22.0", - "babel-types": "^6.24.1" - } - }, - "babel-plugin-transform-es2015-template-literals": { - "version": "6.22.0", - "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-template-literals/-/babel-plugin-transform-es2015-template-literals-6.22.0.tgz", - "integrity": "sha1-qEs0UPfp+PH2g51taH2oS7EjbY0=", - "requires": { - "babel-runtime": "^6.22.0" - } - }, - "babel-plugin-transform-es2015-typeof-symbol": { - "version": "6.23.0", - "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-typeof-symbol/-/babel-plugin-transform-es2015-typeof-symbol-6.23.0.tgz", - "integrity": "sha1-3sCfHN3/lLUqxz1QXITfWdzOs3I=", - "requires": { - "babel-runtime": "^6.22.0" - } - }, - "babel-plugin-transform-es2015-unicode-regex": { - "version": "6.24.1", - "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-unicode-regex/-/babel-plugin-transform-es2015-unicode-regex-6.24.1.tgz", - "integrity": "sha1-04sS9C6nMj9yk4fxinxa4frrNek=", - "requires": { - "babel-helper-regex": "^6.24.1", - "babel-runtime": "^6.22.0", - "regexpu-core": "^2.0.0" - } - }, - "babel-plugin-transform-exponentiation-operator": { - "version": "6.24.1", - "resolved": "https://registry.npmjs.org/babel-plugin-transform-exponentiation-operator/-/babel-plugin-transform-exponentiation-operator-6.24.1.tgz", - "integrity": "sha1-KrDJx/MJj6SJB3cruBP+QejeOg4=", - "requires": { - "babel-helper-builder-binary-assignment-operator-visitor": "^6.24.1", - "babel-plugin-syntax-exponentiation-operator": "^6.8.0", - "babel-runtime": "^6.22.0" - } - }, - "babel-plugin-transform-export-extensions": { - "version": "6.22.0", - "resolved": "https://registry.npmjs.org/babel-plugin-transform-export-extensions/-/babel-plugin-transform-export-extensions-6.22.0.tgz", - "integrity": "sha1-U3OLR+deghhYnuqUbLvTkQm75lM=", - "requires": { - "babel-plugin-syntax-export-extensions": "^6.8.0", - "babel-runtime": "^6.22.0" - } - }, - "babel-plugin-transform-function-bind": { - "version": "6.22.0", - "resolved": "https://registry.npmjs.org/babel-plugin-transform-function-bind/-/babel-plugin-transform-function-bind-6.22.0.tgz", - "integrity": "sha1-xvuOlqwpajELjPjqQBRiQH3fapc=", - "requires": { - "babel-plugin-syntax-function-bind": "^6.8.0", - "babel-runtime": "^6.22.0" - } - }, - "babel-plugin-transform-object-rest-spread": { - "version": "6.26.0", - "resolved": "https://registry.npmjs.org/babel-plugin-transform-object-rest-spread/-/babel-plugin-transform-object-rest-spread-6.26.0.tgz", - "integrity": "sha1-DzZpLVD+9rfi1LOsFHgTepY7ewY=", - "requires": { - "babel-plugin-syntax-object-rest-spread": "^6.8.0", - "babel-runtime": "^6.26.0" - } - }, - "babel-plugin-transform-regenerator": { - "version": "6.26.0", - "resolved": "https://registry.npmjs.org/babel-plugin-transform-regenerator/-/babel-plugin-transform-regenerator-6.26.0.tgz", - "integrity": "sha1-4HA2lvveJ/Cj78rPi03KL3s6jy8=", - "requires": { - "regenerator-transform": "^0.10.0" - } - }, - "babel-plugin-transform-strict-mode": { - "version": "6.24.1", - "resolved": "https://registry.npmjs.org/babel-plugin-transform-strict-mode/-/babel-plugin-transform-strict-mode-6.24.1.tgz", - "integrity": "sha1-1fr3qleKZbvlkc9e2uBKDGcCB1g=", - "requires": { - "babel-runtime": "^6.22.0", - "babel-types": "^6.24.1" - } - }, - "babel-preset-es2015": { - "version": "6.24.1", - "resolved": "https://registry.npmjs.org/babel-preset-es2015/-/babel-preset-es2015-6.24.1.tgz", - "integrity": "sha1-1EBQ1rwsn+6nAqrzjXJ6AhBTiTk=", - "requires": { - "babel-plugin-check-es2015-constants": "^6.22.0", - "babel-plugin-transform-es2015-arrow-functions": "^6.22.0", - "babel-plugin-transform-es2015-block-scoped-functions": "^6.22.0", - "babel-plugin-transform-es2015-block-scoping": "^6.24.1", - "babel-plugin-transform-es2015-classes": "^6.24.1", - "babel-plugin-transform-es2015-computed-properties": "^6.24.1", - "babel-plugin-transform-es2015-destructuring": "^6.22.0", - "babel-plugin-transform-es2015-duplicate-keys": "^6.24.1", - "babel-plugin-transform-es2015-for-of": "^6.22.0", - "babel-plugin-transform-es2015-function-name": "^6.24.1", - "babel-plugin-transform-es2015-literals": "^6.22.0", - "babel-plugin-transform-es2015-modules-amd": "^6.24.1", - "babel-plugin-transform-es2015-modules-commonjs": "^6.24.1", - "babel-plugin-transform-es2015-modules-systemjs": "^6.24.1", - "babel-plugin-transform-es2015-modules-umd": "^6.24.1", - "babel-plugin-transform-es2015-object-super": "^6.24.1", - "babel-plugin-transform-es2015-parameters": "^6.24.1", - "babel-plugin-transform-es2015-shorthand-properties": "^6.24.1", - "babel-plugin-transform-es2015-spread": "^6.22.0", - "babel-plugin-transform-es2015-sticky-regex": "^6.24.1", - "babel-plugin-transform-es2015-template-literals": "^6.22.0", - "babel-plugin-transform-es2015-typeof-symbol": "^6.22.0", - "babel-plugin-transform-es2015-unicode-regex": "^6.24.1", - "babel-plugin-transform-regenerator": "^6.24.1" - } - }, - "babel-preset-stage-0": { - "version": "6.24.1", - "resolved": "https://registry.npmjs.org/babel-preset-stage-0/-/babel-preset-stage-0-6.24.1.tgz", - "integrity": "sha1-VkLRUEL5E4TX5a+LyIsduVsDnmo=", - "requires": { - "babel-plugin-transform-do-expressions": "^6.22.0", - "babel-plugin-transform-function-bind": "^6.22.0", - "babel-preset-stage-1": "^6.24.1" - } - }, - "babel-preset-stage-1": { - "version": "6.24.1", - "resolved": "https://registry.npmjs.org/babel-preset-stage-1/-/babel-preset-stage-1-6.24.1.tgz", - "integrity": "sha1-dpLNfc1oSZB+auSgqFWJz7niv7A=", - "requires": { - "babel-plugin-transform-class-constructor-call": "^6.24.1", - "babel-plugin-transform-export-extensions": "^6.22.0", - "babel-preset-stage-2": "^6.24.1" - } - }, - "babel-preset-stage-2": { - "version": "6.24.1", - "resolved": "https://registry.npmjs.org/babel-preset-stage-2/-/babel-preset-stage-2-6.24.1.tgz", - "integrity": "sha1-2eKWD7PXEYfw5k7sYrwHdnIZvcE=", - "requires": { - "babel-plugin-syntax-dynamic-import": "^6.18.0", - "babel-plugin-transform-class-properties": "^6.24.1", - "babel-plugin-transform-decorators": "^6.24.1", - "babel-preset-stage-3": "^6.24.1" - } - }, - "babel-preset-stage-3": { - "version": "6.24.1", - "resolved": "https://registry.npmjs.org/babel-preset-stage-3/-/babel-preset-stage-3-6.24.1.tgz", - "integrity": "sha1-g2raCp56f6N8sTj7kyb4eTSkg5U=", - "requires": { - "babel-plugin-syntax-trailing-function-commas": "^6.22.0", - "babel-plugin-transform-async-generator-functions": "^6.24.1", - "babel-plugin-transform-async-to-generator": "^6.24.1", - "babel-plugin-transform-exponentiation-operator": "^6.24.1", - "babel-plugin-transform-object-rest-spread": "^6.22.0" - } - }, - "babel-register": { - "version": "6.26.0", - "resolved": "https://registry.npmjs.org/babel-register/-/babel-register-6.26.0.tgz", - "integrity": "sha1-btAhFz4vy0htestFxgCahW9kcHE=", - "requires": { - "babel-core": "^6.26.0", - "babel-runtime": "^6.26.0", - "core-js": "^2.5.0", - "home-or-tmp": "^2.0.0", - "lodash": "^4.17.4", - "mkdirp": "^0.5.1", - "source-map-support": "^0.4.15" - } - }, - "babel-runtime": { - "version": "6.26.0", - "resolved": "https://registry.npmjs.org/babel-runtime/-/babel-runtime-6.26.0.tgz", - "integrity": "sha1-llxwWGaOgrVde/4E/yM3vItWR/4=", - "requires": { - "core-js": "^2.4.0", - "regenerator-runtime": "^0.11.0" - } - }, - "babel-template": { - "version": "6.26.0", - "resolved": "https://registry.npmjs.org/babel-template/-/babel-template-6.26.0.tgz", - "integrity": "sha1-3gPi0WOWsGn0bdn/+FIfsaDjXgI=", - "requires": { - "babel-runtime": "^6.26.0", - "babel-traverse": "^6.26.0", - "babel-types": "^6.26.0", - "babylon": "^6.18.0", - "lodash": "^4.17.4" - } - }, - "babel-traverse": { - "version": "6.26.0", - "resolved": "https://registry.npmjs.org/babel-traverse/-/babel-traverse-6.26.0.tgz", - "integrity": "sha1-RqnL1+3MYsjlwGTi0tjQ9ANXZu4=", - "requires": { - "babel-code-frame": "^6.26.0", - "babel-messages": "^6.23.0", - "babel-runtime": "^6.26.0", - "babel-types": "^6.26.0", - "babylon": "^6.18.0", - "debug": "^2.6.8", - "globals": "^9.18.0", - "invariant": "^2.2.2", - "lodash": "^4.17.4" - } - }, - "babel-types": { - "version": "6.26.0", - "resolved": "https://registry.npmjs.org/babel-types/-/babel-types-6.26.0.tgz", - "integrity": "sha1-o7Bz+Uq0nrb6Vc1lInozQ4BjJJc=", - "requires": { - "babel-runtime": "^6.26.0", - "esutils": "^2.0.2", - "lodash": "^4.17.4", - "to-fast-properties": "^1.0.3" - } - }, - "babelify": { - "version": "7.3.0", - "resolved": "https://registry.npmjs.org/babelify/-/babelify-7.3.0.tgz", - "integrity": "sha1-qlau3nBn/XvVSWZu4W3ChQh+iOU=", - "requires": { - "babel-core": "^6.0.14", - "object-assign": "^4.0.0" - } - }, - "babylon": { - "version": "6.18.0", - "resolved": "https://registry.npmjs.org/babylon/-/babylon-6.18.0.tgz", - "integrity": "sha1-ry87iPpvXB5MY00aD46sT1WzleM=" - }, - "balanced-match": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", - "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=" - }, - "base": { - "version": "0.11.2", - "resolved": "https://registry.npmjs.org/base/-/base-0.11.2.tgz", - "integrity": "sha512-5T6P4xPgpp0YDFvSWwEZ4NoE3aM4QBQXDzmVbraCkFj8zHM+mba8SyqB5DbZWyR7mYHo6Y7BdQo3MoA4m0TeQg==", - "requires": { - "cache-base": "^1.0.1", - "class-utils": "^0.3.5", - "component-emitter": "^1.2.1", - "define-property": "^1.0.0", - "isobject": "^3.0.1", - "mixin-deep": "^1.2.0", - "pascalcase": "^0.1.1" - }, - "dependencies": { - "define-property": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", - "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", - "requires": { - "is-descriptor": "^1.0.0" - } - }, - "is-accessor-descriptor": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", - "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", - "requires": { - "kind-of": "^6.0.0" - } - }, - "is-data-descriptor": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", - "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", - "requires": { - "kind-of": "^6.0.0" - } - }, - "is-descriptor": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", - "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", - "requires": { - "is-accessor-descriptor": "^1.0.0", - "is-data-descriptor": "^1.0.0", - "kind-of": "^6.0.2" - } - }, - "is-extendable": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-1.0.1.tgz", - "integrity": "sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==", - "requires": { - "is-plain-object": "^2.0.4" - } - }, - "isobject": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", - "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=" - }, - "kind-of": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz", - "integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==" - }, - "mixin-deep": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/mixin-deep/-/mixin-deep-1.3.2.tgz", - "integrity": "sha512-WRoDn//mXBiJ1H40rqa3vH0toePwSsGb45iInWlTySa+Uu4k3tYUSxa2v1KqAiLtvlrSzaExqS1gtk96A9zvEA==", - "requires": { - "for-in": "^1.0.2", - "is-extendable": "^1.0.1" - } - } - } - }, - "base64-js": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.3.0.tgz", - "integrity": "sha512-ccav/yGvoa80BQDljCxsmmQ3Xvx60/UpBIij5QN21W3wBi/hhIC9OoO+KLpu9IJTS9j4DRVJ3aDDF9cMSoa2lw==" - }, - "bignumber.js": { - "version": "7.2.1", - "resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-7.2.1.tgz", - "integrity": "sha512-S4XzBk5sMB+Rcb/LNcpzXr57VRTxgAvaAEDAl1AwRx27j00hT84O6OkteE7u8UB3NuaaygCRrEpqox4uDOrbdQ==" - }, - "binary-extensions": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.0.0.tgz", - "integrity": "sha512-Phlt0plgpIIBOGTT/ehfFnbNlfsDEiqmzE2KRXoX1bLIlir4X/MR+zSyBEkL05ffWgnRSf/DXv+WrUAVr93/ow==" - }, - "bluebird": { - "version": "3.5.5", - "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.5.tgz", - "integrity": "sha512-5am6HnnfN+urzt4yfg7IgTbotDjIT/u8AJpEt0sIU9FtXfVeezXAPKswrG+xKUCOYAINpSdgZVDU6QFh+cuH3w==" - }, - "blueimp-md5": { - "version": "2.11.0", - "resolved": "https://registry.npmjs.org/blueimp-md5/-/blueimp-md5-2.11.0.tgz", - "integrity": "sha512-xvA4mdnIevstCvNKTRLMOKi7L76U/X/CTs9Yz+PLWmWAC/7SuYi5Xv2J7bAhJnE2+LcLv+x4+0vusvKgM9LnZQ==" - }, - "bn.js": { - "version": "4.11.8", - "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.8.tgz", - "integrity": "sha1-LN4J617jQfSEdGuwMJsyU7GxRC8=" - }, - "body-parser": { - "version": "1.18.2", - "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.18.2.tgz", - "integrity": "sha1-h2eKGdhLR9hZuDGZvVm84iKxBFQ=", - "requires": { - "bytes": "3.0.0", - "content-type": "~1.0.4", - "debug": "2.6.9", - "depd": "~1.1.1", - "http-errors": "~1.6.2", - "iconv-lite": "0.4.19", - "on-finished": "~2.3.0", - "qs": "6.5.1", - "raw-body": "2.3.2", - "type-is": "~1.6.15" - } - }, - "boxen": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/boxen/-/boxen-3.2.0.tgz", - "integrity": "sha512-cU4J/+NodM3IHdSL2yN8bqYqnmlBTidDR4RC7nJs61ZmtGz8VZzM3HLQX0zY5mrSmPtR3xWwsq2jOUQqFZN8+A==", - "requires": { - "ansi-align": "^3.0.0", - "camelcase": "^5.3.1", - "chalk": "^2.4.2", - "cli-boxes": "^2.2.0", - "string-width": "^3.0.0", - "term-size": "^1.2.0", - "type-fest": "^0.3.0", - "widest-line": "^2.0.0" - }, - "dependencies": { - "ansi-regex": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", - "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==" - }, - "camelcase": { - "version": "5.3.1", - "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz", - "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==" - }, - "chalk": { - "version": "2.4.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", - "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", - "requires": { - "ansi-styles": "^3.2.1", - "escape-string-regexp": "^1.0.5", - "supports-color": "^5.3.0" - } - }, - "string-width": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz", - "integrity": "sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w==", - "requires": { - "emoji-regex": "^7.0.1", - "is-fullwidth-code-point": "^2.0.0", - "strip-ansi": "^5.1.0" - } - }, - "strip-ansi": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", - "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", - "requires": { - "ansi-regex": "^4.1.0" - } - }, - "supports-color": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", - "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", - "requires": { - "has-flag": "^3.0.0" - } - }, - "type-fest": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.3.1.tgz", - "integrity": "sha512-cUGJnCdr4STbePCgqNFbpVNCepa+kAVohJs1sLhxzdH+gnEoOd8VhbYa7pD3zZYGiURWM2xzEII3fQcRizDkYQ==" - } - } - }, - "brace-expansion": { - "version": "1.1.11", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", - "requires": { - "balanced-match": "^1.0.0", - "concat-map": "0.0.1" - } - }, - "braces": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/braces/-/braces-2.3.2.tgz", - "integrity": "sha512-aNdbnj9P8PjdXU4ybaWLK2IF3jc/EoDYbC7AazW6to3TRsfXxscC9UXOB5iDiEQrkyIbWp2SLQda4+QAa7nc3w==", - "requires": { - "arr-flatten": "^1.1.0", - "array-unique": "^0.3.2", - "extend-shallow": "^2.0.1", - "fill-range": "^4.0.0", - "isobject": "^3.0.1", - "repeat-element": "^1.1.2", - "snapdragon": "^0.8.1", - "snapdragon-node": "^2.0.1", - "split-string": "^3.0.2", - "to-regex": "^3.0.1" - }, - "dependencies": { - "array-unique": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.3.2.tgz", - "integrity": "sha1-qJS3XUvE9s1nnvMkSp/Y9Gri1Cg=" - }, - "extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "requires": { - "is-extendable": "^0.1.0" - } - } - } - }, - "brorand": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/brorand/-/brorand-1.1.0.tgz", - "integrity": "sha1-EsJe/kCkXjwyPrhnWgoM5XsiNx8=" - }, - "browser-pack": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/browser-pack/-/browser-pack-6.1.0.tgz", - "integrity": "sha512-erYug8XoqzU3IfcU8fUgyHqyOXqIE4tUTTQ+7mqUjQlvnXkOO6OlT9c/ZoJVHYoAaqGxr09CN53G7XIsO4KtWA==", - "requires": { - "JSONStream": "^1.0.3", - "combine-source-map": "~0.8.0", - "defined": "^1.0.0", - "safe-buffer": "^5.1.1", - "through2": "^2.0.0", - "umd": "^3.0.0" - } - }, - "browser-resolve": { - "version": "1.11.2", - "resolved": "https://registry.npmjs.org/browser-resolve/-/browser-resolve-1.11.2.tgz", - "integrity": "sha1-j/CbCixCFxihBRwmCzLkj0QpOM4=", - "requires": { - "resolve": "1.1.7" - }, - "dependencies": { - "resolve": { - "version": "1.1.7", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.1.7.tgz", - "integrity": "sha1-IDEU2CrSxe2ejgQRs5ModeiJ6Xs=" - } - } - }, - "browserify": { - "version": "14.5.0", - "resolved": "https://registry.npmjs.org/browserify/-/browserify-14.5.0.tgz", - "integrity": "sha1-C7vOUhrNbk0dVNjpNlAI77hanMU=", - "requires": { - "JSONStream": "^1.0.3", - "assert": "^1.4.0", - "browser-pack": "^6.0.1", - "browser-resolve": "^1.11.0", - "browserify-zlib": "~0.2.0", - "buffer": "^5.0.2", - "cached-path-relative": "^1.0.0", - "concat-stream": "~1.5.1", - "console-browserify": "^1.1.0", - "constants-browserify": "~1.0.0", - "crypto-browserify": "^3.0.0", - "defined": "^1.0.0", - "deps-sort": "^2.0.0", - "domain-browser": "~1.1.0", - "duplexer2": "~0.1.2", - "events": "~1.1.0", - "glob": "^7.1.0", - "has": "^1.0.0", - "htmlescape": "^1.1.0", - "https-browserify": "^1.0.0", - "inherits": "~2.0.1", - "insert-module-globals": "^7.0.0", - "labeled-stream-splicer": "^2.0.0", - "module-deps": "^4.0.8", - "os-browserify": "~0.3.0", - "parents": "^1.0.1", - "path-browserify": "~0.0.0", - "process": "~0.11.0", - "punycode": "^1.3.2", - "querystring-es3": "~0.2.0", - "read-only-stream": "^2.0.0", - "readable-stream": "^2.0.2", - "resolve": "^1.1.4", - "shasum": "^1.0.0", - "shell-quote": "^1.6.1", - "stream-browserify": "^2.0.0", - "stream-http": "^2.0.0", - "string_decoder": "~1.0.0", - "subarg": "^1.0.0", - "syntax-error": "^1.1.1", - "through2": "^2.0.0", - "timers-browserify": "^1.0.1", - "tty-browserify": "~0.0.0", - "url": "~0.11.0", - "util": "~0.10.1", - "vm-browserify": "~0.0.1", - "xtend": "^4.0.0" - }, - "dependencies": { - "string_decoder": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", - "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", - "requires": { - "safe-buffer": "~5.1.0" - } - } - } - }, - "browserify-aes": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/browserify-aes/-/browserify-aes-1.2.0.tgz", - "integrity": "sha512-+7CHXqGuspUn/Sl5aO7Ea0xWGAtETPXNSAjHo48JfLdPWcMng33Xe4znFvQweqc/uzk5zSOI3H52CYnjCfb5hA==", - "requires": { - "buffer-xor": "^1.0.3", - "cipher-base": "^1.0.0", - "create-hash": "^1.1.0", - "evp_bytestokey": "^1.0.3", - "inherits": "^2.0.1", - "safe-buffer": "^5.0.1" - } - }, - "browserify-cipher": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/browserify-cipher/-/browserify-cipher-1.0.1.tgz", - "integrity": "sha512-sPhkz0ARKbf4rRQt2hTpAHqn47X3llLkUGn+xEJzLjwY8LRs2p0v7ljvI5EyoRO/mexrNunNECisZs+gw2zz1w==", - "requires": { - "browserify-aes": "^1.0.4", - "browserify-des": "^1.0.0", - "evp_bytestokey": "^1.0.0" - } - }, - "browserify-des": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/browserify-des/-/browserify-des-1.0.1.tgz", - "integrity": "sha512-zy0Cobe3hhgpiOM32Tj7KQ3Vl91m0njwsjzZQK1L+JDf11dzP9qIvjreVinsvXrgfjhStXwUWAEpB9D7Gwmayw==", - "requires": { - "cipher-base": "^1.0.1", - "des.js": "^1.0.0", - "inherits": "^2.0.1" - } - }, - "browserify-rsa": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/browserify-rsa/-/browserify-rsa-4.0.1.tgz", - "integrity": "sha1-IeCr+vbyApzy+vsTNWenAdQTVSQ=", - "requires": { - "bn.js": "^4.1.0", - "randombytes": "^2.0.1" - } - }, - "browserify-shim": { - "version": "3.8.14", - "resolved": "https://registry.npmjs.org/browserify-shim/-/browserify-shim-3.8.14.tgz", - "integrity": "sha1-vxBXAmky0yU8de991xTzuHft7Gs=", - "requires": { - "exposify": "~0.5.0", - "mothership": "~0.2.0", - "rename-function-calls": "~0.1.0", - "resolve": "~0.6.1", - "through": "~2.3.4" - }, - "dependencies": { - "resolve": { - "version": "0.6.3", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-0.6.3.tgz", - "integrity": "sha1-3ZV5gufnNt699TtYpN2RdUV13UY=" - } - } - }, - "browserify-sign": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/browserify-sign/-/browserify-sign-4.0.4.tgz", - "integrity": "sha1-qk62jl17ZYuqa/alfmMMvXqT0pg=", - "requires": { - "bn.js": "^4.1.1", - "browserify-rsa": "^4.0.0", - "create-hash": "^1.1.0", - "create-hmac": "^1.1.2", - "elliptic": "^6.0.0", - "inherits": "^2.0.1", - "parse-asn1": "^5.0.0" - } - }, - "browserify-zlib": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/browserify-zlib/-/browserify-zlib-0.2.0.tgz", - "integrity": "sha1-KGlFnZqjviRf6P4sofRuLn9U1z8=", - "requires": { - "pako": "~1.0.5" - } - }, - "buffer": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.1.0.tgz", - "integrity": "sha512-YkIRgwsZwJWTnyQrsBTWefizHh+8GYj3kbL1BTiAQ/9pwpino0G7B2gp5tx/FUBqUlvtxV85KNR3mwfAtv15Yw==", - "requires": { - "base64-js": "^1.0.2", - "ieee754": "^1.1.4" - } - }, - "buffer-from": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.0.0.tgz", - "integrity": "sha512-83apNb8KK0Se60UE1+4Ukbe3HbfELJ6UlI4ldtOGs7So4KD26orJM8hIY9lxdzP+UpItH1Yh/Y8GUvNFWFFRxA==" - }, - "buffer-xor": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/buffer-xor/-/buffer-xor-1.0.3.tgz", - "integrity": "sha1-JuYe0UIvtw3ULm42cp7VHYVf6Nk=" - }, - "builtin-modules": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-1.1.1.tgz", - "integrity": "sha1-Jw8HbFpywC9bZaR9+Uxf46J4iS8=" - }, - "builtin-status-codes": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/builtin-status-codes/-/builtin-status-codes-3.0.0.tgz", - "integrity": "sha1-hZgoeOIbmOHGZCXgPQF0eI9Wnug=" - }, - "byline": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/byline/-/byline-5.0.0.tgz", - "integrity": "sha1-dBxSFkaOrcRXsDQQEYrXfejB3bE=" - }, - "bytes": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.0.0.tgz", - "integrity": "sha1-0ygVQE1olpn4Wk6k+odV3ROpYEg=" - }, - "cache-base": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/cache-base/-/cache-base-1.0.1.tgz", - "integrity": "sha512-AKcdTnFSWATd5/GCPRxr2ChwIJ85CeyrEyjRHlKxQ56d4XJMGym0uAiKn0xbLOGOl3+yRpOTi484dVCEc5AUzQ==", - "requires": { - "collection-visit": "^1.0.0", - "component-emitter": "^1.2.1", - "get-value": "^2.0.6", - "has-value": "^1.0.0", - "isobject": "^3.0.1", - "set-value": "^2.0.0", - "to-object-path": "^0.3.0", - "union-value": "^1.0.0", - "unset-value": "^1.0.0" - }, - "dependencies": { - "extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "requires": { - "is-extendable": "^0.1.0" - } - }, - "isobject": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", - "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=" - }, - "set-value": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/set-value/-/set-value-2.0.1.tgz", - "integrity": "sha512-JxHc1weCN68wRY0fhCoXpyK55m/XPHafOmK4UWD7m2CI14GMcFypt4w/0+NV5f/ZMby2F6S2wwA7fgynh9gWSw==", - "requires": { - "extend-shallow": "^2.0.1", - "is-extendable": "^0.1.1", - "is-plain-object": "^2.0.3", - "split-string": "^3.0.1" - } - } - } - }, - "cacheable-request": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/cacheable-request/-/cacheable-request-6.1.0.tgz", - "integrity": "sha512-Oj3cAGPCqOZX7Rz64Uny2GYAZNliQSqfbePrgAQ1wKAihYmCUnraBtJtKcGR4xz7wF+LoJC+ssFZvv5BgF9Igg==", - "requires": { - "clone-response": "^1.0.2", - "get-stream": "^5.1.0", - "http-cache-semantics": "^4.0.0", - "keyv": "^3.0.0", - "lowercase-keys": "^2.0.0", - "normalize-url": "^4.1.0", - "responselike": "^1.0.2" - }, - "dependencies": { - "get-stream": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-5.1.0.tgz", - "integrity": "sha512-EXr1FOzrzTfGeL0gQdeFEvOMm2mzMOglyiOXSTpPC+iAjAKftbr3jpCMWynogwYnM+eSj9sHGc6wjIcDvYiygw==", - "requires": { - "pump": "^3.0.0" - } - }, - "lowercase-keys": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/lowercase-keys/-/lowercase-keys-2.0.0.tgz", - "integrity": "sha512-tqNXrS78oMOE73NMxK4EMLQsQowWf8jKooH9g7xPavRT706R6bkQJ6DY2Te7QukaZsulxa30wQ7bk0pm4XiHmA==" - } - } - }, - "cached-path-relative": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/cached-path-relative/-/cached-path-relative-1.0.2.tgz", - "integrity": "sha512-5r2GqsoEb4qMTTN9J+WzXfjov+hjxT+j3u5K+kIVNIwAd99DLCJE9pBIMP1qVeybV6JiijL385Oz0DcYxfbOIg==" - }, - "call-matcher": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/call-matcher/-/call-matcher-1.1.0.tgz", - "integrity": "sha512-IoQLeNwwf9KTNbtSA7aEBb1yfDbdnzwjCetjkC8io5oGeOmK2CBNdg0xr+tadRYKO0p7uQyZzvon0kXlZbvGrw==", - "requires": { - "core-js": "^2.0.0", - "deep-equal": "^1.0.0", - "espurify": "^1.6.0", - "estraverse": "^4.0.0" - } - }, - "call-signature": { - "version": "0.0.2", - "resolved": "https://registry.npmjs.org/call-signature/-/call-signature-0.0.2.tgz", - "integrity": "sha1-qEq8glpV70yysCi9dOIFpluaSZY=" - }, - "callsites": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", - "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==" - }, - "camelcase": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-2.1.1.tgz", - "integrity": "sha1-fB0W1nmhu+WcoCys7PsBHiAfWh8=" - }, - "camelcase-keys": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/camelcase-keys/-/camelcase-keys-2.1.0.tgz", - "integrity": "sha1-MIvur/3ygRkFHvodkyITyRuPkuc=", - "requires": { - "camelcase": "^2.0.0", - "map-obj": "^1.0.0" - } - }, - "capture-stack-trace": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/capture-stack-trace/-/capture-stack-trace-1.0.0.tgz", - "integrity": "sha1-Sm+gc5nCa7pH8LJJa00PtAjFVQ0=" - }, - "chai": { - "version": "4.3.6", - "resolved": "https://registry.npmjs.org/chai/-/chai-4.3.6.tgz", - "integrity": "sha512-bbcp3YfHCUzMOvKqsztczerVgBKSsEijCySNlHHbX3VG1nskvqjz5Rfso1gGwD6w6oOV3eI60pKuMOV5MV7p3Q==", - "requires": { - "assertion-error": "^1.1.0", - "check-error": "^1.0.2", - "deep-eql": "^3.0.1", - "get-func-name": "^2.0.0", - "loupe": "^2.3.1", - "pathval": "^1.1.1", - "type-detect": "^4.0.5" - } - }, - "chai-as-promised": { - "version": "7.1.1", - "resolved": "https://registry.npmjs.org/chai-as-promised/-/chai-as-promised-7.1.1.tgz", - "integrity": "sha512-azL6xMoi+uxu6z4rhWQ1jbdUhOMhis2PvscD/xjLqNMkv3BPPp2JyyuTHOrf9BOosGpNQ11v6BKv/g57RXbiaA==", - "requires": { - "check-error": "^1.0.2" - } - }, - "chalk": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.1.tgz", - "integrity": "sha512-ObN6h1v2fTJSmUXoS3nMQ92LbDK9be4TV+6G+omQlGJFdcUX5heKi1LZ1YnRMIgwTLEj3E24bT6tYni50rlCfQ==", - "requires": { - "ansi-styles": "^3.2.1", - "escape-string-regexp": "^1.0.5", - "supports-color": "^5.3.0" - }, - "dependencies": { - "has-flag": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", - "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=" - }, - "supports-color": { - "version": "5.4.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.4.0.tgz", - "integrity": "sha512-zjaXglF5nnWpsq470jSv6P9DwPvgLkuapYmfDm3JWOm0vkNTVF2tI4UrN2r6jH1qM/uc/WtxYY1hYoA2dOKj5w==", - "requires": { - "has-flag": "^3.0.0" - } - } - } - }, - "chardet": { - "version": "0.4.2", - "resolved": "https://registry.npmjs.org/chardet/-/chardet-0.4.2.tgz", - "integrity": "sha1-tUc7M9yXxCTl2Y3IfVXU2KKci/I=" - }, - "check-error": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.2.tgz", - "integrity": "sha512-BrgHpW9NURQgzoNyjfq0Wu6VFO6D7IZEmJNdtgNqpzGG8RuNFHt2jQxWlAs4HMe119chBnv+34syEZtc6IhLtA==" - }, - "chokidar": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.0.2.tgz", - "integrity": "sha512-c4PR2egjNjI1um6bamCQ6bUNPDiyofNQruHvKgHQ4gDUP/ITSVSzNsiI5OWtHOsX323i5ha/kk4YmOZ1Ktg7KA==", - "requires": { - "anymatch": "^3.0.1", - "braces": "^3.0.2", - "fsevents": "^2.0.6", - "glob-parent": "^5.0.0", - "is-binary-path": "^2.1.0", - "is-glob": "^4.0.1", - "normalize-path": "^3.0.0", - "readdirp": "^3.1.1" - }, - "dependencies": { - "braces": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", - "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", - "requires": { - "fill-range": "^7.0.1" - } - }, - "fill-range": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", - "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", - "requires": { - "to-regex-range": "^5.0.1" - } - }, - "glob-parent": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.0.0.tgz", - "integrity": "sha512-Z2RwiujPRGluePM6j699ktJYxmPpJKCfpGA13jz2hmFZC7gKetzrWvg5KN3+OsIFmydGyZ1AVwERCq1w/ZZwRg==", - "requires": { - "is-glob": "^4.0.1" - } - }, - "is-number": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", - "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==" - }, - "to-regex-range": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", - "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", - "requires": { - "is-number": "^7.0.0" - } - } - } - }, - "chunkd": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/chunkd/-/chunkd-1.0.0.tgz", - "integrity": "sha512-xx3Pb5VF9QaqCotolyZ1ywFBgyuJmu6+9dLiqBxgelEse9Xsr3yUlpoX3O4Oh11M00GT2kYMsRByTKIMJW2Lkg==" - }, - "ci-info": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-1.1.3.tgz", - "integrity": "sha512-SK/846h/Rcy8q9Z9CAwGBLfCJ6EkjJWdpelWDufQpqVDYq2Wnnv8zlSO6AMQap02jvhVruKKpEtQOufo3pFhLg==" - }, - "ci-parallel-vars": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/ci-parallel-vars/-/ci-parallel-vars-1.0.0.tgz", - "integrity": "sha512-u6dx20FBXm+apMi+5x7UVm6EH7BL1gc4XrcnQewjcB7HWRcor/V5qWc3RG2HwpgDJ26gIi2DSEu3B7sXynAw/g==" - }, - "cipher-base": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/cipher-base/-/cipher-base-1.0.4.tgz", - "integrity": "sha1-h2Dk7MJy9MNjUy+SbYdKriwTl94=", - "requires": { - "inherits": "^2.0.1", - "safe-buffer": "^5.0.1" - } - }, - "class-utils": { - "version": "0.3.6", - "resolved": "https://registry.npmjs.org/class-utils/-/class-utils-0.3.6.tgz", - "integrity": "sha512-qOhPa/Fj7s6TY8H8esGu5QNpMMQxz79h+urzrNYN6mn+9BnxlDGf5QZ+XeCDsxSjPqsSR56XOZOJmpeurnLMeg==", - "requires": { - "arr-union": "^3.1.0", - "define-property": "^0.2.5", - "isobject": "^3.0.0", - "static-extend": "^0.1.1" - }, - "dependencies": { - "define-property": { - "version": "0.2.5", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", - "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", - "requires": { - "is-descriptor": "^0.1.0" - } - }, - "isobject": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", - "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=" - } - } - }, - "clean-stack": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/clean-stack/-/clean-stack-2.1.0.tgz", - "integrity": "sha512-uQWrpRm+iZZUCAp7ZZJQbd4Za9I3AjR/3YTjmcnAtkauaIm/T5CT6U8zVI6e60T6OANqBFAzuR9/HB3NzuZCRA==" - }, - "clean-yaml-object": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/clean-yaml-object/-/clean-yaml-object-0.1.0.tgz", - "integrity": "sha1-Y/sRDcLOGoTcIfbZM0h20BCui2g=" - }, - "cli-boxes": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/cli-boxes/-/cli-boxes-2.2.0.tgz", - "integrity": "sha512-gpaBrMAizVEANOpfZp/EEUixTXDyGt7DFzdK5hU+UbWt/J0lB0w20ncZj59Z9a93xHb9u12zF5BS6i9RKbtg4w==" - }, - "cli-cursor": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-2.1.0.tgz", - "integrity": "sha1-s12sN2R5+sw+lHR9QdDQ9SOP/LU=", - "requires": { - "restore-cursor": "^2.0.0" - } - }, - "cli-spinners": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/cli-spinners/-/cli-spinners-2.2.0.tgz", - "integrity": "sha512-tgU3fKwzYjiLEQgPMD9Jt+JjHVL9kW93FiIMX/l7rivvOD4/LL0Mf7gda3+4U2KJBloybwgj5KEoQgGRioMiKQ==" - }, - "cli-truncate": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/cli-truncate/-/cli-truncate-2.0.0.tgz", - "integrity": "sha512-C4hp+8GCIFVsUUiXcw+ce+7wexVWImw8rQrgMBFsqerx9LvvcGlwm6sMjQYAEmV/Xb87xc1b5Ttx505MSpZVqg==", - "requires": { - "slice-ansi": "^2.1.0", - "string-width": "^4.1.0" - }, - "dependencies": { - "ansi-regex": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", - "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==" - }, - "emoji-regex": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", - "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==" - }, - "is-fullwidth-code-point": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", - "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==" - }, - "string-width": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.1.0.tgz", - "integrity": "sha512-NrX+1dVVh+6Y9dnQ19pR0pP4FiEIlUvdTGn8pw6CKTNq5sgib2nIhmUNT5TAmhWmvKr3WcxBcP3E8nWezuipuQ==", - "requires": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^5.2.0" - } - }, - "strip-ansi": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", - "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", - "requires": { - "ansi-regex": "^4.1.0" - } - } - } - }, - "cli-width": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/cli-width/-/cli-width-2.2.0.tgz", - "integrity": "sha1-/xnt6Kml5XkyQUewwR8PvLq+1jk=" - }, - "clone": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/clone/-/clone-1.0.4.tgz", - "integrity": "sha1-2jCcwmPfFZlMaIypAheco8fNfH4=" - }, - "clone-response": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/clone-response/-/clone-response-1.0.2.tgz", - "integrity": "sha1-0dyXOSAxTfZ/vrlCI7TuNQI56Ws=", - "requires": { - "mimic-response": "^1.0.0" - } - }, - "cmd-shim": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/cmd-shim/-/cmd-shim-2.0.2.tgz", - "integrity": "sha1-b8vamUg6j9FdfTChlspp1oii79s=", - "requires": { - "graceful-fs": "^4.1.2", - "mkdirp": "~0.5.0" - } - }, - "code-excerpt": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/code-excerpt/-/code-excerpt-2.1.1.tgz", - "integrity": "sha512-tJLhH3EpFm/1x7heIW0hemXJTUU5EWl2V0EIX558jp05Mt1U6DVryCgkp3l37cxqs+DNbNgxG43SkwJXpQ14Jw==", - "requires": { - "convert-to-spaces": "^1.0.1" - } - }, - "code-point-at": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz", - "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=" - }, - "collection-visit": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/collection-visit/-/collection-visit-1.0.0.tgz", - "integrity": "sha1-S8A3PBZLwykbTTaMgpzxqApZ3KA=", - "requires": { - "map-visit": "^1.0.0", - "object-visit": "^1.0.0" - } - }, - "color-convert": { - "version": "1.9.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.1.tgz", - "integrity": "sha1-wSYRB66y8pTr/+ye2eytUppgl+0=", - "requires": { - "color-name": "^1.1.1" - } - }, - "color-name": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", - "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=" - }, - "colors": { - "version": "1.2.5", - "resolved": "https://registry.npmjs.org/colors/-/colors-1.2.5.tgz", - "integrity": "sha512-erNRLao/Y3Fv54qUa0LBB+//Uf3YwMUmdJinN20yMXm9zdKKqH9wt7R9IIVZ+K7ShzfpLV/Zg8+VyrBJYB4lpg==" - }, - "columnify": { - "version": "1.5.4", - "resolved": "https://registry.npmjs.org/columnify/-/columnify-1.5.4.tgz", - "integrity": "sha1-Rzfd8ce2mop8NAVweC6UfuyOeLs=", - "requires": { - "strip-ansi": "^3.0.0", - "wcwidth": "^1.0.0" - }, - "dependencies": { - "strip-ansi": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", - "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", - "requires": { - "ansi-regex": "^2.0.0" - } - } - } - }, - "combine-source-map": { - "version": "0.8.0", - "resolved": "https://registry.npmjs.org/combine-source-map/-/combine-source-map-0.8.0.tgz", - "integrity": "sha1-pY0N8ELBhvz4IqjoAV9UUNLXmos=", - "requires": { - "convert-source-map": "~1.1.0", - "inline-source-map": "~0.6.0", - "lodash.memoize": "~3.0.3", - "source-map": "~0.5.3" - }, - "dependencies": { - "convert-source-map": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.1.3.tgz", - "integrity": "sha1-SCnId+n+SbMWHzvzZziI4gRpmGA=" - } - } - }, - "command-join": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/command-join/-/command-join-2.0.0.tgz", - "integrity": "sha1-Uui5hPSHLZUv8b3IuYOX0nxxRM8=" - }, - "common-path-prefix": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/common-path-prefix/-/common-path-prefix-1.0.0.tgz", - "integrity": "sha1-zVL28HEuC6q5fW+XModPIvR3UsA=" - }, - "compare-func": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/compare-func/-/compare-func-1.3.2.tgz", - "integrity": "sha1-md0LpFfh+bxyKxLAjsM+6rMfpkg=", - "requires": { - "array-ify": "^1.0.0", - "dot-prop": "^3.0.0" - }, - "dependencies": { - "dot-prop": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/dot-prop/-/dot-prop-3.0.0.tgz", - "integrity": "sha1-G3CK8JSknJoOfbyteQq6U52sEXc=", - "requires": { - "is-obj": "^1.0.0" - } - } - } - }, - "component-emitter": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.2.1.tgz", - "integrity": "sha1-E3kY1teCg/ffemt8WmPhQOaUJeY=" - }, - "concat-map": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" - }, - "concat-stream": { - "version": "1.5.2", - "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.5.2.tgz", - "integrity": "sha1-cIl4Yk2FavQaWnQd790mHadSwmY=", - "requires": { - "inherits": "~2.0.1", - "readable-stream": "~2.0.0", - "typedarray": "~0.0.5" - }, - "dependencies": { - "process-nextick-args": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz", - "integrity": "sha1-FQ4gt1ZZCtP5EJPyWk8q2L/zC6M=" - }, - "readable-stream": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.0.6.tgz", - "integrity": "sha1-j5A0HmilPMySh4jaz80Rs265t44=", - "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.1", - "isarray": "~1.0.0", - "process-nextick-args": "~1.0.6", - "string_decoder": "~0.10.x", - "util-deprecate": "~1.0.1" - } - }, - "string_decoder": { - "version": "0.10.31", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", - "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=" - } - } - }, - "concordance": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/concordance/-/concordance-4.0.0.tgz", - "integrity": "sha512-l0RFuB8RLfCS0Pt2Id39/oCPykE01pyxgAFypWTlaGRgvLkZrtczZ8atEHpTeEIW+zYWXTBuA9cCSeEOScxReQ==", - "requires": { - "date-time": "^2.1.0", - "esutils": "^2.0.2", - "fast-diff": "^1.1.2", - "js-string-escape": "^1.0.1", - "lodash.clonedeep": "^4.5.0", - "lodash.flattendeep": "^4.4.0", - "lodash.islength": "^4.0.1", - "lodash.merge": "^4.6.1", - "md5-hex": "^2.0.0", - "semver": "^5.5.1", - "well-known-symbols": "^2.0.0" - }, - "dependencies": { - "md5-hex": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/md5-hex/-/md5-hex-2.0.0.tgz", - "integrity": "sha1-0FiOnxx0lUSS7NJKwKxs6ZfZLjM=", - "requires": { - "md5-o-matic": "^0.1.1" - } - }, - "semver": { - "version": "5.7.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.0.tgz", - "integrity": "sha512-Ya52jSX2u7QKghxeoFGpLwCtGlt7j0oY9DYb5apt9nPlJ42ID+ulTXESnt/qAQcoSERyZ5sl3LDIOw0nAn/5DA==" - } - } - }, - "configstore": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/configstore/-/configstore-4.0.0.tgz", - "integrity": "sha512-CmquAXFBocrzaSM8mtGPMM/HiWmyIpr4CcJl/rgY2uCObZ/S7cKU0silxslqJejl+t/T9HS8E0PUNQD81JGUEQ==", - "requires": { - "dot-prop": "^4.1.0", - "graceful-fs": "^4.1.2", - "make-dir": "^1.0.0", - "unique-string": "^1.0.0", - "write-file-atomic": "^2.0.0", - "xdg-basedir": "^3.0.0" - }, - "dependencies": { - "dot-prop": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/dot-prop/-/dot-prop-4.2.0.tgz", - "integrity": "sha512-tUMXrxlExSW6U2EXiiKGSBVdYgtV8qlHL+C10TsW4PURY/ic+eaysnSkwB4kA/mBlCyy/IKDJ+Lc3wbWeaXtuQ==", - "requires": { - "is-obj": "^1.0.0" - } - } - } - }, - "console-browserify": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/console-browserify/-/console-browserify-1.1.0.tgz", - "integrity": "sha1-8CQcRXMKn8YyOyBtvzjtx0HQuxA=", - "requires": { - "date-now": "^0.1.4" - } - }, - "console-control-strings": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz", - "integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=" - }, - "constants-browserify": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/constants-browserify/-/constants-browserify-1.0.0.tgz", - "integrity": "sha1-wguW2MYXdIqvHBYCF2DNJ/y4y3U=" - }, - "content-disposition": { - "version": "0.5.2", - "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.2.tgz", - "integrity": "sha1-DPaLud318r55YcOoUXjLhdunjLQ=" - }, - "content-type": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.4.tgz", - "integrity": "sha1-4TjMdeBAxyexlm/l5fjJruJW/js=" - }, - "conventional-changelog": { - "version": "1.1.24", - "resolved": "https://registry.npmjs.org/conventional-changelog/-/conventional-changelog-1.1.24.tgz", - "integrity": "sha512-2WcSUst4Y3Z4hHvoMTWXMJr/DmgVdLiMOVY1Kak2LfFz+GIz2KDp5naqbFesYbfXPmaZ5p491dO0FWZIJoJw1Q==", - "requires": { - "conventional-changelog-angular": "^1.6.6", - "conventional-changelog-atom": "^0.2.8", - "conventional-changelog-codemirror": "^0.3.8", - "conventional-changelog-core": "^2.0.11", - "conventional-changelog-ember": "^0.3.12", - "conventional-changelog-eslint": "^1.0.9", - "conventional-changelog-express": "^0.3.6", - "conventional-changelog-jquery": "^0.1.0", - "conventional-changelog-jscs": "^0.1.0", - "conventional-changelog-jshint": "^0.3.8", - "conventional-changelog-preset-loader": "^1.1.8" - } - }, - "conventional-changelog-angular": { - "version": "1.6.6", - "resolved": "https://registry.npmjs.org/conventional-changelog-angular/-/conventional-changelog-angular-1.6.6.tgz", - "integrity": "sha512-suQnFSqCxRwyBxY68pYTsFkG0taIdinHLNEAX5ivtw8bCRnIgnpvcHmlR/yjUyZIrNPYAoXlY1WiEKWgSE4BNg==", - "requires": { - "compare-func": "^1.3.1", - "q": "^1.5.1" - } - }, - "conventional-changelog-atom": { - "version": "0.2.8", - "resolved": "https://registry.npmjs.org/conventional-changelog-atom/-/conventional-changelog-atom-0.2.8.tgz", - "integrity": "sha512-8pPZqhMbrnltNBizjoDCb/Sz85KyUXNDQxuAEYAU5V/eHn0okMBVjqc8aHWYpHrytyZWvMGbayOlDv7i8kEf6g==", - "requires": { - "q": "^1.5.1" - } - }, - "conventional-changelog-cli": { - "version": "1.3.22", - "resolved": "https://registry.npmjs.org/conventional-changelog-cli/-/conventional-changelog-cli-1.3.22.tgz", - "integrity": "sha512-pnjdIJbxjkZ5VdAX/H1wndr1G10CY8MuZgnXuJhIHglOXfIrXygb7KZC836GW9uo1u8PjEIvIw/bKX0lOmOzZg==", - "requires": { - "add-stream": "^1.0.0", - "conventional-changelog": "^1.1.24", - "lodash": "^4.2.1", - "meow": "^4.0.0", - "tempfile": "^1.1.1" - }, - "dependencies": { - "camelcase": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-4.1.0.tgz", - "integrity": "sha1-1UVjW+HjPFQmScaRc+Xeas+uNN0=" - }, - "camelcase-keys": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/camelcase-keys/-/camelcase-keys-4.2.0.tgz", - "integrity": "sha1-oqpfsa9oh1glnDLBQUJteJI7m3c=", - "requires": { - "camelcase": "^4.1.0", - "map-obj": "^2.0.0", - "quick-lru": "^1.0.0" - } - }, - "load-json-file": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-4.0.0.tgz", - "integrity": "sha1-L19Fq5HjMhYjT9U62rZo607AmTs=", - "requires": { - "graceful-fs": "^4.1.2", - "parse-json": "^4.0.0", - "pify": "^3.0.0", - "strip-bom": "^3.0.0" - } - }, - "map-obj": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/map-obj/-/map-obj-2.0.0.tgz", - "integrity": "sha1-plzSkIepJZi4eRJXpSPgISIqwfk=" - }, - "meow": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/meow/-/meow-4.0.1.tgz", - "integrity": "sha512-xcSBHD5Z86zaOc+781KrupuHAzeGXSLtiAOmBsiLDiPSaYSB6hdew2ng9EBAnZ62jagG9MHAOdxpDi/lWBFJ/A==", - "requires": { - "camelcase-keys": "^4.0.0", - "decamelize-keys": "^1.0.0", - "loud-rejection": "^1.0.0", - "minimist": "^1.1.3", - "minimist-options": "^3.0.1", - "normalize-package-data": "^2.3.4", - "read-pkg-up": "^3.0.0", - "redent": "^2.0.0", - "trim-newlines": "^2.0.0" - } - }, - "minimist": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", - "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" - }, - "parse-json": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-4.0.0.tgz", - "integrity": "sha1-vjX1Qlvh9/bHRxhPmKeIy5lHfuA=", - "requires": { - "error-ex": "^1.3.1", - "json-parse-better-errors": "^1.0.1" - } - }, - "path-type": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/path-type/-/path-type-3.0.0.tgz", - "integrity": "sha512-T2ZUsdZFHgA3u4e5PfPbjd7HDDpxPnQb5jN0SrDsjNSuVXHJqtwTnWqG0B1jZrgmJ/7lj1EmVIByWt1gxGkWvg==", - "requires": { - "pify": "^3.0.0" - } - }, - "pify": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/pify/-/pify-3.0.0.tgz", - "integrity": "sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY=" - }, - "read-pkg": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-3.0.0.tgz", - "integrity": "sha1-nLxoaXj+5l0WwA4rGcI3/Pbjg4k=", - "requires": { - "load-json-file": "^4.0.0", - "normalize-package-data": "^2.3.2", - "path-type": "^3.0.0" - } - }, - "read-pkg-up": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-3.0.0.tgz", - "integrity": "sha1-PtSWaF26D4/hGNBpHcUfSh/5bwc=", - "requires": { - "find-up": "^2.0.0", - "read-pkg": "^3.0.0" - } - }, - "redent": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/redent/-/redent-2.0.0.tgz", - "integrity": "sha1-wbIAe0LVfrE4kHmzyDM2OdXhzKo=", - "requires": { - "indent-string": "^3.0.0", - "strip-indent": "^2.0.0" - } - }, - "strip-indent": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/strip-indent/-/strip-indent-2.0.0.tgz", - "integrity": "sha1-XvjbKV0B5u1sv3qrlpmNeCJSe2g=" - }, - "trim-newlines": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/trim-newlines/-/trim-newlines-2.0.0.tgz", - "integrity": "sha1-tAPQuRvlDDMd/EuC7s6yLD3hbSA=" - } - } - }, - "conventional-changelog-codemirror": { - "version": "0.3.8", - "resolved": "https://registry.npmjs.org/conventional-changelog-codemirror/-/conventional-changelog-codemirror-0.3.8.tgz", - "integrity": "sha512-3HFZKtBXTaUCHvz7ai6nk2+psRIkldDoNzCsom0egDtVmPsvvHZkzjynhdQyULfacRSsBTaiQ0ol6nBOL4dDiQ==", - "requires": { - "q": "^1.5.1" - } - }, - "conventional-changelog-core": { - "version": "2.0.11", - "resolved": "https://registry.npmjs.org/conventional-changelog-core/-/conventional-changelog-core-2.0.11.tgz", - "integrity": "sha512-HvTE6RlqeEZ/NFPtQeFLsIDOLrGP3bXYr7lFLMhCVsbduF1MXIe8OODkwMFyo1i9ku9NWBwVnVn0jDmIFXjDRg==", - "requires": { - "conventional-changelog-writer": "^3.0.9", - "conventional-commits-parser": "^2.1.7", - "dateformat": "^3.0.0", - "get-pkg-repo": "^1.0.0", - "git-raw-commits": "^1.3.6", - "git-remote-origin-url": "^2.0.0", - "git-semver-tags": "^1.3.6", - "lodash": "^4.2.1", - "normalize-package-data": "^2.3.5", - "q": "^1.5.1", - "read-pkg": "^1.1.0", - "read-pkg-up": "^1.0.1", - "through2": "^2.0.0" - }, - "dependencies": { - "find-up": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-1.1.2.tgz", - "integrity": "sha1-ay6YIrGizgpgq2TWEOzK1TyyTQ8=", - "requires": { - "path-exists": "^2.0.0", - "pinkie-promise": "^2.0.0" - } - }, - "load-json-file": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-1.1.0.tgz", - "integrity": "sha1-lWkFcI1YtLq0wiYbBPWfMcmTdMA=", - "requires": { - "graceful-fs": "^4.1.2", - "parse-json": "^2.2.0", - "pify": "^2.0.0", - "pinkie-promise": "^2.0.0", - "strip-bom": "^2.0.0" - } - }, - "path-exists": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-2.1.0.tgz", - "integrity": "sha1-D+tsZPD8UY2adU3V77YscCJ2H0s=", - "requires": { - "pinkie-promise": "^2.0.0" - } - }, - "path-type": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/path-type/-/path-type-1.1.0.tgz", - "integrity": "sha1-WcRPfuSR2nBNpBXaWkBwuk+P5EE=", - "requires": { - "graceful-fs": "^4.1.2", - "pify": "^2.0.0", - "pinkie-promise": "^2.0.0" - } - }, - "pinkie": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/pinkie/-/pinkie-2.0.4.tgz", - "integrity": "sha1-clVrgM+g1IqXToDnckjoDtT3+HA=" - }, - "pinkie-promise": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/pinkie-promise/-/pinkie-promise-2.0.1.tgz", - "integrity": "sha1-ITXW36ejWMBprJsXh3YogihFD/o=", - "requires": { - "pinkie": "^2.0.0" - } - }, - "read-pkg": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-1.1.0.tgz", - "integrity": "sha1-9f+qXs0pyzHAR0vKfXVra7KePyg=", - "requires": { - "load-json-file": "^1.0.0", - "normalize-package-data": "^2.3.2", - "path-type": "^1.0.0" - } - }, - "read-pkg-up": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-1.0.1.tgz", - "integrity": "sha1-nWPBMnbAZZGNV/ACpX9AobZD+wI=", - "requires": { - "find-up": "^1.0.0", - "read-pkg": "^1.0.0" - } - }, - "strip-bom": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-2.0.0.tgz", - "integrity": "sha1-YhmoVhZSBJHzV4i9vxRHqZx+aw4=", - "requires": { - "is-utf8": "^0.2.0" - } - } - } - }, - "conventional-changelog-ember": { - "version": "0.3.12", - "resolved": "https://registry.npmjs.org/conventional-changelog-ember/-/conventional-changelog-ember-0.3.12.tgz", - "integrity": "sha512-mmJzA7uzbrOqeF89dMMi6z17O07ORTXlTMArnLG9ZTX4oLaKNolUlxFUFlFm9JUoVWajVpaHQWjxH1EOQ+ARoQ==", - "requires": { - "q": "^1.5.1" - } - }, - "conventional-changelog-eslint": { - "version": "1.0.9", - "resolved": "https://registry.npmjs.org/conventional-changelog-eslint/-/conventional-changelog-eslint-1.0.9.tgz", - "integrity": "sha512-h87nfVh2fdk9fJIvz26wCBsbDC/KxqCc5wSlNMZbXcARtbgNbNDIF7Y7ctokFdnxkzVdaHsbINkh548T9eBA7Q==", - "requires": { - "q": "^1.5.1" - } - }, - "conventional-changelog-express": { - "version": "0.3.6", - "resolved": "https://registry.npmjs.org/conventional-changelog-express/-/conventional-changelog-express-0.3.6.tgz", - "integrity": "sha512-3iWVtBJZ9RnRnZveNDzOD8QRn6g6vUif0qVTWWyi5nUIAbuN1FfPVyKdAlJJfp5Im+dE8Kiy/d2SpaX/0X678Q==", - "requires": { - "q": "^1.5.1" - } - }, - "conventional-changelog-jquery": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/conventional-changelog-jquery/-/conventional-changelog-jquery-0.1.0.tgz", - "integrity": "sha1-Agg5cWLjhGmG5xJztsecW1+A9RA=", - "requires": { - "q": "^1.4.1" - } - }, - "conventional-changelog-jscs": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/conventional-changelog-jscs/-/conventional-changelog-jscs-0.1.0.tgz", - "integrity": "sha1-BHnrRDzH1yxYvwvPDvHURKkvDlw=", - "requires": { - "q": "^1.4.1" - } - }, - "conventional-changelog-jshint": { - "version": "0.3.8", - "resolved": "https://registry.npmjs.org/conventional-changelog-jshint/-/conventional-changelog-jshint-0.3.8.tgz", - "integrity": "sha512-hn9QU4ZI/5V50wKPJNPGT4gEWgiBFpV6adieILW4MaUFynuDYOvQ71EMSj3EznJyKi/KzuXpc9dGmX8njZMjig==", - "requires": { - "compare-func": "^1.3.1", - "q": "^1.5.1" - } - }, - "conventional-changelog-preset-loader": { - "version": "1.1.8", - "resolved": "https://registry.npmjs.org/conventional-changelog-preset-loader/-/conventional-changelog-preset-loader-1.1.8.tgz", - "integrity": "sha512-MkksM4G4YdrMlT2MbTsV2F6LXu/hZR0Tc/yenRrDIKRwBl/SP7ER4ZDlglqJsCzLJi4UonBc52Bkm5hzrOVCcw==" - }, - "conventional-changelog-writer": { - "version": "3.0.9", - "resolved": "https://registry.npmjs.org/conventional-changelog-writer/-/conventional-changelog-writer-3.0.9.tgz", - "integrity": "sha512-n9KbsxlJxRQsUnK6wIBRnARacvNnN4C/nxnxCkH+B/R1JS2Fa+DiP1dU4I59mEDEjgnFaN2+9wr1P1s7GYB5/Q==", - "requires": { - "compare-func": "^1.3.1", - "conventional-commits-filter": "^1.1.6", - "dateformat": "^3.0.0", - "handlebars": "^4.0.2", - "json-stringify-safe": "^5.0.1", - "lodash": "^4.2.1", - "meow": "^4.0.0", - "semver": "^5.5.0", - "split": "^1.0.0", - "through2": "^2.0.0" - }, - "dependencies": { - "camelcase": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-4.1.0.tgz", - "integrity": "sha1-1UVjW+HjPFQmScaRc+Xeas+uNN0=" - }, - "camelcase-keys": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/camelcase-keys/-/camelcase-keys-4.2.0.tgz", - "integrity": "sha1-oqpfsa9oh1glnDLBQUJteJI7m3c=", - "requires": { - "camelcase": "^4.1.0", - "map-obj": "^2.0.0", - "quick-lru": "^1.0.0" - } - }, - "load-json-file": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-4.0.0.tgz", - "integrity": "sha1-L19Fq5HjMhYjT9U62rZo607AmTs=", - "requires": { - "graceful-fs": "^4.1.2", - "parse-json": "^4.0.0", - "pify": "^3.0.0", - "strip-bom": "^3.0.0" - } - }, - "map-obj": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/map-obj/-/map-obj-2.0.0.tgz", - "integrity": "sha1-plzSkIepJZi4eRJXpSPgISIqwfk=" - }, - "meow": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/meow/-/meow-4.0.1.tgz", - "integrity": "sha512-xcSBHD5Z86zaOc+781KrupuHAzeGXSLtiAOmBsiLDiPSaYSB6hdew2ng9EBAnZ62jagG9MHAOdxpDi/lWBFJ/A==", - "requires": { - "camelcase-keys": "^4.0.0", - "decamelize-keys": "^1.0.0", - "loud-rejection": "^1.0.0", - "minimist": "^1.1.3", - "minimist-options": "^3.0.1", - "normalize-package-data": "^2.3.4", - "read-pkg-up": "^3.0.0", - "redent": "^2.0.0", - "trim-newlines": "^2.0.0" - } - }, - "minimist": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", - "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" - }, - "parse-json": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-4.0.0.tgz", - "integrity": "sha1-vjX1Qlvh9/bHRxhPmKeIy5lHfuA=", - "requires": { - "error-ex": "^1.3.1", - "json-parse-better-errors": "^1.0.1" - } - }, - "path-type": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/path-type/-/path-type-3.0.0.tgz", - "integrity": "sha512-T2ZUsdZFHgA3u4e5PfPbjd7HDDpxPnQb5jN0SrDsjNSuVXHJqtwTnWqG0B1jZrgmJ/7lj1EmVIByWt1gxGkWvg==", - "requires": { - "pify": "^3.0.0" - } - }, - "pify": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/pify/-/pify-3.0.0.tgz", - "integrity": "sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY=" - }, - "read-pkg": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-3.0.0.tgz", - "integrity": "sha1-nLxoaXj+5l0WwA4rGcI3/Pbjg4k=", - "requires": { - "load-json-file": "^4.0.0", - "normalize-package-data": "^2.3.2", - "path-type": "^3.0.0" - } - }, - "read-pkg-up": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-3.0.0.tgz", - "integrity": "sha1-PtSWaF26D4/hGNBpHcUfSh/5bwc=", - "requires": { - "find-up": "^2.0.0", - "read-pkg": "^3.0.0" - } - }, - "redent": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/redent/-/redent-2.0.0.tgz", - "integrity": "sha1-wbIAe0LVfrE4kHmzyDM2OdXhzKo=", - "requires": { - "indent-string": "^3.0.0", - "strip-indent": "^2.0.0" - } - }, - "strip-indent": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/strip-indent/-/strip-indent-2.0.0.tgz", - "integrity": "sha1-XvjbKV0B5u1sv3qrlpmNeCJSe2g=" - }, - "trim-newlines": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/trim-newlines/-/trim-newlines-2.0.0.tgz", - "integrity": "sha1-tAPQuRvlDDMd/EuC7s6yLD3hbSA=" - } - } - }, - "conventional-commits-filter": { - "version": "1.1.6", - "resolved": "https://registry.npmjs.org/conventional-commits-filter/-/conventional-commits-filter-1.1.6.tgz", - "integrity": "sha512-KcDgtCRKJCQhyk6VLT7zR+ZOyCnerfemE/CsR3iQpzRRFbLEs0Y6rwk3mpDvtOh04X223z+1xyJ582Stfct/0Q==", - "requires": { - "is-subset": "^0.1.1", - "modify-values": "^1.0.0" - } - }, - "conventional-commits-parser": { - "version": "2.1.7", - "resolved": "https://registry.npmjs.org/conventional-commits-parser/-/conventional-commits-parser-2.1.7.tgz", - "integrity": "sha512-BoMaddIEJ6B4QVMSDu9IkVImlGOSGA1I2BQyOZHeLQ6qVOJLcLKn97+fL6dGbzWEiqDzfH4OkcveULmeq2MHFQ==", - "requires": { - "JSONStream": "^1.0.4", - "is-text-path": "^1.0.0", - "lodash": "^4.2.1", - "meow": "^4.0.0", - "split2": "^2.0.0", - "through2": "^2.0.0", - "trim-off-newlines": "^1.0.0" - }, - "dependencies": { - "camelcase": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-4.1.0.tgz", - "integrity": "sha1-1UVjW+HjPFQmScaRc+Xeas+uNN0=" - }, - "camelcase-keys": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/camelcase-keys/-/camelcase-keys-4.2.0.tgz", - "integrity": "sha1-oqpfsa9oh1glnDLBQUJteJI7m3c=", - "requires": { - "camelcase": "^4.1.0", - "map-obj": "^2.0.0", - "quick-lru": "^1.0.0" - } - }, - "load-json-file": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-4.0.0.tgz", - "integrity": "sha1-L19Fq5HjMhYjT9U62rZo607AmTs=", - "requires": { - "graceful-fs": "^4.1.2", - "parse-json": "^4.0.0", - "pify": "^3.0.0", - "strip-bom": "^3.0.0" - } - }, - "map-obj": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/map-obj/-/map-obj-2.0.0.tgz", - "integrity": "sha1-plzSkIepJZi4eRJXpSPgISIqwfk=" - }, - "meow": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/meow/-/meow-4.0.1.tgz", - "integrity": "sha512-xcSBHD5Z86zaOc+781KrupuHAzeGXSLtiAOmBsiLDiPSaYSB6hdew2ng9EBAnZ62jagG9MHAOdxpDi/lWBFJ/A==", - "requires": { - "camelcase-keys": "^4.0.0", - "decamelize-keys": "^1.0.0", - "loud-rejection": "^1.0.0", - "minimist": "^1.1.3", - "minimist-options": "^3.0.1", - "normalize-package-data": "^2.3.4", - "read-pkg-up": "^3.0.0", - "redent": "^2.0.0", - "trim-newlines": "^2.0.0" - } - }, - "minimist": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", - "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" - }, - "parse-json": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-4.0.0.tgz", - "integrity": "sha1-vjX1Qlvh9/bHRxhPmKeIy5lHfuA=", - "requires": { - "error-ex": "^1.3.1", - "json-parse-better-errors": "^1.0.1" - } - }, - "path-type": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/path-type/-/path-type-3.0.0.tgz", - "integrity": "sha512-T2ZUsdZFHgA3u4e5PfPbjd7HDDpxPnQb5jN0SrDsjNSuVXHJqtwTnWqG0B1jZrgmJ/7lj1EmVIByWt1gxGkWvg==", - "requires": { - "pify": "^3.0.0" - } - }, - "pify": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/pify/-/pify-3.0.0.tgz", - "integrity": "sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY=" - }, - "read-pkg": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-3.0.0.tgz", - "integrity": "sha1-nLxoaXj+5l0WwA4rGcI3/Pbjg4k=", - "requires": { - "load-json-file": "^4.0.0", - "normalize-package-data": "^2.3.2", - "path-type": "^3.0.0" - } - }, - "read-pkg-up": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-3.0.0.tgz", - "integrity": "sha1-PtSWaF26D4/hGNBpHcUfSh/5bwc=", - "requires": { - "find-up": "^2.0.0", - "read-pkg": "^3.0.0" - } - }, - "redent": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/redent/-/redent-2.0.0.tgz", - "integrity": "sha1-wbIAe0LVfrE4kHmzyDM2OdXhzKo=", - "requires": { - "indent-string": "^3.0.0", - "strip-indent": "^2.0.0" - } - }, - "strip-indent": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/strip-indent/-/strip-indent-2.0.0.tgz", - "integrity": "sha1-XvjbKV0B5u1sv3qrlpmNeCJSe2g=" - }, - "trim-newlines": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/trim-newlines/-/trim-newlines-2.0.0.tgz", - "integrity": "sha1-tAPQuRvlDDMd/EuC7s6yLD3hbSA=" - } - } - }, - "conventional-recommended-bump": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/conventional-recommended-bump/-/conventional-recommended-bump-1.2.1.tgz", - "integrity": "sha512-oJjG6DkRgtnr/t/VrPdzmf4XZv8c4xKVJrVT4zrSHd92KEL+EYxSbYoKq8lQ7U5yLMw7130wrcQTLRjM/T+d4w==", - "requires": { - "concat-stream": "^1.4.10", - "conventional-commits-filter": "^1.1.1", - "conventional-commits-parser": "^2.1.1", - "git-raw-commits": "^1.3.0", - "git-semver-tags": "^1.3.0", - "meow": "^3.3.0", - "object-assign": "^4.0.1" - } - }, - "convert-source-map": { - "version": "1.5.1", - "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.5.1.tgz", - "integrity": "sha1-uCeAl7m8IpNl3lxiz1/K7YtVmeU=" - }, - "convert-to-spaces": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/convert-to-spaces/-/convert-to-spaces-1.0.2.tgz", - "integrity": "sha1-fj5Iu+bZl7FBfdyihoIEtNPYVxU=" - }, - "cookie": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.3.1.tgz", - "integrity": "sha1-5+Ch+e9DtMi6klxcWpboBtFoc7s=" - }, - "cookie-signature": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", - "integrity": "sha1-4wOogrNCzD7oylE6eZmXNNqzriw=" - }, - "copy-descriptor": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/copy-descriptor/-/copy-descriptor-0.1.1.tgz", - "integrity": "sha1-Z29us8OZl8LuGsOpJP1hJHSPV40=" - }, - "core-js": { - "version": "2.5.6", - "resolved": "https://registry.npmjs.org/core-js/-/core-js-2.5.6.tgz", - "integrity": "sha512-lQUVfQi0aLix2xpyjrrJEvfuYCqPc/HwmTKsC/VNf8q0zsjX7SQZtp4+oRONN5Tsur9GDETPjj+Ub2iDiGZfSQ==" - }, - "core-util-is": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", - "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=" - }, - "create-ecdh": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/create-ecdh/-/create-ecdh-4.0.3.tgz", - "integrity": "sha512-GbEHQPMOswGpKXM9kCWVrremUcBmjteUaQ01T9rkKCPDXfUHX0IoP9LpHYo2NPFampa4e+/pFDc3jQdxrxQLaw==", - "requires": { - "bn.js": "^4.1.0", - "elliptic": "^6.0.0" - } - }, - "create-error-class": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/create-error-class/-/create-error-class-3.0.2.tgz", - "integrity": "sha1-Br56vvlHo/FKMP1hBnHUAbyot7Y=", - "requires": { - "capture-stack-trace": "^1.0.0" - } - }, - "create-hash": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/create-hash/-/create-hash-1.2.0.tgz", - "integrity": "sha512-z00bCGNHDG8mHAkP7CtT1qVu+bFQUPjYq/4Iv3C3kWjTFV10zIjfSoeqXo9Asws8gwSHDGj/hl2u4OGIjapeCg==", - "requires": { - "cipher-base": "^1.0.1", - "inherits": "^2.0.1", - "md5.js": "^1.3.4", - "ripemd160": "^2.0.1", - "sha.js": "^2.4.0" - } - }, - "create-hmac": { - "version": "1.1.7", - "resolved": "https://registry.npmjs.org/create-hmac/-/create-hmac-1.1.7.tgz", - "integrity": "sha512-MJG9liiZ+ogc4TzUwuvbER1JRdgvUFSB5+VR/g5h82fGaIRWMWddtKBHi7/sVhfjQZ6SehlyhvQYrcYkaUIpLg==", - "requires": { - "cipher-base": "^1.0.3", - "create-hash": "^1.1.0", - "inherits": "^2.0.1", - "ripemd160": "^2.0.0", - "safe-buffer": "^5.0.1", - "sha.js": "^2.4.8" - } - }, - "cross-spawn": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-5.1.0.tgz", - "integrity": "sha1-6L0O/uWPz/b4+UUQoKVUu/ojVEk=", - "requires": { - "lru-cache": "^4.0.1", - "shebang-command": "^1.2.0", - "which": "^1.2.9" - } - }, - "crypto-browserify": { - "version": "3.12.0", - "resolved": "https://registry.npmjs.org/crypto-browserify/-/crypto-browserify-3.12.0.tgz", - "integrity": "sha1-OWz58xN/A+S45TLFj2mCVOAPgOw=", - "requires": { - "browserify-cipher": "^1.0.0", - "browserify-sign": "^4.0.0", - "create-ecdh": "^4.0.0", - "create-hash": "^1.1.0", - "create-hmac": "^1.1.0", - "diffie-hellman": "^5.0.0", - "inherits": "^2.0.1", - "pbkdf2": "^3.0.3", - "public-encrypt": "^4.0.0", - "randombytes": "^2.0.0", - "randomfill": "^1.0.3" - } - }, - "crypto-random-string": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/crypto-random-string/-/crypto-random-string-1.0.0.tgz", - "integrity": "sha1-ojD2T1aDEOFJgAmUB5DsmVRbyn4=" - }, - "currently-unhandled": { - "version": "0.4.1", - "resolved": "https://registry.npmjs.org/currently-unhandled/-/currently-unhandled-0.4.1.tgz", - "integrity": "sha1-mI3zP+qxke95mmE2nddsF635V+o=", - "requires": { - "array-find-index": "^1.0.1" - } - }, - "dargs": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/dargs/-/dargs-4.1.0.tgz", - "integrity": "sha1-A6nbtLXC8Tm/FK5T8LiipqhvThc=", - "requires": { - "number-is-nan": "^1.0.0" - } - }, - "date-now": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/date-now/-/date-now-0.1.4.tgz", - "integrity": "sha1-6vQ5/U1ISK105cx9vvIAZyueNFs=" - }, - "date-time": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/date-time/-/date-time-2.1.0.tgz", - "integrity": "sha512-/9+C44X7lot0IeiyfgJmETtRMhBidBYM2QFFIkGa0U1k+hSyY87Nw7PY3eDqpvCBm7I3WCSfPeZskW/YYq6m4g==", - "requires": { - "time-zone": "^1.0.0" - } - }, - "dateformat": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/dateformat/-/dateformat-3.0.3.tgz", - "integrity": "sha512-jyCETtSl3VMZMWeRo7iY1FL19ges1t55hMo5yaam4Jrsm5EPL89UQkoQRyiI+Yf4k8r2ZpdngkV8hr1lIdjb3Q==" - }, - "debug": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha1-XRKFFd8TT/Mn6QpMk/Tgd6U2NB8=", - "requires": { - "ms": "2.0.0" - }, - "dependencies": { - "ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" - } - } - }, - "decamelize": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", - "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=" - }, - "decamelize-keys": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/decamelize-keys/-/decamelize-keys-1.1.0.tgz", - "integrity": "sha1-0XGoeTMlKAfrPLYdwcFEXQeN8tk=", - "requires": { - "decamelize": "^1.1.0", - "map-obj": "^1.0.0" - } - }, - "decode-uri-component": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/decode-uri-component/-/decode-uri-component-0.2.0.tgz", - "integrity": "sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU=" - }, - "decompress-response": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-3.3.0.tgz", - "integrity": "sha1-gKTdMjdIOEv6JICDYirt7Jgq3/M=", - "requires": { - "mimic-response": "^1.0.0" - } - }, - "dedent": { - "version": "0.7.0", - "resolved": "https://registry.npmjs.org/dedent/-/dedent-0.7.0.tgz", - "integrity": "sha1-JJXduvbrh0q7Dhvp3yLS5aVEMmw=" - }, - "deep-eql": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-3.0.1.tgz", - "integrity": "sha512-+QeIQyN5ZuO+3Uk5DYh6/1eKO0m0YmJFGNmFHGACpf1ClL1nmlV/p4gNgbl2pJGxgXb4faqo6UE+M5ACEMyVcw==", - "requires": { - "type-detect": "^4.0.0" - } - }, - "deep-equal": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/deep-equal/-/deep-equal-1.0.1.tgz", - "integrity": "sha1-9dJgKStmDghO/0zbyfCK0yR0SLU=" - }, - "deep-extend": { - "version": "0.5.1", - "resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.5.1.tgz", - "integrity": "sha512-N8vBdOa+DF7zkRrDCsaOXoCs/E2fJfx9B9MrKnnSiHNh4ws7eSys6YQE4KvT1cecKmOASYQBhbKjeuDD9lT81w==" - }, - "deep-is": { - "version": "0.1.3", - "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.3.tgz", - "integrity": "sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ=" - }, - "defaults": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/defaults/-/defaults-1.0.3.tgz", - "integrity": "sha1-xlYFHpgX2f8I7YgUd/P+QBnz730=", - "requires": { - "clone": "^1.0.2" - } - }, - "defer-to-connect": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/defer-to-connect/-/defer-to-connect-1.0.2.tgz", - "integrity": "sha512-k09hcQcTDY+cwgiwa6PYKLm3jlagNzQ+RSvhjzESOGOx+MNOuXkxTfEvPrO1IOQ81tArCFYQgi631clB70RpQw==" - }, - "define-properties": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.3.tgz", - "integrity": "sha512-3MqfYKj2lLzdMSf8ZIZE/V+Zuy+BgD6f164e8K2w7dgnpKArBDerGYpM46IYYcjnkdPNMjPk9A6VFB8+3SKlXQ==", - "requires": { - "object-keys": "^1.0.12" - }, - "dependencies": { - "object-keys": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz", - "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==" - } - } - }, - "define-property": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-2.0.2.tgz", - "integrity": "sha512-jwK2UV4cnPpbcG7+VRARKTZPUWowwXA8bzH5NP6ud0oeAxyYPuGZUAC7hMugpCdz4BeSZl2Dl9k66CHJ/46ZYQ==", - "requires": { - "is-descriptor": "^1.0.2", - "isobject": "^3.0.1" - }, - "dependencies": { - "is-accessor-descriptor": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", - "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", - "requires": { - "kind-of": "^6.0.0" - } - }, - "is-data-descriptor": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", - "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", - "requires": { - "kind-of": "^6.0.0" - } - }, - "is-descriptor": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", - "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", - "requires": { - "is-accessor-descriptor": "^1.0.0", - "is-data-descriptor": "^1.0.0", - "kind-of": "^6.0.2" - } - }, - "isobject": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", - "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=" - }, - "kind-of": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz", - "integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==" - } - } - }, - "defined": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/defined/-/defined-1.0.0.tgz", - "integrity": "sha1-yY2bzvdWdBiOEQlpFRGZ45sfppM=" - }, - "del": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/del/-/del-4.1.1.tgz", - "integrity": "sha512-QwGuEUouP2kVwQenAsOof5Fv8K9t3D8Ca8NxcXKrIpEHjTXK5J2nXLdP+ALI1cgv8wj7KuwBhTwBkOZSJKM5XQ==", - "requires": { - "@types/glob": "^7.1.1", - "globby": "^6.1.0", - "is-path-cwd": "^2.0.0", - "is-path-in-cwd": "^2.0.0", - "p-map": "^2.0.0", - "pify": "^4.0.1", - "rimraf": "^2.6.3" - }, - "dependencies": { - "glob": { - "version": "7.1.4", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.4.tgz", - "integrity": "sha512-hkLPepehmnKk41pUGm3sYxoFs/umurYfYJCerbXEyFIWcAzvpipAgVkBqqT9RBKMGjnq6kMuyYwha6csxbiM1A==", - "requires": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.0.4", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" - } - }, - "pify": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/pify/-/pify-4.0.1.tgz", - "integrity": "sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g==" - }, - "rimraf": { - "version": "2.6.3", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.3.tgz", - "integrity": "sha512-mwqeW5XsA2qAejG46gYdENaxXjx9onRNCfn7L0duuP4hCuTIi/QO7PDK07KJfp1d+izWPrzEJDcSqBa0OZQriA==", - "requires": { - "glob": "^7.1.3" - } - } - } - }, - "delegates": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/delegates/-/delegates-1.0.0.tgz", - "integrity": "sha1-hMbhWbgZBP3KWaDvRM2HDTElD5o=" - }, - "depd": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz", - "integrity": "sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak=" - }, - "deps-sort": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/deps-sort/-/deps-sort-2.0.0.tgz", - "integrity": "sha1-CRckkC6EZYJg65EHSMzNGvbiH7U=", - "requires": { - "JSONStream": "^1.0.3", - "shasum": "^1.0.0", - "subarg": "^1.0.0", - "through2": "^2.0.0" - } - }, - "des.js": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/des.js/-/des.js-1.0.0.tgz", - "integrity": "sha1-wHTS4qpqipoH29YfmhXCzYPsjsw=", - "requires": { - "inherits": "^2.0.1", - "minimalistic-assert": "^1.0.0" - } - }, - "destroy": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz", - "integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA=" - }, - "detect-indent": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/detect-indent/-/detect-indent-4.0.0.tgz", - "integrity": "sha1-920GQ1LN9Docts5hnE7jqUdd4gg=", - "requires": { - "repeating": "^2.0.0" - } - }, - "detective": { - "version": "4.7.1", - "resolved": "https://registry.npmjs.org/detective/-/detective-4.7.1.tgz", - "integrity": "sha512-H6PmeeUcZloWtdt4DAkFyzFL94arpHr3NOwwmVILFiy+9Qd4JTxxXrzfyGk/lmct2qVGBwTSwSXagqu2BxmWig==", - "requires": { - "acorn": "^5.2.1", - "defined": "^1.0.0" - }, - "dependencies": { - "acorn": { - "version": "5.5.3", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.5.3.tgz", - "integrity": "sha512-jd5MkIUlbbmb07nXH0DT3y7rDVtkzDi4XZOUVWAer8ajmF/DTSSbl5oNFyDOl/OXA33Bl79+ypHhl2pN20VeOQ==" - } - } - }, - "diff": { - "version": "3.5.0", - "resolved": "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz", - "integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==" - }, - "diffie-hellman": { - "version": "5.0.3", - "resolved": "https://registry.npmjs.org/diffie-hellman/-/diffie-hellman-5.0.3.tgz", - "integrity": "sha512-kqag/Nl+f3GwyK25fhUMYj81BUOrZ9IuJsjIcDE5icNM9FJHAVm3VcUDxdLPoQtTuUylWm6ZIknYJwwaPxsUzg==", - "requires": { - "bn.js": "^4.1.0", - "miller-rabin": "^4.0.0", - "randombytes": "^2.0.0" - } - }, - "dir-glob": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/dir-glob/-/dir-glob-3.0.1.tgz", - "integrity": "sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA==", - "requires": { - "path-type": "^4.0.0" - }, - "dependencies": { - "path-type": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz", - "integrity": "sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==" - } - } - }, - "doctrine": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz", - "integrity": "sha512-yS+Q5i3hBf7GBkd4KG8a7eBNNWNGLTaEwwYWUijIYM7zrlYDM0BFXHjjPWlWZ1Rg7UaddZeIDmi9jF3HmqiQ2w==", - "requires": { - "esutils": "^2.0.2" - } - }, - "domain-browser": { - "version": "1.1.7", - "resolved": "https://registry.npmjs.org/domain-browser/-/domain-browser-1.1.7.tgz", - "integrity": "sha1-hnqksJP6oF8d4IwG9NeyH9+GmLw=" - }, - "dot-parts": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/dot-parts/-/dot-parts-1.0.1.tgz", - "integrity": "sha1-iEvXvPwwgv+tL+XbU+SU2PPgdD8=" - }, - "dot-prop": { - "version": "5.3.0", - "resolved": "https://registry.npmjs.org/dot-prop/-/dot-prop-5.3.0.tgz", - "integrity": "sha512-QM8q3zDe58hqUqjraQOmzZ1LIH9SWQJTlEKCH4kJ2oQvLZk7RbQXvtDM2XEq3fwkV9CCvvH4LA0AV+ogFsBM2Q==", - "requires": { - "is-obj": "^2.0.0" - }, - "dependencies": { - "is-obj": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/is-obj/-/is-obj-2.0.0.tgz", - "integrity": "sha512-drqDG3cbczxxEJRoOXcOjtdp1J/lyp1mNn0xaznRs8+muBhgQcrnbspox5X5fOw0HnMnbfDzvnEMEtqDEJEo8w==" - } - } - }, - "duplexer": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/duplexer/-/duplexer-0.1.1.tgz", - "integrity": "sha1-rOb/gIwc5mtX0ev5eXessCM0z8E=" - }, - "duplexer2": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/duplexer2/-/duplexer2-0.1.4.tgz", - "integrity": "sha1-ixLauHjA1p4+eJEFFmKjL8a93ME=", - "requires": { - "readable-stream": "^2.0.2" - } - }, - "duplexer3": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/duplexer3/-/duplexer3-0.1.4.tgz", - "integrity": "sha1-7gHdHKwO08vH/b6jfcCo8c4ALOI=" - }, - "ee-first": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", - "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=" - }, - "elliptic": { - "version": "6.5.4", - "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.4.tgz", - "integrity": "sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ==", - "requires": { - "bn.js": "^4.11.9", - "brorand": "^1.1.0", - "hash.js": "^1.0.0", - "hmac-drbg": "^1.0.1", - "inherits": "^2.0.4", - "minimalistic-assert": "^1.0.1", - "minimalistic-crypto-utils": "^1.0.1" - }, - "dependencies": { - "bn.js": { - "version": "4.12.0", - "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz", - "integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==" - }, - "inherits": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", - "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" - } - } - }, - "emittery": { - "version": "0.4.1", - "resolved": "https://registry.npmjs.org/emittery/-/emittery-0.4.1.tgz", - "integrity": "sha512-r4eRSeStEGf6M5SKdrQhhLK5bOwOBxQhIE3YSTnZE3GpKiLfnnhE+tPtrJE79+eDJgm39BM6LSoI8SCx4HbwlQ==" - }, - "emoji-regex": { - "version": "7.0.3", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-7.0.3.tgz", - "integrity": "sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA==" - }, - "empower-core": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/empower-core/-/empower-core-1.2.0.tgz", - "integrity": "sha512-g6+K6Geyc1o6FdXs9HwrXleCFan7d66G5xSCfSF7x1mJDCes6t0om9lFQG3zOrzh3Bkb/45N0cZ5Gqsf7YrzGQ==", - "requires": { - "call-signature": "0.0.2", - "core-js": "^2.0.0" - } - }, - "encodeurl": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", - "integrity": "sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k=" - }, - "end-of-stream": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.1.tgz", - "integrity": "sha512-1MkrZNvWTKCaigbn+W15elq2BB/L22nqrSY5DKlo3X6+vclJm8Bb5djXJBmEX6fS3+zCh/F4VBK5Z2KxJt4s2Q==", - "requires": { - "once": "^1.4.0" - } - }, - "equal-length": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/equal-length/-/equal-length-1.0.1.tgz", - "integrity": "sha1-IcoRLUirJLTh5//A5TOdMf38J0w=" - }, - "error-ex": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.1.tgz", - "integrity": "sha1-+FWobOYa3E6GIcPNoh56dhLDqNw=", - "requires": { - "is-arrayish": "^0.2.1" - } - }, - "es6-error": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/es6-error/-/es6-error-4.1.1.tgz", - "integrity": "sha512-Um/+FxMr9CISWh0bi5Zv0iOD+4cFh5qLeks1qhAopKVAJw3drgKbKySikp7wGhDL0HPeaja0P5ULZrxLkniUVg==" - }, - "escape-html": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", - "integrity": "sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg=" - }, - "escape-string-regexp": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", - "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=" - }, - "escodegen": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/escodegen/-/escodegen-1.1.0.tgz", - "integrity": "sha1-xmOSP24gqtSNDA+knzHG1PSTYM8=", - "requires": { - "esprima": "~1.0.4", - "estraverse": "~1.5.0", - "esutils": "~1.0.0", - "source-map": "~0.1.30" - }, - "dependencies": { - "esprima": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/esprima/-/esprima-1.0.4.tgz", - "integrity": "sha1-n1V+CPw7TSbs6d00+Pv0drYlha0=" - }, - "estraverse": { - "version": "1.5.1", - "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-1.5.1.tgz", - "integrity": "sha1-hno+jlip+EYYr7bC3bzZFrfLr3E=" - }, - "esutils": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/esutils/-/esutils-1.0.0.tgz", - "integrity": "sha1-gVHTWOIMisx/t0XnRywAJf5JZXA=" - }, - "source-map": { - "version": "0.1.43", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.1.43.tgz", - "integrity": "sha1-wkvBRspRfBRx9drL4lcbK3+eM0Y=", - "optional": true, - "requires": { - "amdefine": ">=0.0.4" - } - } - } - }, - "eslint": { - "version": "6.2.2", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-6.2.2.tgz", - "integrity": "sha512-mf0elOkxHbdyGX1IJEUsNBzCDdyoUgljF3rRlgfyYh0pwGnreLc0jjD6ZuleOibjmnUWZLY2eXwSooeOgGJ2jw==", - "requires": { - "@babel/code-frame": "^7.0.0", - "ajv": "^6.10.0", - "chalk": "^2.1.0", - "cross-spawn": "^6.0.5", - "debug": "^4.0.1", - "doctrine": "^3.0.0", - "eslint-scope": "^5.0.0", - "eslint-utils": "^1.4.2", - "eslint-visitor-keys": "^1.1.0", - "espree": "^6.1.1", - "esquery": "^1.0.1", - "esutils": "^2.0.2", - "file-entry-cache": "^5.0.1", - "functional-red-black-tree": "^1.0.1", - "glob-parent": "^5.0.0", - "globals": "^11.7.0", - "ignore": "^4.0.6", - "import-fresh": "^3.0.0", - "imurmurhash": "^0.1.4", - "inquirer": "^6.4.1", - "is-glob": "^4.0.0", - "js-yaml": "^3.13.1", - "json-stable-stringify-without-jsonify": "^1.0.1", - "levn": "^0.3.0", - "lodash": "^4.17.14", - "minimatch": "^3.0.4", - "mkdirp": "^0.5.1", - "natural-compare": "^1.4.0", - "optionator": "^0.8.2", - "progress": "^2.0.0", - "regexpp": "^2.0.1", - "semver": "^6.1.2", - "strip-ansi": "^5.2.0", - "strip-json-comments": "^3.0.1", - "table": "^5.2.3", - "text-table": "^0.2.0", - "v8-compile-cache": "^2.0.3" - }, - "dependencies": { - "ansi-regex": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", - "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==" - }, - "chardet": { - "version": "0.7.0", - "resolved": "https://registry.npmjs.org/chardet/-/chardet-0.7.0.tgz", - "integrity": "sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA==" - }, - "cross-spawn": { - "version": "6.0.5", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-6.0.5.tgz", - "integrity": "sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ==", - "requires": { - "nice-try": "^1.0.4", - "path-key": "^2.0.1", - "semver": "^5.5.0", - "shebang-command": "^1.2.0", - "which": "^1.2.9" - }, - "dependencies": { - "semver": { - "version": "5.7.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", - "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==" - } - } - }, - "debug": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", - "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", - "requires": { - "ms": "^2.1.1" - } - }, - "eslint-scope": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.0.0.tgz", - "integrity": "sha512-oYrhJW7S0bxAFDvWqzvMPRm6pcgcnWc4QnofCAqRTRfQC0JcwenzGglTtsLyIuuWFfkqDG9vz67cnttSd53djw==", - "requires": { - "esrecurse": "^4.1.0", - "estraverse": "^4.1.1" - } - }, - "eslint-visitor-keys": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.1.0.tgz", - "integrity": "sha512-8y9YjtM1JBJU/A9Kc+SbaOV4y29sSWckBwMHa+FGtVj5gN/sbnKDf6xJUl+8g7FAij9LVaP8C24DUiH/f/2Z9A==" - }, - "external-editor": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/external-editor/-/external-editor-3.1.0.tgz", - "integrity": "sha512-hMQ4CX1p1izmuLYyZqLMO/qGNw10wSv9QDCPfzXfyFrOaCSSoRfqE1Kf1s5an66J5JZC62NewG+mK49jOCtQew==", - "requires": { - "chardet": "^0.7.0", - "iconv-lite": "^0.4.24", - "tmp": "^0.0.33" - } - }, - "globals": { - "version": "11.12.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz", - "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==" - }, - "iconv-lite": { - "version": "0.4.24", - "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", - "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", - "requires": { - "safer-buffer": ">= 2.1.2 < 3" - } - }, - "ignore": { - "version": "4.0.6", - "resolved": "https://registry.npmjs.org/ignore/-/ignore-4.0.6.tgz", - "integrity": "sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg==" - }, - "inquirer": { - "version": "6.5.2", - "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-6.5.2.tgz", - "integrity": "sha512-cntlB5ghuB0iuO65Ovoi8ogLHiWGs/5yNrtUcKjFhSSiVeAIVpD7koaSU9RM8mpXw5YDi9RdYXGQMaOURB7ycQ==", - "requires": { - "ansi-escapes": "^3.2.0", - "chalk": "^2.4.2", - "cli-cursor": "^2.1.0", - "cli-width": "^2.0.0", - "external-editor": "^3.0.3", - "figures": "^2.0.0", - "lodash": "^4.17.12", - "mute-stream": "0.0.7", - "run-async": "^2.2.0", - "rxjs": "^6.4.0", - "string-width": "^2.1.0", - "strip-ansi": "^5.1.0", - "through": "^2.3.6" - }, - "dependencies": { - "chalk": { - "version": "2.4.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", - "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", - "requires": { - "ansi-styles": "^3.2.1", - "escape-string-regexp": "^1.0.5", - "supports-color": "^5.3.0" - } - } - } - }, - "semver": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==" - }, - "strip-ansi": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", - "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", - "requires": { - "ansi-regex": "^4.1.0" - } - }, - "strip-json-comments": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.0.1.tgz", - "integrity": "sha512-VTyMAUfdm047mwKl+u79WIdrZxtFtn+nBxHeb844XBQ9uMNTuTHdx2hc5RiAJYqwTj3wc/xe5HLSdJSkJ+WfZw==" - }, - "supports-color": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", - "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", - "requires": { - "has-flag": "^3.0.0" - } - } - } - }, - "eslint-config-prettier": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-6.1.0.tgz", - "integrity": "sha512-k9fny9sPjIBQ2ftFTesJV21Rg4R/7a7t7LCtZVrYQiHEp8Nnuk3EGaDmsKSAnsPj0BYcgB2zxzHa2NTkIxcOLg==", - "requires": { - "get-stdin": "^6.0.0" - }, - "dependencies": { - "get-stdin": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-6.0.0.tgz", - "integrity": "sha512-jp4tHawyV7+fkkSKyvjuLZswblUtz+SQKzSWnBbii16BuZksJlU1wuBYXY75r+duh/llF1ur6oNwi+2ZzjKZ7g==" - } - } - }, - "eslint-plugin-only-warn": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/eslint-plugin-only-warn/-/eslint-plugin-only-warn-1.0.1.tgz", - "integrity": "sha512-ckQiP40oGxrWjxY+UN6qr1DSWgsJwibICzsjBSyv6EPujZ/lta9zDe67ja7a3Wq27LiZ7B1nuBOamuigTxrbtQ==" - }, - "eslint-scope": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-4.0.3.tgz", - "integrity": "sha512-p7VutNr1O/QrxysMo3E45FjYDTeXBy0iTltPFNSqKAIfjDSXC+4dj+qfyuD8bfAXrW/y6lW3O76VaYNPKfpKrg==", - "requires": { - "esrecurse": "^4.1.0", - "estraverse": "^4.1.1" - } - }, - "eslint-utils": { - "version": "1.4.2", - "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-1.4.2.tgz", - "integrity": "sha512-eAZS2sEUMlIeCjBeubdj45dmBHQwPHWyBcT1VSYB7o9x9WRRqKxyUoiXlRjyAwzN7YEzHJlYg0NmzDRWx6GP4Q==", - "requires": { - "eslint-visitor-keys": "^1.0.0" - } - }, - "eslint-visitor-keys": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz", - "integrity": "sha512-qzm/XxIbxm/FHyH341ZrbnMUpe+5Bocte9xkmFMzPMjRaZMcXww+MpBptFvtU+79L362nqiLhekCxCxDPaUMBQ==" - }, - "esm": { - "version": "3.2.25", - "resolved": "https://registry.npmjs.org/esm/-/esm-3.2.25.tgz", - "integrity": "sha512-U1suiZ2oDVWv4zPO56S0NcR5QriEahGtdN2OR6FiOG4WJvcjBVFB0qI4+eKoWFH483PKGuLuu6V8Z4T5g63UVA==" - }, - "espower-location-detector": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/espower-location-detector/-/espower-location-detector-1.0.0.tgz", - "integrity": "sha1-oXt+zFnTDheeK+9z+0E3cEyzMbU=", - "requires": { - "is-url": "^1.2.1", - "path-is-absolute": "^1.0.0", - "source-map": "^0.5.0", - "xtend": "^4.0.0" - } - }, - "espree": { - "version": "6.1.1", - "resolved": "https://registry.npmjs.org/espree/-/espree-6.1.1.tgz", - "integrity": "sha512-EYbr8XZUhWbYCqQRW0duU5LxzL5bETN6AjKBGy1302qqzPaCH10QbRg3Wvco79Z8x9WbiE8HYB4e75xl6qUYvQ==", - "requires": { - "acorn": "^7.0.0", - "acorn-jsx": "^5.0.2", - "eslint-visitor-keys": "^1.1.0" - }, - "dependencies": { - "acorn": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.0.0.tgz", - "integrity": "sha512-PaF/MduxijYYt7unVGRuds1vBC9bFxbNf+VWqhOClfdgy7RlVkQqt610ig1/yxTgsDIfW1cWDel5EBbOy3jdtQ==" - }, - "eslint-visitor-keys": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.1.0.tgz", - "integrity": "sha512-8y9YjtM1JBJU/A9Kc+SbaOV4y29sSWckBwMHa+FGtVj5gN/sbnKDf6xJUl+8g7FAij9LVaP8C24DUiH/f/2Z9A==" - } - } - }, - "esprima": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", - "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==" - }, - "espurify": { - "version": "1.8.1", - "resolved": "https://registry.npmjs.org/espurify/-/espurify-1.8.1.tgz", - "integrity": "sha512-ZDko6eY/o+D/gHCWyHTU85mKDgYcS4FJj7S+YD6WIInm7GQ6AnOjmcL4+buFV/JOztVLELi/7MmuGU5NHta0Mg==", - "requires": { - "core-js": "^2.0.0" - } - }, - "esquery": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.0.1.tgz", - "integrity": "sha512-SmiyZ5zIWH9VM+SRUReLS5Q8a7GxtRdxEBVZpm98rJM7Sb+A9DVCndXfkeFUd3byderg+EbDkfnevfCwynWaNA==", - "requires": { - "estraverse": "^4.0.0" - } - }, - "esrecurse": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.2.1.tgz", - "integrity": "sha512-64RBB++fIOAXPw3P9cy89qfMlvZEXZkqqJkjqqXIvzP5ezRZjW+lPWjw35UX/3EhUPFYbg5ER4JYgDw4007/DQ==", - "requires": { - "estraverse": "^4.1.0" - } - }, - "estraverse": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.2.0.tgz", - "integrity": "sha1-De4/7TH81GlhjOc0IJn8GvoL2xM=" - }, - "estree-walker": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-0.2.1.tgz", - "integrity": "sha1-va/oCVOD2EFNXcLs9MkXO225QS4=" - }, - "esutils": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.2.tgz", - "integrity": "sha1-Cr9PHKpbyx96nYrMbepPqqBLrJs=" - }, - "etag": { - "version": "1.8.1", - "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", - "integrity": "sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc=" - }, - "event-stream": { - "version": "3.3.4", - "resolved": "https://registry.npmjs.org/event-stream/-/event-stream-3.3.4.tgz", - "integrity": "sha1-SrTJoPWlTbkzi0w02Gv86PSzVXE=", - "requires": { - "duplexer": "~0.1.1", - "from": "~0", - "map-stream": "~0.1.0", - "pause-stream": "0.0.11", - "split": "0.3", - "stream-combiner": "~0.0.4", - "through": "~2.3.1" - }, - "dependencies": { - "split": { - "version": "0.3.3", - "resolved": "https://registry.npmjs.org/split/-/split-0.3.3.tgz", - "integrity": "sha1-zQ7qXmOiEd//frDwkcQTPi0N0o8=", - "requires": { - "through": "2" - } - } - } - }, - "events": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/events/-/events-1.1.1.tgz", - "integrity": "sha1-nr23Y1rQmccNzEwqH1AEKI6L2SQ=" - }, - "evp_bytestokey": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/evp_bytestokey/-/evp_bytestokey-1.0.3.tgz", - "integrity": "sha1-f8vbGY3HGVlDLv4ThCaE4FJaywI=", - "requires": { - "md5.js": "^1.3.4", - "safe-buffer": "^5.1.1" - } - }, - "execa": { - "version": "0.7.0", - "resolved": "https://registry.npmjs.org/execa/-/execa-0.7.0.tgz", - "integrity": "sha1-lEvs00zEHuMqY6n68nrVpl/Fl3c=", - "requires": { - "cross-spawn": "^5.0.1", - "get-stream": "^3.0.0", - "is-stream": "^1.1.0", - "npm-run-path": "^2.0.0", - "p-finally": "^1.0.0", - "signal-exit": "^3.0.0", - "strip-eof": "^1.0.0" - } - }, - "expand-brackets": { - "version": "2.1.4", - "resolved": "https://registry.npmjs.org/expand-brackets/-/expand-brackets-2.1.4.tgz", - "integrity": "sha1-t3c14xXOMPa27/D4OwQVGiJEliI=", - "requires": { - "debug": "^2.3.3", - "define-property": "^0.2.5", - "extend-shallow": "^2.0.1", - "posix-character-classes": "^0.1.0", - "regex-not": "^1.0.0", - "snapdragon": "^0.8.1", - "to-regex": "^3.0.1" - }, - "dependencies": { - "define-property": { - "version": "0.2.5", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", - "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", - "requires": { - "is-descriptor": "^0.1.0" - } - }, - "extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "requires": { - "is-extendable": "^0.1.0" - } - } - } - }, - "exposify": { - "version": "0.5.0", - "resolved": "https://registry.npmjs.org/exposify/-/exposify-0.5.0.tgz", - "integrity": "sha1-+S0AlMJls/VT4fpFagOhiD0QWcw=", - "requires": { - "globo": "~1.1.0", - "map-obj": "~1.0.1", - "replace-requires": "~1.0.3", - "through2": "~0.4.0", - "transformify": "~0.1.1" - }, - "dependencies": { - "isarray": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=" - }, - "readable-stream": { - "version": "1.0.34", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", - "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=", - "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.1", - "isarray": "0.0.1", - "string_decoder": "~0.10.x" - } - }, - "string_decoder": { - "version": "0.10.31", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", - "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=" - }, - "through2": { - "version": "0.4.2", - "resolved": "https://registry.npmjs.org/through2/-/through2-0.4.2.tgz", - "integrity": "sha1-2/WGYDEVHsg1K7bE22SiKSqEC5s=", - "requires": { - "readable-stream": "~1.0.17", - "xtend": "~2.1.1" - } - }, - "xtend": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/xtend/-/xtend-2.1.2.tgz", - "integrity": "sha1-bv7MKk2tjmlixJAbM3znuoe10os=", - "requires": { - "object-keys": "~0.4.0" - } - } - } - }, - "express": { - "version": "4.16.3", - "resolved": "https://registry.npmjs.org/express/-/express-4.16.3.tgz", - "integrity": "sha1-avilAjUNsyRuzEvs9rWjTSL37VM=", - "requires": { - "accepts": "~1.3.5", - "array-flatten": "1.1.1", - "body-parser": "1.18.2", - "content-disposition": "0.5.2", - "content-type": "~1.0.4", - "cookie": "0.3.1", - "cookie-signature": "1.0.6", - "debug": "2.6.9", - "depd": "~1.1.2", - "encodeurl": "~1.0.2", - "escape-html": "~1.0.3", - "etag": "~1.8.1", - "finalhandler": "1.1.1", - "fresh": "0.5.2", - "merge-descriptors": "1.0.1", - "methods": "~1.1.2", - "on-finished": "~2.3.0", - "parseurl": "~1.3.2", - "path-to-regexp": "0.1.7", - "proxy-addr": "~2.0.3", - "qs": "6.5.1", - "range-parser": "~1.2.0", - "safe-buffer": "5.1.1", - "send": "0.16.2", - "serve-static": "1.13.2", - "setprototypeof": "1.1.0", - "statuses": "~1.4.0", - "type-is": "~1.6.16", - "utils-merge": "1.0.1", - "vary": "~1.1.2" - }, - "dependencies": { - "safe-buffer": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", - "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==" - } - } - }, - "extend-shallow": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-3.0.2.tgz", - "integrity": "sha1-Jqcarwc7OfshJxcnRhMcJwQCjbg=", - "requires": { - "assign-symbols": "^1.0.0", - "is-extendable": "^1.0.1" - }, - "dependencies": { - "is-extendable": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-1.0.1.tgz", - "integrity": "sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==", - "requires": { - "is-plain-object": "^2.0.4" - } - } - } - }, - "external-editor": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/external-editor/-/external-editor-2.2.0.tgz", - "integrity": "sha512-bSn6gvGxKt+b7+6TKEv1ZycHleA7aHhRHyAqJyp5pbUFuYYNIzpZnQDk7AsYckyWdEnTeAnay0aCy2aV6iTk9A==", - "requires": { - "chardet": "^0.4.0", - "iconv-lite": "^0.4.17", - "tmp": "^0.0.33" - } - }, - "extglob": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/extglob/-/extglob-2.0.4.tgz", - "integrity": "sha512-Nmb6QXkELsuBr24CJSkilo6UHHgbekK5UiZgfE6UHD3Eb27YC6oD+bhcT+tJ6cl8dmsgdQxnWlcry8ksBIBLpw==", - "requires": { - "array-unique": "^0.3.2", - "define-property": "^1.0.0", - "expand-brackets": "^2.1.4", - "extend-shallow": "^2.0.1", - "fragment-cache": "^0.2.1", - "regex-not": "^1.0.0", - "snapdragon": "^0.8.1", - "to-regex": "^3.0.1" - }, - "dependencies": { - "define-property": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", - "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", - "requires": { - "is-descriptor": "^1.0.0" - } - }, - "extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "requires": { - "is-extendable": "^0.1.0" - } - }, - "is-accessor-descriptor": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", - "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", - "requires": { - "kind-of": "^6.0.0" - } - }, - "is-data-descriptor": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", - "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", - "requires": { - "kind-of": "^6.0.0" - } - }, - "is-descriptor": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", - "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", - "requires": { - "is-accessor-descriptor": "^1.0.0", - "is-data-descriptor": "^1.0.0", - "kind-of": "^6.0.2" - } - }, - "kind-of": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz", - "integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==" - } - } - }, - "fast-deep-equal": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz", - "integrity": "sha1-ewUhjd+WZ79/Nwv3/bLLFf3Qqkk=" - }, - "fast-diff": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/fast-diff/-/fast-diff-1.2.0.tgz", - "integrity": "sha512-xJuoT5+L99XlZ8twedaRf6Ax2TgQVxvgZOYoPKqZufmJib0tL2tegPBOZb1pVNgIhlqDlA0eO0c3wBvQcmzx4w==" - }, - "fast-glob": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.0.4.tgz", - "integrity": "sha512-wkIbV6qg37xTJwqSsdnIphL1e+LaGz4AIQqr00mIubMaEhv1/HEmJ0uuCGZRNRUkZZmOB5mJKO0ZUTVq+SxMQg==", - "requires": { - "@nodelib/fs.stat": "^2.0.1", - "@nodelib/fs.walk": "^1.2.1", - "glob-parent": "^5.0.0", - "is-glob": "^4.0.1", - "merge2": "^1.2.3", - "micromatch": "^4.0.2" - }, - "dependencies": { - "glob-parent": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.0.0.tgz", - "integrity": "sha512-Z2RwiujPRGluePM6j699ktJYxmPpJKCfpGA13jz2hmFZC7gKetzrWvg5KN3+OsIFmydGyZ1AVwERCq1w/ZZwRg==", - "requires": { - "is-glob": "^4.0.1" - } - } - } - }, - "fast-json-stable-stringify": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz", - "integrity": "sha1-1RQsDK7msRifh9OnYREGT4bIu/I=" - }, - "fast-levenshtein": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", - "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=" - }, - "fastq": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.6.0.tgz", - "integrity": "sha512-jmxqQ3Z/nXoeyDmWAzF9kH1aGZSis6e/SbfPmJpUnyZ0ogr6iscHQaml4wsEepEWSdtmpy+eVXmCRIMpxaXqOA==", - "requires": { - "reusify": "^1.0.0" - } - }, - "figures": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/figures/-/figures-2.0.0.tgz", - "integrity": "sha1-OrGi0qYsi/tDGgyUy3l6L84nyWI=", - "requires": { - "escape-string-regexp": "^1.0.5" - } - }, - "file-entry-cache": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-5.0.1.tgz", - "integrity": "sha512-bCg29ictuBaKUwwArK4ouCaqDgLZcysCFLmM/Yn/FDoqndh/9vNuQfXRDvTuXKLxfD/JtZQGKFT8MGcJBK644g==", - "requires": { - "flat-cache": "^2.0.1" - } - }, - "fill-range": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-4.0.0.tgz", - "integrity": "sha1-1USBHUKPmOsGpj3EAtJAPDKMOPc=", - "requires": { - "extend-shallow": "^2.0.1", - "is-number": "^3.0.0", - "repeat-string": "^1.6.1", - "to-regex-range": "^2.1.0" - }, - "dependencies": { - "extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "requires": { - "is-extendable": "^0.1.0" - } - } - } - }, - "finalhandler": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.1.1.tgz", - "integrity": "sha512-Y1GUDo39ez4aHAw7MysnUD5JzYX+WaIj8I57kO3aEPT1fFRL4sr7mjei97FgnwhAyyzRYmQZaTHb2+9uZ1dPtg==", - "requires": { - "debug": "2.6.9", - "encodeurl": "~1.0.2", - "escape-html": "~1.0.3", - "on-finished": "~2.3.0", - "parseurl": "~1.3.2", - "statuses": "~1.4.0", - "unpipe": "~1.0.0" - } - }, - "find-parent-dir": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/find-parent-dir/-/find-parent-dir-0.3.0.tgz", - "integrity": "sha1-M8RLQpqysvBkYpnF+fcY83b/jVQ=" - }, - "find-up": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-2.1.0.tgz", - "integrity": "sha1-RdG35QbHF93UgndaK3eSCjwMV6c=", - "requires": { - "locate-path": "^2.0.0" - } - }, - "flat-cache": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-2.0.1.tgz", - "integrity": "sha512-LoQe6yDuUMDzQAEH8sgmh4Md6oZnc/7PjtwjNFSzveXqSHt6ka9fPBuso7IGf9Rz4uqnSnWiFH2B/zj24a5ReA==", - "requires": { - "flatted": "^2.0.0", - "rimraf": "2.6.3", - "write": "1.0.3" - }, - "dependencies": { - "glob": { - "version": "7.1.4", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.4.tgz", - "integrity": "sha512-hkLPepehmnKk41pUGm3sYxoFs/umurYfYJCerbXEyFIWcAzvpipAgVkBqqT9RBKMGjnq6kMuyYwha6csxbiM1A==", - "requires": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.0.4", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" - } - }, - "rimraf": { - "version": "2.6.3", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.3.tgz", - "integrity": "sha512-mwqeW5XsA2qAejG46gYdENaxXjx9onRNCfn7L0duuP4hCuTIi/QO7PDK07KJfp1d+izWPrzEJDcSqBa0OZQriA==", - "requires": { - "glob": "^7.1.3" - } - } - } - }, - "flatted": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/flatted/-/flatted-2.0.1.tgz", - "integrity": "sha512-a1hQMktqW9Nmqr5aktAux3JMNqaucxGcjtjWnZLHX7yyPCmlSV3M54nGYbqT8K+0GhF3NBgmJCc3ma+WOgX8Jg==" - }, - "fn-name": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/fn-name/-/fn-name-2.0.1.tgz", - "integrity": "sha1-UhTXU3pNBqSjAcDMJi/rhBiAAuc=" - }, - "for-in": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz", - "integrity": "sha1-gQaNKVqBQuwKxybG4iAMMPttXoA=" - }, - "forwarded": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.1.2.tgz", - "integrity": "sha1-mMI9qxF1ZXuMBXPozszZGw/xjIQ=" - }, - "fragment-cache": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/fragment-cache/-/fragment-cache-0.2.1.tgz", - "integrity": "sha1-QpD60n8T6Jvn8zeZxrxaCr//DRk=", - "requires": { - "map-cache": "^0.2.2" - } - }, - "fresh": { - "version": "0.5.2", - "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", - "integrity": "sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac=" - }, - "from": { - "version": "0.1.7", - "resolved": "https://registry.npmjs.org/from/-/from-0.1.7.tgz", - "integrity": "sha1-g8YK/Fi5xWmXAH7Rp2izqzA6RP4=" - }, - "fs-extra": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-4.0.3.tgz", - "integrity": "sha1-DYUhIuW8W+tFP7Ao6cDJvzY0DJQ=", - "requires": { - "graceful-fs": "^4.1.2", - "jsonfile": "^4.0.0", - "universalify": "^0.1.0" - } - }, - "fs.realpath": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", - "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" - }, - "fsevents": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.1.2.tgz", - "integrity": "sha512-R4wDiBwZ0KzpgOWetKDug1FZcYhqYnUYKtfZYt4mD5SBz76q0KR4Q9o7GIPamsVPGmW3EYPPJ0dOOjvx32ldZA==", - "optional": true - }, - "function-bind": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", - "integrity": "sha1-pWiZ0+o8m6uHS7l3O3xe3pL0iV0=" - }, - "functional-red-black-tree": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz", - "integrity": "sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc=" - }, - "gauge": { - "version": "2.7.4", - "resolved": "https://registry.npmjs.org/gauge/-/gauge-2.7.4.tgz", - "integrity": "sha1-LANAXHU4w51+s3sxcCLjJfsBi/c=", - "requires": { - "aproba": "^1.0.3", - "console-control-strings": "^1.0.0", - "has-unicode": "^2.0.0", - "object-assign": "^4.1.0", - "signal-exit": "^3.0.0", - "string-width": "^1.0.1", - "strip-ansi": "^3.0.1", - "wide-align": "^1.1.0" - }, - "dependencies": { - "is-fullwidth-code-point": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", - "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", - "requires": { - "number-is-nan": "^1.0.0" - } - }, - "string-width": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", - "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", - "requires": { - "code-point-at": "^1.0.0", - "is-fullwidth-code-point": "^1.0.0", - "strip-ansi": "^3.0.0" - } - }, - "strip-ansi": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", - "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", - "requires": { - "ansi-regex": "^2.0.0" - } - } - } - }, - "get-caller-file": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-1.0.3.tgz", - "integrity": "sha512-3t6rVToeoZfYSGd8YoLFR2DJkiQrIiUrGcjvFX2mDw3bn6k2OtwHN0TNCLbBO+w8qTvimhDkv+LSscbJY1vE6w==" - }, - "get-func-name": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.0.tgz", - "integrity": "sha512-Hm0ixYtaSZ/V7C8FJrtZIuBBI+iSgL+1Aq82zSu8VQNB4S3Gk8e7Qs3VwBDJAhmRZcFqkl3tQu36g/Foh5I5ig==" - }, - "get-pkg-repo": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/get-pkg-repo/-/get-pkg-repo-1.4.0.tgz", - "integrity": "sha1-xztInAbYDMVTbCyFP54FIyBWly0=", - "requires": { - "hosted-git-info": "^2.1.4", - "meow": "^3.3.0", - "normalize-package-data": "^2.3.0", - "parse-github-repo-url": "^1.3.0", - "through2": "^2.0.0" - } - }, - "get-port": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/get-port/-/get-port-3.2.0.tgz", - "integrity": "sha1-3Xzn3hh8Bsi/NTeWrHHgmfCYDrw=" - }, - "get-stdin": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-4.0.1.tgz", - "integrity": "sha1-uWjGsKBDhDJJAui/Gl3zJXmkUP4=" - }, - "get-stream": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", - "integrity": "sha1-jpQ9E1jcN1VQVOy+LtsFqhdO3hQ=" - }, - "get-value": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/get-value/-/get-value-2.0.6.tgz", - "integrity": "sha1-3BXKHGcjh8p2vTesCjlbogQqLCg=" - }, - "git-raw-commits": { - "version": "1.3.6", - "resolved": "https://registry.npmjs.org/git-raw-commits/-/git-raw-commits-1.3.6.tgz", - "integrity": "sha512-svsK26tQ8vEKnMshTDatSIQSMDdz8CxIIqKsvPqbtV23Etmw6VNaFAitu8zwZ0VrOne7FztwPyRLxK7/DIUTQg==", - "requires": { - "dargs": "^4.0.1", - "lodash.template": "^4.0.2", - "meow": "^4.0.0", - "split2": "^2.0.0", - "through2": "^2.0.0" - }, - "dependencies": { - "camelcase": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-4.1.0.tgz", - "integrity": "sha1-1UVjW+HjPFQmScaRc+Xeas+uNN0=" - }, - "camelcase-keys": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/camelcase-keys/-/camelcase-keys-4.2.0.tgz", - "integrity": "sha1-oqpfsa9oh1glnDLBQUJteJI7m3c=", - "requires": { - "camelcase": "^4.1.0", - "map-obj": "^2.0.0", - "quick-lru": "^1.0.0" - } - }, - "load-json-file": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-4.0.0.tgz", - "integrity": "sha1-L19Fq5HjMhYjT9U62rZo607AmTs=", - "requires": { - "graceful-fs": "^4.1.2", - "parse-json": "^4.0.0", - "pify": "^3.0.0", - "strip-bom": "^3.0.0" - } - }, - "map-obj": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/map-obj/-/map-obj-2.0.0.tgz", - "integrity": "sha1-plzSkIepJZi4eRJXpSPgISIqwfk=" - }, - "meow": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/meow/-/meow-4.0.1.tgz", - "integrity": "sha512-xcSBHD5Z86zaOc+781KrupuHAzeGXSLtiAOmBsiLDiPSaYSB6hdew2ng9EBAnZ62jagG9MHAOdxpDi/lWBFJ/A==", - "requires": { - "camelcase-keys": "^4.0.0", - "decamelize-keys": "^1.0.0", - "loud-rejection": "^1.0.0", - "minimist": "^1.1.3", - "minimist-options": "^3.0.1", - "normalize-package-data": "^2.3.4", - "read-pkg-up": "^3.0.0", - "redent": "^2.0.0", - "trim-newlines": "^2.0.0" - } - }, - "minimist": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", - "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" - }, - "parse-json": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-4.0.0.tgz", - "integrity": "sha1-vjX1Qlvh9/bHRxhPmKeIy5lHfuA=", - "requires": { - "error-ex": "^1.3.1", - "json-parse-better-errors": "^1.0.1" - } - }, - "path-type": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/path-type/-/path-type-3.0.0.tgz", - "integrity": "sha512-T2ZUsdZFHgA3u4e5PfPbjd7HDDpxPnQb5jN0SrDsjNSuVXHJqtwTnWqG0B1jZrgmJ/7lj1EmVIByWt1gxGkWvg==", - "requires": { - "pify": "^3.0.0" - } - }, - "pify": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/pify/-/pify-3.0.0.tgz", - "integrity": "sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY=" - }, - "read-pkg": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-3.0.0.tgz", - "integrity": "sha1-nLxoaXj+5l0WwA4rGcI3/Pbjg4k=", - "requires": { - "load-json-file": "^4.0.0", - "normalize-package-data": "^2.3.2", - "path-type": "^3.0.0" - } - }, - "read-pkg-up": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-3.0.0.tgz", - "integrity": "sha1-PtSWaF26D4/hGNBpHcUfSh/5bwc=", - "requires": { - "find-up": "^2.0.0", - "read-pkg": "^3.0.0" - } - }, - "redent": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/redent/-/redent-2.0.0.tgz", - "integrity": "sha1-wbIAe0LVfrE4kHmzyDM2OdXhzKo=", - "requires": { - "indent-string": "^3.0.0", - "strip-indent": "^2.0.0" - } - }, - "strip-indent": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/strip-indent/-/strip-indent-2.0.0.tgz", - "integrity": "sha1-XvjbKV0B5u1sv3qrlpmNeCJSe2g=" - }, - "trim-newlines": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/trim-newlines/-/trim-newlines-2.0.0.tgz", - "integrity": "sha1-tAPQuRvlDDMd/EuC7s6yLD3hbSA=" - } - } - }, - "git-remote-origin-url": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/git-remote-origin-url/-/git-remote-origin-url-2.0.0.tgz", - "integrity": "sha1-UoJlna4hBxRaERJhEq0yFuxfpl8=", - "requires": { - "gitconfiglocal": "^1.0.0", - "pify": "^2.3.0" - } - }, - "git-semver-tags": { - "version": "1.3.6", - "resolved": "https://registry.npmjs.org/git-semver-tags/-/git-semver-tags-1.3.6.tgz", - "integrity": "sha512-2jHlJnln4D/ECk9FxGEBh3k44wgYdWjWDtMmJPaecjoRmxKo3Y1Lh8GMYuOPu04CHw86NTAODchYjC5pnpMQig==", - "requires": { - "meow": "^4.0.0", - "semver": "^5.5.0" - }, - "dependencies": { - "camelcase": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-4.1.0.tgz", - "integrity": "sha1-1UVjW+HjPFQmScaRc+Xeas+uNN0=" - }, - "camelcase-keys": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/camelcase-keys/-/camelcase-keys-4.2.0.tgz", - "integrity": "sha1-oqpfsa9oh1glnDLBQUJteJI7m3c=", - "requires": { - "camelcase": "^4.1.0", - "map-obj": "^2.0.0", - "quick-lru": "^1.0.0" - } - }, - "load-json-file": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-4.0.0.tgz", - "integrity": "sha1-L19Fq5HjMhYjT9U62rZo607AmTs=", - "requires": { - "graceful-fs": "^4.1.2", - "parse-json": "^4.0.0", - "pify": "^3.0.0", - "strip-bom": "^3.0.0" - } - }, - "map-obj": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/map-obj/-/map-obj-2.0.0.tgz", - "integrity": "sha1-plzSkIepJZi4eRJXpSPgISIqwfk=" - }, - "meow": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/meow/-/meow-4.0.1.tgz", - "integrity": "sha512-xcSBHD5Z86zaOc+781KrupuHAzeGXSLtiAOmBsiLDiPSaYSB6hdew2ng9EBAnZ62jagG9MHAOdxpDi/lWBFJ/A==", - "requires": { - "camelcase-keys": "^4.0.0", - "decamelize-keys": "^1.0.0", - "loud-rejection": "^1.0.0", - "minimist": "^1.1.3", - "minimist-options": "^3.0.1", - "normalize-package-data": "^2.3.4", - "read-pkg-up": "^3.0.0", - "redent": "^2.0.0", - "trim-newlines": "^2.0.0" - } - }, - "minimist": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", - "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" - }, - "parse-json": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-4.0.0.tgz", - "integrity": "sha1-vjX1Qlvh9/bHRxhPmKeIy5lHfuA=", - "requires": { - "error-ex": "^1.3.1", - "json-parse-better-errors": "^1.0.1" - } - }, - "path-type": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/path-type/-/path-type-3.0.0.tgz", - "integrity": "sha512-T2ZUsdZFHgA3u4e5PfPbjd7HDDpxPnQb5jN0SrDsjNSuVXHJqtwTnWqG0B1jZrgmJ/7lj1EmVIByWt1gxGkWvg==", - "requires": { - "pify": "^3.0.0" - } - }, - "pify": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/pify/-/pify-3.0.0.tgz", - "integrity": "sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY=" - }, - "read-pkg": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-3.0.0.tgz", - "integrity": "sha1-nLxoaXj+5l0WwA4rGcI3/Pbjg4k=", - "requires": { - "load-json-file": "^4.0.0", - "normalize-package-data": "^2.3.2", - "path-type": "^3.0.0" - } - }, - "read-pkg-up": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-3.0.0.tgz", - "integrity": "sha1-PtSWaF26D4/hGNBpHcUfSh/5bwc=", - "requires": { - "find-up": "^2.0.0", - "read-pkg": "^3.0.0" - } - }, - "redent": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/redent/-/redent-2.0.0.tgz", - "integrity": "sha1-wbIAe0LVfrE4kHmzyDM2OdXhzKo=", - "requires": { - "indent-string": "^3.0.0", - "strip-indent": "^2.0.0" - } - }, - "strip-indent": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/strip-indent/-/strip-indent-2.0.0.tgz", - "integrity": "sha1-XvjbKV0B5u1sv3qrlpmNeCJSe2g=" - }, - "trim-newlines": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/trim-newlines/-/trim-newlines-2.0.0.tgz", - "integrity": "sha1-tAPQuRvlDDMd/EuC7s6yLD3hbSA=" - } - } - }, - "gitconfiglocal": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/gitconfiglocal/-/gitconfiglocal-1.0.0.tgz", - "integrity": "sha1-QdBF84UaXqiPA/JMocYXgRRGS5s=", - "requires": { - "ini": "^1.3.2" - } - }, - "glob": { - "version": "7.1.2", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", - "integrity": "sha1-wZyd+aAocC1nhhI4SmVSQExjbRU=", - "requires": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.0.4", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" - } - }, - "glob-parent": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.0.0.tgz", - "integrity": "sha512-Z2RwiujPRGluePM6j699ktJYxmPpJKCfpGA13jz2hmFZC7gKetzrWvg5KN3+OsIFmydGyZ1AVwERCq1w/ZZwRg==", - "requires": { - "is-glob": "^4.0.1" - } - }, - "global-dirs": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/global-dirs/-/global-dirs-0.1.1.tgz", - "integrity": "sha1-sxnA3UYH81PzvpzKTHL8FIxJ9EU=", - "requires": { - "ini": "^1.3.4" - } - }, - "globals": { - "version": "9.18.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-9.18.0.tgz", - "integrity": "sha1-qjiWs+abSH8X4x7SFD1pqOMMLYo=" - }, - "globby": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/globby/-/globby-6.1.0.tgz", - "integrity": "sha1-9abXDoOV4hyFj7BInWTfAkJNUGw=", - "requires": { - "array-union": "^1.0.1", - "glob": "^7.0.3", - "object-assign": "^4.0.1", - "pify": "^2.0.0", - "pinkie-promise": "^2.0.0" - }, - "dependencies": { - "pinkie": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/pinkie/-/pinkie-2.0.4.tgz", - "integrity": "sha1-clVrgM+g1IqXToDnckjoDtT3+HA=" - }, - "pinkie-promise": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/pinkie-promise/-/pinkie-promise-2.0.1.tgz", - "integrity": "sha1-ITXW36ejWMBprJsXh3YogihFD/o=", - "requires": { - "pinkie": "^2.0.0" - } - } - } - }, - "globo": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/globo/-/globo-1.1.0.tgz", - "integrity": "sha1-DSYJiVXepCLrIAGxBImLChAcqvM=", - "requires": { - "accessory": "~1.1.0", - "is-defined": "~1.0.0", - "ternary": "~1.0.0" - } - }, - "got": { - "version": "6.7.1", - "resolved": "https://registry.npmjs.org/got/-/got-6.7.1.tgz", - "integrity": "sha1-JAzQV4WpoY5WHcG0S0HHY+8ejbA=", - "requires": { - "create-error-class": "^3.0.0", - "duplexer3": "^0.1.4", - "get-stream": "^3.0.0", - "is-redirect": "^1.0.0", - "is-retry-allowed": "^1.0.0", - "is-stream": "^1.0.0", - "lowercase-keys": "^1.0.0", - "safe-buffer": "^5.0.1", - "timed-out": "^4.0.0", - "unzip-response": "^2.0.1", - "url-parse-lax": "^1.0.0" - } - }, - "graceful-fs": { - "version": "4.1.11", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", - "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=" - }, - "grapheme-splitter": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/grapheme-splitter/-/grapheme-splitter-1.0.2.tgz", - "integrity": "sha1-Y56dwb8GWJLGQ94x2qJ89YsQaOI=" - }, - "handlebars": { - "version": "4.7.7", - "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.7.7.tgz", - "integrity": "sha512-aAcXm5OAfE/8IXkcZvCepKU3VzW1/39Fb5ZuqMtgI/hT8X2YgoMvBY5dLhq/cpOvw7Lk1nK/UF71aLG/ZnVYRA==", - "requires": { - "minimist": "^1.2.5", - "neo-async": "^2.6.0", - "source-map": "^0.6.1", - "uglify-js": "^3.1.4", - "wordwrap": "^1.0.0" - }, - "dependencies": { - "source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==" - } - } - }, - "has": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/has/-/has-1.0.1.tgz", - "integrity": "sha1-hGFzP1OLCDfJNh45qauelwTcLyg=", - "requires": { - "function-bind": "^1.0.2" - } - }, - "has-ansi": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", - "integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=", - "requires": { - "ansi-regex": "^2.0.0" - } - }, - "has-flag": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", - "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=" - }, - "has-require": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/has-require/-/has-require-1.2.2.tgz", - "integrity": "sha1-khZ1qxMNvZdo/I2o8ajiQt+kF3Q=", - "requires": { - "escape-string-regexp": "^1.0.3" - } - }, - "has-symbols": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.0.tgz", - "integrity": "sha1-uhqPGvKg/DllD1yFA2dwQSIGO0Q=" - }, - "has-unicode": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/has-unicode/-/has-unicode-2.0.1.tgz", - "integrity": "sha1-4Ob+aijPUROIVeCG0Wkedx3iqLk=" - }, - "has-value": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/has-value/-/has-value-1.0.0.tgz", - "integrity": "sha1-GLKB2lhbHFxR3vJMkw7SmgvmsXc=", - "requires": { - "get-value": "^2.0.6", - "has-values": "^1.0.0", - "isobject": "^3.0.0" - }, - "dependencies": { - "isobject": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", - "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=" - } - } - }, - "has-values": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/has-values/-/has-values-1.0.0.tgz", - "integrity": "sha1-lbC2P+whRmGab+V/51Yo1aOe/k8=", - "requires": { - "is-number": "^3.0.0", - "kind-of": "^4.0.0" - }, - "dependencies": { - "is-number": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-number/-/is-number-3.0.0.tgz", - "integrity": "sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU=", - "requires": { - "kind-of": "^3.0.2" - }, - "dependencies": { - "kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "requires": { - "is-buffer": "^1.1.5" - } - } - } - }, - "kind-of": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-4.0.0.tgz", - "integrity": "sha1-IIE989cSkosgc3hpGkUGb65y3Vc=", - "requires": { - "is-buffer": "^1.1.5" - } - } - } - }, - "has-yarn": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/has-yarn/-/has-yarn-2.1.0.tgz", - "integrity": "sha512-UqBRqi4ju7T+TqGNdqAO0PaSVGsDGJUBQvk9eUWNGRY1CFGDzYhLWoM7JQEemnlvVcv/YEmc2wNW8BC24EnUsw==" - }, - "hash-base": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/hash-base/-/hash-base-3.0.4.tgz", - "integrity": "sha1-X8hoaEfs1zSZQDMZprCj8/auSRg=", - "requires": { - "inherits": "^2.0.1", - "safe-buffer": "^5.0.1" - } - }, - "hash.js": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/hash.js/-/hash.js-1.1.3.tgz", - "integrity": "sha1-NA3tvmKQGHFRweodd3o0SJNd+EY=", - "requires": { - "inherits": "^2.0.3", - "minimalistic-assert": "^1.0.0" - } - }, - "hasha": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/hasha/-/hasha-5.0.0.tgz", - "integrity": "sha512-PqWdhnQhq6tqD32hZv+l1e5mJHNSudjnaAzgAHfkGiU0ABN6lmbZF8abJIulQHbZ7oiHhP8yL6O910ICMc+5pw==", - "requires": { - "is-stream": "^1.1.0", - "type-fest": "^0.3.0" - }, - "dependencies": { - "type-fest": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.3.1.tgz", - "integrity": "sha512-cUGJnCdr4STbePCgqNFbpVNCepa+kAVohJs1sLhxzdH+gnEoOd8VhbYa7pD3zZYGiURWM2xzEII3fQcRizDkYQ==" - } - } - }, - "hmac-drbg": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/hmac-drbg/-/hmac-drbg-1.0.1.tgz", - "integrity": "sha1-0nRXAQJabHdabFRXk+1QL8DGSaE=", - "requires": { - "hash.js": "^1.0.3", - "minimalistic-assert": "^1.0.0", - "minimalistic-crypto-utils": "^1.0.1" - } - }, - "home-or-tmp": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/home-or-tmp/-/home-or-tmp-2.0.0.tgz", - "integrity": "sha1-42w/LSyufXRqhX440Y1fMqeILbg=", - "requires": { - "os-homedir": "^1.0.0", - "os-tmpdir": "^1.0.1" - } - }, - "homedir-polyfill": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/homedir-polyfill/-/homedir-polyfill-1.0.1.tgz", - "integrity": "sha1-TCu8inWJmP7r9e1oWA921GdotLw=", - "requires": { - "parse-passwd": "^1.0.0" - } - }, - "hosted-git-info": { - "version": "2.8.9", - "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.9.tgz", - "integrity": "sha512-mxIDAb9Lsm6DoOJ7xH+5+X4y1LU/4Hi50L9C5sIswK3JzULS4bwk1FvjdBgvYR4bzT4tuUQiC15FE2f5HbLvYw==" - }, - "htmlescape": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/htmlescape/-/htmlescape-1.1.1.tgz", - "integrity": "sha1-OgPtwiFLyjtmQko+eVk0lQnLA1E=" - }, - "http-cache-semantics": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-4.0.3.tgz", - "integrity": "sha512-TcIMG3qeVLgDr1TEd2XvHaTnMPwYQUQMIBLy+5pLSDKYFc7UIqj39w8EGzZkaxoLv/l2K8HaI0t5AVA+YYgUew==" - }, - "http-errors": { - "version": "1.6.3", - "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.6.3.tgz", - "integrity": "sha1-i1VoC7S+KDoLW/TqLjhYC+HZMg0=", - "requires": { - "depd": "~1.1.2", - "inherits": "2.0.3", - "setprototypeof": "1.1.0", - "statuses": ">= 1.4.0 < 2" - } - }, - "https-browserify": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/https-browserify/-/https-browserify-1.0.0.tgz", - "integrity": "sha1-7AbBDgo0wPL68Zn3/X/Hj//QPHM=" - }, - "iconv-lite": { - "version": "0.4.19", - "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.19.tgz", - "integrity": "sha1-90aPYBNfXl2tM5nAqBvpoWA6CCs=" - }, - "ieee754": { - "version": "1.1.11", - "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.1.11.tgz", - "integrity": "sha512-VhDzCKN7K8ufStx/CLj5/PDTMgph+qwN5Pkd5i0sGnVwk56zJ0lkT8Qzi1xqWLS0Wp29DgDtNeS7v8/wMoZeHg==" - }, - "ignore": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.1.2.tgz", - "integrity": "sha512-vdqWBp7MyzdmHkkRWV5nY+PfGRbYbahfuvsBCh277tq+w9zyNi7h5CYJCK0kmzti9kU+O/cB7sE8HvKv6aXAKQ==" - }, - "ignore-by-default": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/ignore-by-default/-/ignore-by-default-1.0.1.tgz", - "integrity": "sha1-SMptcvbGo68Aqa1K5odr44ieKwk=" - }, - "import-fresh": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.1.0.tgz", - "integrity": "sha512-PpuksHKGt8rXfWEr9m9EHIpgyyaltBy8+eF6GJM0QCAxMgxCfucMF3mjecK2QsJr0amJW7gTqh5/wht0z2UhEQ==", - "requires": { - "parent-module": "^1.0.0", - "resolve-from": "^4.0.0" - }, - "dependencies": { - "resolve-from": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", - "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==" - } - } - }, - "import-lazy": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/import-lazy/-/import-lazy-2.1.0.tgz", - "integrity": "sha1-BWmOPUXIjo1+nZLLBYTnfwlvPkM=" - }, - "import-local": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/import-local/-/import-local-3.0.1.tgz", - "integrity": "sha512-XlabwTJ9tPOdyjnGdGvxUMnUhmhlnJhdYjp5e8UDb2fO+5Gto1Frlg66ixVAf1Os+zQlrKt3QlTCVodyxYBZjQ==", - "requires": { - "pkg-dir": "^4.2.0", - "resolve-cwd": "^3.0.0" - } - }, - "imurmurhash": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", - "integrity": "sha1-khi5srkoojixPcT7a21XbyMUU+o=" - }, - "indent-string": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/indent-string/-/indent-string-3.2.0.tgz", - "integrity": "sha1-Sl/W0nzDMvN+VBmlBNu4NxBckok=" - }, - "indexof": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/indexof/-/indexof-0.0.1.tgz", - "integrity": "sha1-gtwzbSMrkGIXnQWrMpOmYFn9Q10=" - }, - "inflight": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", - "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", - "requires": { - "once": "^1.3.0", - "wrappy": "1" - } - }, - "inherits": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" - }, - "ini": { - "version": "1.3.5", - "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz", - "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==" - }, - "inline-source-map": { - "version": "0.6.2", - "resolved": "https://registry.npmjs.org/inline-source-map/-/inline-source-map-0.6.2.tgz", - "integrity": "sha1-+Tk0ccGKedFyT4Y/o4tYY3Ct4qU=", - "requires": { - "source-map": "~0.5.3" - } - }, - "inquirer": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-3.3.0.tgz", - "integrity": "sha1-ndLyrXZdyrH/BEO0kUQqILoifck=", - "requires": { - "ansi-escapes": "^3.0.0", - "chalk": "^2.0.0", - "cli-cursor": "^2.1.0", - "cli-width": "^2.0.0", - "external-editor": "^2.0.4", - "figures": "^2.0.0", - "lodash": "^4.3.0", - "mute-stream": "0.0.7", - "run-async": "^2.2.0", - "rx-lite": "^4.0.8", - "rx-lite-aggregates": "^4.0.8", - "string-width": "^2.1.0", - "strip-ansi": "^4.0.0", - "through": "^2.3.6" - }, - "dependencies": { - "ansi-escapes": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-3.1.0.tgz", - "integrity": "sha512-UgAb8H9D41AQnu/PbWlCofQVcnV4Gs2bBJi9eZPxfU/hgglFh3SMDMENRIqdr7H6XFnXdoknctFByVsCOotTVw==" - } - } - }, - "insert-module-globals": { - "version": "7.1.0", - "resolved": "https://registry.npmjs.org/insert-module-globals/-/insert-module-globals-7.1.0.tgz", - "integrity": "sha512-LbYZdybvKjbbcKLp03lB323Cgc8f0iL0Rjh8U6JZ7K1gZSf7MxQH191iCNUcLX4qIQ6/yWe4Q4ZsQ+opcReNFg==", - "requires": { - "JSONStream": "^1.0.3", - "combine-source-map": "^0.8.0", - "concat-stream": "^1.6.1", - "is-buffer": "^1.1.0", - "lexical-scope": "^1.2.0", - "path-is-absolute": "^1.0.1", - "process": "~0.11.0", - "through2": "^2.0.0", - "xtend": "^4.0.0" - }, - "dependencies": { - "concat-stream": { - "version": "1.6.2", - "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz", - "integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==", - "requires": { - "buffer-from": "^1.0.0", - "inherits": "^2.0.3", - "readable-stream": "^2.2.2", - "typedarray": "^0.0.6" - } - } - } - }, - "invariant": { - "version": "2.2.4", - "resolved": "https://registry.npmjs.org/invariant/-/invariant-2.2.4.tgz", - "integrity": "sha512-phJfQVBuaJM5raOpJjSfkiD6BpbCE4Ns//LaXl6wGYtUBY83nWS6Rf9tXm2e8VaK60JEjYldbPif/A2B1C2gNA==", - "requires": { - "loose-envify": "^1.0.0" - } - }, - "invert-kv": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/invert-kv/-/invert-kv-1.0.0.tgz", - "integrity": "sha1-EEqOSqym09jNFXqO+L+rLXo//bY=" - }, - "ipaddr.js": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.6.0.tgz", - "integrity": "sha1-4/o1e3c9phnybpXwSdBVxyeW+Gs=" - }, - "irregular-plurals": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/irregular-plurals/-/irregular-plurals-2.0.0.tgz", - "integrity": "sha512-Y75zBYLkh0lJ9qxeHlMjQ7bSbyiSqNW/UOPWDmzC7cXskL1hekSITh1Oc6JV0XCWWZ9DE8VYSB71xocLk3gmGw==" - }, - "is-accessor-descriptor": { - "version": "0.1.6", - "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz", - "integrity": "sha1-qeEss66Nh2cn7u84Q/igiXtcmNY=", - "requires": { - "kind-of": "^3.0.2" - } - }, - "is-arrayish": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz", - "integrity": "sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0=" - }, - "is-binary-path": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", - "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", - "requires": { - "binary-extensions": "^2.0.0" - } - }, - "is-buffer": { - "version": "1.1.6", - "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", - "integrity": "sha1-76ouqdqg16suoTqXsritUf776L4=" - }, - "is-builtin-module": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-builtin-module/-/is-builtin-module-1.0.0.tgz", - "integrity": "sha1-VAVy0096wxGfj3bDDLwbHgN6/74=", - "requires": { - "builtin-modules": "^1.0.0" - } - }, - "is-ci": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/is-ci/-/is-ci-1.1.0.tgz", - "integrity": "sha512-c7TnwxLePuqIlxHgr7xtxzycJPegNHFuIrBkwbf8hc58//+Op1CqFkyS+xnIMkwn9UsJIwc174BIjkyBmSpjKg==", - "requires": { - "ci-info": "^1.0.0" - } - }, - "is-data-descriptor": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz", - "integrity": "sha1-C17mSDiOLIYCgueT8YVv7D8wG1Y=", - "requires": { - "kind-of": "^3.0.2" - } - }, - "is-defined": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-defined/-/is-defined-1.0.0.tgz", - "integrity": "sha1-HwfKZ9Vx9ZTEsUQVpF9774j5K/U=" - }, - "is-descriptor": { - "version": "0.1.6", - "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-0.1.6.tgz", - "integrity": "sha512-avDYr0SB3DwO9zsMov0gKCESFYqCnE4hq/4z3TdUlukEy5t9C0YRq7HLrsN52NAcqXKaepeCD0n+B0arnVG3Hg==", - "requires": { - "is-accessor-descriptor": "^0.1.6", - "is-data-descriptor": "^0.1.4", - "kind-of": "^5.0.0" - }, - "dependencies": { - "kind-of": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-5.1.0.tgz", - "integrity": "sha512-NGEErnH6F2vUuXDh+OlbcKW7/wOcfdRHaZ7VWtqCztfHri/++YKmP51OdWeGPuqCOba6kk2OTe5d02VmTB80Pw==" - } - } - }, - "is-error": { - "version": "2.2.2", - "resolved": "https://registry.npmjs.org/is-error/-/is-error-2.2.2.tgz", - "integrity": "sha512-IOQqts/aHWbiisY5DuPJQ0gcbvaLFCa7fBa9xoLfxBZvQ+ZI/Zh9xoI7Gk+G64N0FdK4AbibytHht2tWgpJWLg==" - }, - "is-extendable": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz", - "integrity": "sha1-YrEQ4omkcUGOPsNqYX1HLjAd/Ik=" - }, - "is-extglob": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", - "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=" - }, - "is-finite": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-finite/-/is-finite-1.0.2.tgz", - "integrity": "sha1-zGZ3aVYCvlUO8R6LSqYwU0K20Ko=", - "requires": { - "number-is-nan": "^1.0.0" - } - }, - "is-fullwidth-code-point": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", - "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=" - }, - "is-glob": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.1.tgz", - "integrity": "sha512-5G0tKtBTFImOqDnLB2hG6Bp2qcKEFduo4tZu9MT/H6NQv/ghhy30o55ufafxJ/LdH79LLs2Kfrn85TLKyA7BUg==", - "requires": { - "is-extglob": "^2.1.1" - } - }, - "is-installed-globally": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/is-installed-globally/-/is-installed-globally-0.1.0.tgz", - "integrity": "sha1-Df2Y9akRFxbdU13aZJL2e/PSWoA=", - "requires": { - "global-dirs": "^0.1.0", - "is-path-inside": "^1.0.0" - }, - "dependencies": { - "is-path-inside": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-1.0.1.tgz", - "integrity": "sha1-jvW33lBDej/cprToZe96pVy0gDY=", - "requires": { - "path-is-inside": "^1.0.1" - } - } - } - }, - "is-module": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-module/-/is-module-1.0.0.tgz", - "integrity": "sha1-Mlj7afeMFNW4FdZkM2tM/7ZEFZE=" - }, - "is-npm": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-npm/-/is-npm-3.0.0.tgz", - "integrity": "sha512-wsigDr1Kkschp2opC4G3yA6r9EgVA6NjRpWzIi9axXqeIaAATPRJc4uLujXe3Nd9uO8KoDyA4MD6aZSeXTADhA==" - }, - "is-number": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-number/-/is-number-3.0.0.tgz", - "integrity": "sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU=", - "requires": { - "kind-of": "^3.0.2" - } - }, - "is-obj": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/is-obj/-/is-obj-1.0.1.tgz", - "integrity": "sha1-PkcprB9f3gJc19g6iW2rn09n2w8=" - }, - "is-observable": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/is-observable/-/is-observable-2.0.0.tgz", - "integrity": "sha512-fhBZv3eFKUbyHXZ1oHujdo2tZ+CNbdpdzzlENgCGZUC8keoGxUew2jYFLYcUB4qo7LDD03o4KK11m/QYD7kEjg==" - }, - "is-path-cwd": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/is-path-cwd/-/is-path-cwd-2.2.0.tgz", - "integrity": "sha512-w942bTcih8fdJPJmQHFzkS76NEP8Kzzvmw92cXsazb8intwLqPibPPdXf4ANdKV3rYMuuQYGIWtvz9JilB3NFQ==" - }, - "is-path-in-cwd": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/is-path-in-cwd/-/is-path-in-cwd-2.1.0.tgz", - "integrity": "sha512-rNocXHgipO+rvnP6dk3zI20RpOtrAM/kzbB258Uw5BWr3TpXi861yzjo16Dn4hUox07iw5AyeMLHWsujkjzvRQ==", - "requires": { - "is-path-inside": "^2.1.0" - } - }, - "is-path-inside": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-2.1.0.tgz", - "integrity": "sha512-wiyhTzfDWsvwAW53OBWF5zuvaOGlZ6PwYxAbPVDhpm+gM09xKQGjBq/8uYN12aDvMxnAnq3dxTyoSoRNmg5YFg==", - "requires": { - "path-is-inside": "^1.0.2" - } - }, - "is-plain-obj": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-1.1.0.tgz", - "integrity": "sha1-caUMhCnfync8kqOQpKA7OfzVHT4=" - }, - "is-plain-object": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz", - "integrity": "sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==", - "requires": { - "isobject": "^3.0.1" - }, - "dependencies": { - "isobject": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", - "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=" - } - } - }, - "is-primitive": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/is-primitive/-/is-primitive-3.0.1.tgz", - "integrity": "sha512-GljRxhWvlCNRfZyORiH77FwdFwGcMO620o37EOYC0ORWdq+WYNVqW0w2Juzew4M+L81l6/QS3t5gkkihyRqv9w==" - }, - "is-promise": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-2.1.0.tgz", - "integrity": "sha1-eaKp7OfwlugPNtKy87wWwf9L8/o=" - }, - "is-redirect": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-redirect/-/is-redirect-1.0.0.tgz", - "integrity": "sha1-HQPd7VO9jbDzDCbk+V02/HyH3CQ=" - }, - "is-retry-allowed": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/is-retry-allowed/-/is-retry-allowed-1.1.0.tgz", - "integrity": "sha1-EaBgVotnM5REAz0BJaYaINVk+zQ=" - }, - "is-stream": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", - "integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ=" - }, - "is-subset": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/is-subset/-/is-subset-0.1.1.tgz", - "integrity": "sha1-ilkRfZMt4d4A8kX83TnOQ/HpOaY=" - }, - "is-text-path": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/is-text-path/-/is-text-path-1.0.1.tgz", - "integrity": "sha1-Thqg+1G/vLPpJogAE5cgLBd1tm4=", - "requires": { - "text-extensions": "^1.0.0" - } - }, - "is-typedarray": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", - "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=" - }, - "is-url": { - "version": "1.2.4", - "resolved": "https://registry.npmjs.org/is-url/-/is-url-1.2.4.tgz", - "integrity": "sha512-ITvGim8FhRiYe4IQ5uHSkj7pVaPDrCTkNd3yq3cV7iZAcJdHTUMPMEHcqSOy9xZ9qFenQCvi+2wjH9a1nXqHww==" - }, - "is-utf8": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/is-utf8/-/is-utf8-0.2.1.tgz", - "integrity": "sha1-Sw2hRCEE0bM2NA6AeX6GXPOffXI=" - }, - "is-windows": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-windows/-/is-windows-1.0.2.tgz", - "integrity": "sha512-eXK1UInq2bPmjyX6e3VHIzMLobc4J94i4AWn+Hpq3OU5KkrRC96OAcR3PRJ/pGu6m8TRnBHP9dkXQVsT/COVIA==" - }, - "is-yarn-global": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/is-yarn-global/-/is-yarn-global-0.3.0.tgz", - "integrity": "sha512-VjSeb/lHmkoyd8ryPVIKvOCn4D1koMqY+vqyjjUfc3xyKtP4dYOxM44sZrnqQSzSds3xyOrUTLTC9LVCVgLngw==" - }, - "isarray": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", - "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=" - }, - "isexe": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", - "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=" - }, - "isobject": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", - "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=" - }, - "js-string-escape": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/js-string-escape/-/js-string-escape-1.0.1.tgz", - "integrity": "sha1-4mJbrbwNZ8dTPp7cEGjFh65BN+8=" - }, - "js-tokens": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-3.0.2.tgz", - "integrity": "sha1-mGbfOVECEw449/mWvOtlRDIJwls=" - }, - "js-yaml": { - "version": "3.13.1", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz", - "integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==", - "requires": { - "argparse": "^1.0.7", - "esprima": "^4.0.0" - } - }, - "jsesc": { - "version": "0.5.0", - "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-0.5.0.tgz", - "integrity": "sha1-597mbjXW/Bb3EP6R1c9p9w8IkR0=" - }, - "json-buffer": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.0.tgz", - "integrity": "sha1-Wx85evx11ne96Lz8Dkfh+aPZqJg=" - }, - "json-parse-better-errors": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/json-parse-better-errors/-/json-parse-better-errors-1.0.2.tgz", - "integrity": "sha512-mrqyZKfX5EhL7hvqcV6WG1yYjnjeuYDzDhhcAAUrq8Po85NBQBJP+ZDUT75qZQ98IkUoBqdkExkukOU7Ts2wrw==" - }, - "json-schema-traverse": { - "version": "0.4.1", - "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", - "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==" - }, - "json-stable-stringify": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/json-stable-stringify/-/json-stable-stringify-0.0.1.tgz", - "integrity": "sha1-YRwj6BTbN1Un34URk9tZ3Sryf0U=", - "requires": { - "jsonify": "~0.0.0" - } - }, - "json-stable-stringify-without-jsonify": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", - "integrity": "sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE=" - }, - "json-stringify-safe": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", - "integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=" - }, - "json5": { - "version": "0.5.1", - "resolved": "https://registry.npmjs.org/json5/-/json5-0.5.1.tgz", - "integrity": "sha1-Hq3nrMASA0rYTiOWdn6tn6VJWCE=" - }, - "jsonfile": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", - "integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=", - "requires": { - "graceful-fs": "^4.1.6" - } - }, - "jsonify": { - "version": "0.0.0", - "resolved": "https://registry.npmjs.org/jsonify/-/jsonify-0.0.0.tgz", - "integrity": "sha1-LHS27kHZPKUbe1qu6PUDYx0lKnM=" - }, - "jsonparse": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/jsonparse/-/jsonparse-1.3.1.tgz", - "integrity": "sha1-P02uSpH6wxX3EGL4UhzCOfE2YoA=" - }, - "keyv": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/keyv/-/keyv-3.1.0.tgz", - "integrity": "sha512-9ykJ/46SN/9KPM/sichzQ7OvXyGDYKGTaDlKMGCAlg2UK8KRy4jb0d8sFc+0Tt0YYnThq8X2RZgCg74RPxgcVA==", - "requires": { - "json-buffer": "3.0.0" - } - }, - "kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "requires": { - "is-buffer": "^1.1.5" - } - }, - "labeled-stream-splicer": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/labeled-stream-splicer/-/labeled-stream-splicer-2.0.1.tgz", - "integrity": "sha512-MC94mHZRvJ3LfykJlTUipBqenZz1pacOZEMhhQ8dMGcDHs0SBE5GbsavUXV7YtP3icBW17W0Zy1I0lfASmo9Pg==", - "requires": { - "inherits": "^2.0.1", - "isarray": "^2.0.4", - "stream-splicer": "^2.0.0" - }, - "dependencies": { - "isarray": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-2.0.4.tgz", - "integrity": "sha512-GMxXOiUirWg1xTKRipM0Ek07rX+ubx4nNVElTJdNLYmNO/2YrDkgJGw9CljXn+r4EWiDQg/8lsRdHyg2PJuUaA==" - } - } - }, - "latest-version": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/latest-version/-/latest-version-5.1.0.tgz", - "integrity": "sha512-weT+r0kTkRQdCdYCNtkMwWXQTMEswKrFBkm4ckQOMVhhqhIMI1UT2hMj+1iigIhgSZm5gTmrRXBNoGUgaTY1xA==", - "requires": { - "package-json": "^6.3.0" - }, - "dependencies": { - "deep-extend": { - "version": "0.6.0", - "resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.6.0.tgz", - "integrity": "sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA==" - }, - "get-stream": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-4.1.0.tgz", - "integrity": "sha512-GMat4EJ5161kIy2HevLlr4luNjBgvmj413KaQA7jt4V8B4RDsfpHk7WQ9GVqfYyyx8OS/L66Kox+rJRNklLK7w==", - "requires": { - "pump": "^3.0.0" - } - }, - "got": { - "version": "9.6.0", - "resolved": "https://registry.npmjs.org/got/-/got-9.6.0.tgz", - "integrity": "sha512-R7eWptXuGYxwijs0eV+v3o6+XH1IqVK8dJOEecQfTmkncw9AV4dcw/Dhxi8MdlqPthxxpZyizMzyg8RTmEsG+Q==", - "requires": { - "@sindresorhus/is": "^0.14.0", - "@szmarczak/http-timer": "^1.1.2", - "cacheable-request": "^6.0.0", - "decompress-response": "^3.3.0", - "duplexer3": "^0.1.4", - "get-stream": "^4.1.0", - "lowercase-keys": "^1.0.1", - "mimic-response": "^1.0.1", - "p-cancelable": "^1.0.0", - "to-readable-stream": "^1.0.0", - "url-parse-lax": "^3.0.0" - } - }, - "minimist": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", - "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" - }, - "package-json": { - "version": "6.4.0", - "resolved": "https://registry.npmjs.org/package-json/-/package-json-6.4.0.tgz", - "integrity": "sha512-bd1T8OBG7hcvMd9c/udgv6u5v9wISP3Oyl9Cm7Weop8EFwrtcQDnS2sb6zhwqus2WslSr5wSTIPiTTpxxmPm7Q==", - "requires": { - "got": "^9.6.0", - "registry-auth-token": "^3.4.0", - "registry-url": "^5.0.0", - "semver": "^6.1.1" - } - }, - "prepend-http": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/prepend-http/-/prepend-http-2.0.0.tgz", - "integrity": "sha1-6SQ0v6XqjBn0HN/UAddBo8gZ2Jc=" - }, - "registry-auth-token": { - "version": "3.4.0", - "resolved": "https://registry.npmjs.org/registry-auth-token/-/registry-auth-token-3.4.0.tgz", - "integrity": "sha512-4LM6Fw8eBQdwMYcES4yTnn2TqIasbXuwDx3um+QRs7S55aMKCBKBxvPXl2RiUjHwuJLTyYfxSpmfSAjQpcuP+A==", - "requires": { - "rc": "^1.1.6", - "safe-buffer": "^5.0.1" - } - }, - "registry-url": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/registry-url/-/registry-url-5.1.0.tgz", - "integrity": "sha512-8acYXXTI0AkQv6RAOjE3vOaIXZkT9wo4LOFbBKYQEEnnMNBpKqdUrI6S4NT0KPIo/WVvJ5tE/X5LF/TQUf0ekw==", - "requires": { - "rc": "^1.2.8" - }, - "dependencies": { - "rc": { - "version": "1.2.8", - "resolved": "https://registry.npmjs.org/rc/-/rc-1.2.8.tgz", - "integrity": "sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw==", - "requires": { - "deep-extend": "^0.6.0", - "ini": "~1.3.0", - "minimist": "^1.2.0", - "strip-json-comments": "~2.0.1" - } - } - } - }, - "semver": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.2.0.tgz", - "integrity": "sha512-jdFC1VdUGT/2Scgbimf7FSx9iJLXoqfglSF+gJeuNWVpiE37OIbc1jywR/GJyFdz3mnkz2/id0L0J/cr0izR5A==" - }, - "url-parse-lax": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/url-parse-lax/-/url-parse-lax-3.0.0.tgz", - "integrity": "sha1-FrXK/Afb42dsGxmZF3gj1lA6yww=", - "requires": { - "prepend-http": "^2.0.0" - } - } - } - }, - "lcid": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/lcid/-/lcid-1.0.0.tgz", - "integrity": "sha1-MIrMr6C8SDo4Z7S28rlQYlHRuDU=", - "requires": { - "invert-kv": "^1.0.0" - } - }, - "lerna": { - "version": "2.11.0", - "resolved": "https://registry.npmjs.org/lerna/-/lerna-2.11.0.tgz", - "integrity": "sha512-kgM6zwe2P2tR30MYvgiLLW+9buFCm6E7o8HnRlhTgm70WVBvXVhydqv+q/MF2HrVZkCawfVtCfetyQmtd4oHhQ==", - "requires": { - "async": "^1.5.0", - "chalk": "^2.1.0", - "cmd-shim": "^2.0.2", - "columnify": "^1.5.4", - "command-join": "^2.0.0", - "conventional-changelog-cli": "^1.3.13", - "conventional-recommended-bump": "^1.2.1", - "dedent": "^0.7.0", - "execa": "^0.8.0", - "find-up": "^2.1.0", - "fs-extra": "^4.0.1", - "get-port": "^3.2.0", - "glob": "^7.1.2", - "glob-parent": "^3.1.0", - "globby": "^6.1.0", - "graceful-fs": "^4.1.11", - "hosted-git-info": "^2.5.0", - "inquirer": "^3.2.2", - "is-ci": "^1.0.10", - "load-json-file": "^4.0.0", - "lodash": "^4.17.4", - "minimatch": "^3.0.4", - "npmlog": "^4.1.2", - "p-finally": "^1.0.0", - "package-json": "^4.0.1", - "path-exists": "^3.0.0", - "read-cmd-shim": "^1.0.1", - "read-pkg": "^3.0.0", - "rimraf": "^2.6.1", - "safe-buffer": "^5.1.1", - "semver": "^5.4.1", - "signal-exit": "^3.0.2", - "slash": "^1.0.0", - "strong-log-transformer": "^1.0.6", - "temp-write": "^3.3.0", - "write-file-atomic": "^2.3.0", - "write-json-file": "^2.2.0", - "write-pkg": "^3.1.0", - "yargs": "^8.0.2" - }, - "dependencies": { - "execa": { - "version": "0.8.0", - "resolved": "https://registry.npmjs.org/execa/-/execa-0.8.0.tgz", - "integrity": "sha1-2NdrvBtVIX7RkP1t1J08d07PyNo=", - "requires": { - "cross-spawn": "^5.0.1", - "get-stream": "^3.0.0", - "is-stream": "^1.1.0", - "npm-run-path": "^2.0.0", - "p-finally": "^1.0.0", - "signal-exit": "^3.0.0", - "strip-eof": "^1.0.0" - } - }, - "glob-parent": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-3.1.0.tgz", - "integrity": "sha1-nmr2KZ2NO9K9QEMIMr0RPfkGxa4=", - "requires": { - "is-glob": "^3.1.0", - "path-dirname": "^1.0.0" - } - }, - "is-extglob": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", - "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=" - }, - "is-glob": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-3.1.0.tgz", - "integrity": "sha1-e6WuJCF4BKxwcHuWkiVnSGzD6Eo=", - "requires": { - "is-extglob": "^2.1.0" - } - }, - "load-json-file": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-4.0.0.tgz", - "integrity": "sha1-L19Fq5HjMhYjT9U62rZo607AmTs=", - "requires": { - "graceful-fs": "^4.1.2", - "parse-json": "^4.0.0", - "pify": "^3.0.0", - "strip-bom": "^3.0.0" - } - }, - "parse-json": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-4.0.0.tgz", - "integrity": "sha1-vjX1Qlvh9/bHRxhPmKeIy5lHfuA=", - "requires": { - "error-ex": "^1.3.1", - "json-parse-better-errors": "^1.0.1" - } - }, - "path-type": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/path-type/-/path-type-3.0.0.tgz", - "integrity": "sha512-T2ZUsdZFHgA3u4e5PfPbjd7HDDpxPnQb5jN0SrDsjNSuVXHJqtwTnWqG0B1jZrgmJ/7lj1EmVIByWt1gxGkWvg==", - "requires": { - "pify": "^3.0.0" - } - }, - "pify": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/pify/-/pify-3.0.0.tgz", - "integrity": "sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY=" - }, - "read-pkg": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-3.0.0.tgz", - "integrity": "sha1-nLxoaXj+5l0WwA4rGcI3/Pbjg4k=", - "requires": { - "load-json-file": "^4.0.0", - "normalize-package-data": "^2.3.2", - "path-type": "^3.0.0" - } - } - } - }, - "levn": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz", - "integrity": "sha1-OwmSTt+fCDwEkP3UwLxEIeBHZO4=", - "requires": { - "prelude-ls": "~1.1.2", - "type-check": "~0.3.2" - } - }, - "lexical-scope": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/lexical-scope/-/lexical-scope-1.2.0.tgz", - "integrity": "sha1-/Ope3HBKSzqHls3KQZw6CvryLfQ=", - "requires": { - "astw": "^2.0.0" - } - }, - "load-json-file": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-2.0.0.tgz", - "integrity": "sha1-eUfkIUmvgNaWy/eXvKq8/h/inKg=", - "requires": { - "graceful-fs": "^4.1.2", - "parse-json": "^2.2.0", - "pify": "^2.0.0", - "strip-bom": "^3.0.0" - } - }, - "locate-path": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-2.0.0.tgz", - "integrity": "sha1-K1aLJl7slExtnA3pw9u7ygNUzY4=", - "requires": { - "p-locate": "^2.0.0", - "path-exists": "^3.0.0" - } - }, - "lodash": { - "version": "4.17.21", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", - "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" - }, - "lodash._reinterpolate": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/lodash._reinterpolate/-/lodash._reinterpolate-3.0.0.tgz", - "integrity": "sha1-DM8tiRZq8Ds2Y8eWU4t1rG4RTZ0=" - }, - "lodash.camelcase": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/lodash.camelcase/-/lodash.camelcase-4.3.0.tgz", - "integrity": "sha1-soqmKIorn8ZRA1x3EfZathkDMaY=" - }, - "lodash.clonedeep": { - "version": "4.5.0", - "resolved": "https://registry.npmjs.org/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz", - "integrity": "sha1-4j8/nE+Pvd6HJSnBBxhXoIblzO8=" - }, - "lodash.escaperegexp": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/lodash.escaperegexp/-/lodash.escaperegexp-4.1.2.tgz", - "integrity": "sha1-ZHYsSGGAglGKw99Mz11YhtriA0c=" - }, - "lodash.flattendeep": { - "version": "4.4.0", - "resolved": "https://registry.npmjs.org/lodash.flattendeep/-/lodash.flattendeep-4.4.0.tgz", - "integrity": "sha1-+wMJF/hqMTTlvJvsDWngAT3f7bI=" - }, - "lodash.isequal": { - "version": "4.5.0", - "resolved": "https://registry.npmjs.org/lodash.isequal/-/lodash.isequal-4.5.0.tgz", - "integrity": "sha1-QVxEePK8wwEgwizhDtMib30+GOA=" - }, - "lodash.islength": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/lodash.islength/-/lodash.islength-4.0.1.tgz", - "integrity": "sha1-Tpho1FJXXXUK/9NYyXlUPcIO1Xc=" - }, - "lodash.keys": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/lodash.keys/-/lodash.keys-4.2.0.tgz", - "integrity": "sha1-oIYCrBLk+4P5H8H7ejYKTZujUgU=" - }, - "lodash.last": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/lodash.last/-/lodash.last-3.0.0.tgz", - "integrity": "sha1-JC9mMRLdTG5jcoxgo8kJ0b2tvUw=" - }, - "lodash.max": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/lodash.max/-/lodash.max-4.0.1.tgz", - "integrity": "sha1-hzVWbGGLNan3YFILSHrnllivE2o=" - }, - "lodash.memoize": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/lodash.memoize/-/lodash.memoize-3.0.4.tgz", - "integrity": "sha1-LcvSwofLwKVcxCMovQxzYVDVPj8=" - }, - "lodash.merge": { - "version": "4.6.2", - "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz", - "integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==" - }, - "lodash.sortby": { - "version": "4.7.0", - "resolved": "https://registry.npmjs.org/lodash.sortby/-/lodash.sortby-4.7.0.tgz", - "integrity": "sha1-7dFMgk4sycHgsKG0K7UhBRakJDg=" - }, - "lodash.template": { - "version": "4.5.0", - "resolved": "https://registry.npmjs.org/lodash.template/-/lodash.template-4.5.0.tgz", - "integrity": "sha512-84vYFxIkmidUiFxidA/KjjH9pAycqW+h980j7Fuz5qxRtO9pgB7MDFTdys1N7A5mcucRiDyEq4fusljItR1T/A==", - "requires": { - "lodash._reinterpolate": "^3.0.0", - "lodash.templatesettings": "^4.0.0" - } - }, - "lodash.templatesettings": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/lodash.templatesettings/-/lodash.templatesettings-4.2.0.tgz", - "integrity": "sha512-stgLz+i3Aa9mZgnjr/O+v9ruKZsPsndy7qPZOchbqk2cnTU1ZaldKK+v7m54WoKIyxiuMZTKT2H81F8BeAc3ZQ==", - "requires": { - "lodash._reinterpolate": "^3.0.0" - } - }, - "lodash.tonumber": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/lodash.tonumber/-/lodash.tonumber-4.0.3.tgz", - "integrity": "sha1-C5azGzVnJ5Prf1pj7nkfG56QJdk=" - }, - "lodash.trimend": { - "version": "4.5.1", - "resolved": "https://registry.npmjs.org/lodash.trimend/-/lodash.trimend-4.5.1.tgz", - "integrity": "sha1-EoBENyhrmMrYmWt5QU4RMAEUCC8=" - }, - "lodash.unescape": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/lodash.unescape/-/lodash.unescape-4.0.1.tgz", - "integrity": "sha1-vyJJiGzlFM2hEvrpIYzcBlIR/Jw=" - }, - "log-symbols": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-2.2.0.tgz", - "integrity": "sha512-VeIAFslyIerEJLXHziedo2basKbMKtTw3vfn5IzG0XTjhAVEJyNHnL2p7vc+wBDSdQuUpNw3M2u6xb9QsAY5Eg==", - "requires": { - "chalk": "^2.0.1" - } - }, - "loose-envify": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.3.1.tgz", - "integrity": "sha1-0aitM/qc4OcT1l/dCsi3SNR4yEg=", - "requires": { - "js-tokens": "^3.0.0" - } - }, - "loud-rejection": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/loud-rejection/-/loud-rejection-1.6.0.tgz", - "integrity": "sha1-W0b4AUft7leIcPCG0Eghz5mOVR8=", - "requires": { - "currently-unhandled": "^0.4.1", - "signal-exit": "^3.0.0" - } - }, - "loupe": { - "version": "2.3.4", - "resolved": "https://registry.npmjs.org/loupe/-/loupe-2.3.4.tgz", - "integrity": "sha512-OvKfgCC2Ndby6aSTREl5aCCPTNIzlDfQZvZxNUrBrihDhL3xcrYegTblhmEiCrg2kKQz4XsFIaemE5BF4ybSaQ==", - "requires": { - "get-func-name": "^2.0.0" - } - }, - "lowercase-keys": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/lowercase-keys/-/lowercase-keys-1.0.1.tgz", - "integrity": "sha512-G2Lj61tXDnVFFOi8VZds+SoQjtQC3dgokKdDG2mTm1tx4m50NUHBOZSBwQQHyy0V12A0JTG4icfZQH+xPyh8VA==" - }, - "lru-cache": { - "version": "4.1.3", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-4.1.3.tgz", - "integrity": "sha512-fFEhvcgzuIoJVUF8fYr5KR0YqxD238zgObTps31YdADwPPAp82a4M8TrckkWyx7ekNlf9aBcVn81cFwwXngrJA==", - "requires": { - "pseudomap": "^1.0.2", - "yallist": "^2.1.2" - } - }, - "magic-string": { - "version": "0.22.5", - "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.22.5.tgz", - "integrity": "sha512-oreip9rJZkzvA8Qzk9HFs8fZGF/u7H/gtrE8EN6RjKJ9kh2HlC+yQ2QezifqTZfGyiuAV0dRv5a+y/8gBb1m9w==", - "requires": { - "vlq": "^0.2.2" - } - }, - "make-dir": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-1.3.0.tgz", - "integrity": "sha512-2w31R7SJtieJJnQtGc7RVL2StM2vGYVfqUOvUDxH6bC6aJTxPxTF0GnIgCyu7tjockiUWAYQRbxa7vKn34s5sQ==", - "requires": { - "pify": "^3.0.0" - }, - "dependencies": { - "pify": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/pify/-/pify-3.0.0.tgz", - "integrity": "sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY=" - } - } - }, - "make-error": { - "version": "1.3.4", - "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.4.tgz", - "integrity": "sha512-0Dab5btKVPhibSalc9QGXb559ED7G7iLjFXBaj9Wq8O3vorueR5K5jaE3hkG6ZQINyhA/JgG6Qk4qdFQjsYV6g==" - }, - "map-age-cleaner": { - "version": "0.1.3", - "resolved": "https://registry.npmjs.org/map-age-cleaner/-/map-age-cleaner-0.1.3.tgz", - "integrity": "sha512-bJzx6nMoP6PDLPBFmg7+xRKeFZvFboMrGlxmNj9ClvX53KrmvM5bXFXEWjbz4cz1AFn+jWJ9z/DJSz7hrs0w3w==", - "requires": { - "p-defer": "^1.0.0" - } - }, - "map-cache": { - "version": "0.2.2", - "resolved": "https://registry.npmjs.org/map-cache/-/map-cache-0.2.2.tgz", - "integrity": "sha1-wyq9C9ZSXZsFFkW7TyasXcmKDb8=" - }, - "map-obj": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/map-obj/-/map-obj-1.0.1.tgz", - "integrity": "sha1-2TPOuSBdgr3PSIb2dCvcK03qFG0=" - }, - "map-stream": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/map-stream/-/map-stream-0.1.0.tgz", - "integrity": "sha1-5WqpTEyAVaFkBKBnS3jyFffI4ZQ=" - }, - "map-visit": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/map-visit/-/map-visit-1.0.0.tgz", - "integrity": "sha1-7Nyo8TFE5mDxtb1B8S80edmN+48=", - "requires": { - "object-visit": "^1.0.0" - } - }, - "matcher": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/matcher/-/matcher-2.0.0.tgz", - "integrity": "sha512-nlmfSlgHBFx36j/Pl/KQPbIaqE8Zf0TqmSMjsuddHDg6PMSVgmyW9HpkLs0o0M1n2GIZ/S2BZBLIww/xjhiGng==", - "requires": { - "escape-string-regexp": "^2.0.0" - }, - "dependencies": { - "escape-string-regexp": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-2.0.0.tgz", - "integrity": "sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w==" - } - } - }, - "md5-hex": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/md5-hex/-/md5-hex-3.0.1.tgz", - "integrity": "sha512-BUiRtTtV39LIJwinWBjqVsU9xhdnz7/i889V859IBFpuqGAj6LuOvHv5XLbgZ2R7ptJoJaEcxkv88/h25T7Ciw==", - "requires": { - "blueimp-md5": "^2.10.0" - } - }, - "md5-o-matic": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/md5-o-matic/-/md5-o-matic-0.1.1.tgz", - "integrity": "sha1-givM1l4RfFFPqxdrJZRdVBAKA8M=" - }, - "md5.js": { - "version": "1.3.4", - "resolved": "https://registry.npmjs.org/md5.js/-/md5.js-1.3.4.tgz", - "integrity": "sha1-6b296UogpawYsENA/Fdk1bCdkB0=", - "requires": { - "hash-base": "^3.0.0", - "inherits": "^2.0.1" - } - }, - "media-typer": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", - "integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=" - }, - "mem": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/mem/-/mem-5.1.1.tgz", - "integrity": "sha512-qvwipnozMohxLXG1pOqoLiZKNkC4r4qqRucSoDwXowsNGDSULiqFTRUF05vcZWnwJSG22qTsynQhxbaMtnX9gw==", - "requires": { - "map-age-cleaner": "^0.1.3", - "mimic-fn": "^2.1.0", - "p-is-promise": "^2.1.0" - }, - "dependencies": { - "mimic-fn": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz", - "integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==" - } - } - }, - "meow": { - "version": "3.7.0", - "resolved": "https://registry.npmjs.org/meow/-/meow-3.7.0.tgz", - "integrity": "sha1-cstmi0JSKCkKu/qFaJJYcwioAfs=", - "requires": { - "camelcase-keys": "^2.0.0", - "decamelize": "^1.1.2", - "loud-rejection": "^1.0.0", - "map-obj": "^1.0.1", - "minimist": "^1.1.3", - "normalize-package-data": "^2.3.4", - "object-assign": "^4.0.1", - "read-pkg-up": "^1.0.1", - "redent": "^1.0.0", - "trim-newlines": "^1.0.0" - }, - "dependencies": { - "find-up": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-1.1.2.tgz", - "integrity": "sha1-ay6YIrGizgpgq2TWEOzK1TyyTQ8=", - "requires": { - "path-exists": "^2.0.0", - "pinkie-promise": "^2.0.0" - } - }, - "load-json-file": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-1.1.0.tgz", - "integrity": "sha1-lWkFcI1YtLq0wiYbBPWfMcmTdMA=", - "requires": { - "graceful-fs": "^4.1.2", - "parse-json": "^2.2.0", - "pify": "^2.0.0", - "pinkie-promise": "^2.0.0", - "strip-bom": "^2.0.0" - } - }, - "minimist": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", - "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" - }, - "path-exists": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-2.1.0.tgz", - "integrity": "sha1-D+tsZPD8UY2adU3V77YscCJ2H0s=", - "requires": { - "pinkie-promise": "^2.0.0" - } - }, - "path-type": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/path-type/-/path-type-1.1.0.tgz", - "integrity": "sha1-WcRPfuSR2nBNpBXaWkBwuk+P5EE=", - "requires": { - "graceful-fs": "^4.1.2", - "pify": "^2.0.0", - "pinkie-promise": "^2.0.0" - } - }, - "pinkie": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/pinkie/-/pinkie-2.0.4.tgz", - "integrity": "sha1-clVrgM+g1IqXToDnckjoDtT3+HA=" - }, - "pinkie-promise": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/pinkie-promise/-/pinkie-promise-2.0.1.tgz", - "integrity": "sha1-ITXW36ejWMBprJsXh3YogihFD/o=", - "requires": { - "pinkie": "^2.0.0" - } - }, - "read-pkg": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-1.1.0.tgz", - "integrity": "sha1-9f+qXs0pyzHAR0vKfXVra7KePyg=", - "requires": { - "load-json-file": "^1.0.0", - "normalize-package-data": "^2.3.2", - "path-type": "^1.0.0" - } - }, - "read-pkg-up": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-1.0.1.tgz", - "integrity": "sha1-nWPBMnbAZZGNV/ACpX9AobZD+wI=", - "requires": { - "find-up": "^1.0.0", - "read-pkg": "^1.0.0" - } - }, - "strip-bom": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-2.0.0.tgz", - "integrity": "sha1-YhmoVhZSBJHzV4i9vxRHqZx+aw4=", - "requires": { - "is-utf8": "^0.2.0" - } - } - } - }, - "merge-descriptors": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz", - "integrity": "sha1-sAqqVW3YtEVoFQ7J0blT8/kMu2E=" - }, - "merge2": { - "version": "1.2.3", - "resolved": "https://registry.npmjs.org/merge2/-/merge2-1.2.3.tgz", - "integrity": "sha512-gdUU1Fwj5ep4kplwcmftruWofEFt6lfpkkr3h860CXbAB9c3hGb55EOL2ali0Td5oebvW0E1+3Sr+Ur7XfKpRA==" - }, - "methods": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", - "integrity": "sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4=" - }, - "micromatch": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.2.tgz", - "integrity": "sha512-y7FpHSbMUMoyPbYUSzO6PaZ6FyRnQOpHuKwbo1G+Knck95XVU4QAiKdGEnj5wwoS7PlOgthX/09u5iFJ+aYf5Q==", - "requires": { - "braces": "^3.0.1", - "picomatch": "^2.0.5" - }, - "dependencies": { - "braces": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", - "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", - "requires": { - "fill-range": "^7.0.1" - } - }, - "fill-range": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", - "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", - "requires": { - "to-regex-range": "^5.0.1" - } - }, - "is-number": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", - "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==" - }, - "to-regex-range": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", - "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", - "requires": { - "is-number": "^7.0.0" - } - } - } - }, - "miller-rabin": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/miller-rabin/-/miller-rabin-4.0.1.tgz", - "integrity": "sha1-8IA1HIZbDcViqEYpZtqlNUPHik0=", - "requires": { - "bn.js": "^4.0.0", - "brorand": "^1.0.1" - } - }, - "mime": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/mime/-/mime-1.4.1.tgz", - "integrity": "sha1-Eh+evEnjdm8xGnbh+hyAA8SwOqY=" - }, - "mime-db": { - "version": "1.33.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.33.0.tgz", - "integrity": "sha512-BHJ/EKruNIqJf/QahvxwQZXKygOQ256myeN/Ew+THcAa5q+PjyTTMMeNQC4DZw5AwfvelsUrA6B67NKMqXDbzQ==" - }, - "mime-types": { - "version": "2.1.18", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.18.tgz", - "integrity": "sha512-lc/aahn+t4/SWV/qcmumYjymLsWfN3ELhpmVuUFjgsORruuZPVSwAQryq+HHGvO/SI2KVX26bx+En+zhM8g8hQ==", - "requires": { - "mime-db": "~1.33.0" - } - }, - "mimic-fn": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-1.2.0.tgz", - "integrity": "sha512-jf84uxzwiuiIVKiOLpfYk7N46TSy8ubTonmneY9vrpHNAnp0QBt2BxWV9dO3/j+BoVAb+a5G6YDPW3M5HOdMWQ==" - }, - "mimic-response": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-1.0.1.tgz", - "integrity": "sha512-j5EctnkH7amfV/q5Hgmoal1g2QHFJRraOtmx0JpIqkxhBhI/lJSl1nMpQ45hVarwNETOoWEimndZ4QK0RHxuxQ==" - }, - "minimalistic-assert": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz", - "integrity": "sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A==" - }, - "minimalistic-crypto-utils": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/minimalistic-crypto-utils/-/minimalistic-crypto-utils-1.0.1.tgz", - "integrity": "sha1-9sAMHAsIIkblxNmd+4x8CDsrWCo=" - }, - "minimatch": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha1-UWbihkV/AzBgZL5Ul+jbsMPTIIM=", - "requires": { - "brace-expansion": "^1.1.7" - } - }, - "minimist": { - "version": "1.2.5", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", - "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==" - }, - "minimist-options": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/minimist-options/-/minimist-options-3.0.2.tgz", - "integrity": "sha512-FyBrT/d0d4+uiZRbqznPXqw3IpZZG3gl3wKWiX784FycUKVwBt0uLBFkQrtE4tZOrgo78nZp2jnKz3L65T5LdQ==", - "requires": { - "arrify": "^1.0.1", - "is-plain-obj": "^1.1.0" - } - }, - "mixin-deep": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/mixin-deep/-/mixin-deep-2.0.1.tgz", - "integrity": "sha512-imbHQNRglyaplMmjBLL3V5R6Bfq5oM+ivds3SKgc6oRtzErEnBUUc5No11Z2pilkUvl42gJvi285xTNswcKCMA==" - }, - "mkdirp": { - "version": "0.5.1", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", - "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", - "requires": { - "minimist": "0.0.8" - }, - "dependencies": { - "minimist": { - "version": "0.0.8", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", - "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=" - } - } - }, - "modify-values": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/modify-values/-/modify-values-1.0.1.tgz", - "integrity": "sha512-xV2bxeN6F7oYjZWTe/YPAy6MN2M+sL4u/Rlm2AHCIVGfo2p1yGmBHQ6vHehl4bRTZBdHu3TSkWdYgkwpYzAGSw==" - }, - "module-deps": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/module-deps/-/module-deps-4.1.1.tgz", - "integrity": "sha1-IyFYM/HaE/1gbMuAh7RIUty4If0=", - "requires": { - "JSONStream": "^1.0.3", - "browser-resolve": "^1.7.0", - "cached-path-relative": "^1.0.0", - "concat-stream": "~1.5.0", - "defined": "^1.0.0", - "detective": "^4.0.0", - "duplexer2": "^0.1.2", - "inherits": "^2.0.1", - "parents": "^1.0.0", - "readable-stream": "^2.0.2", - "resolve": "^1.1.3", - "stream-combiner2": "^1.1.1", - "subarg": "^1.0.0", - "through2": "^2.0.0", - "xtend": "^4.0.0" - } - }, - "moment": { - "version": "2.22.2", - "resolved": "https://registry.npmjs.org/moment/-/moment-2.22.2.tgz", - "integrity": "sha1-PCV/mDn8DpP/UxSWMiOeuQeD/2Y=" - }, - "mothership": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/mothership/-/mothership-0.2.0.tgz", - "integrity": "sha1-k9SKL7w+UOKl/I7VhvW8RMZfmpk=", - "requires": { - "find-parent-dir": "~0.3.0" - } - }, - "ms": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", - "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==" - }, - "mute-stream": { - "version": "0.0.7", - "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.7.tgz", - "integrity": "sha1-MHXOk7whuPq0PhvE2n6BFe0ee6s=" - }, - "nanomatch": { - "version": "1.2.13", - "resolved": "https://registry.npmjs.org/nanomatch/-/nanomatch-1.2.13.tgz", - "integrity": "sha512-fpoe2T0RbHwBTBUOftAfBPaDEi06ufaUai0mE6Yn1kacc3SnTErfb/h+X94VXzI64rKFHYImXSvdwGGCmwOqCA==", - "requires": { - "arr-diff": "^4.0.0", - "array-unique": "^0.3.2", - "define-property": "^2.0.2", - "extend-shallow": "^3.0.2", - "fragment-cache": "^0.2.1", - "is-windows": "^1.0.2", - "kind-of": "^6.0.2", - "object.pick": "^1.3.0", - "regex-not": "^1.0.0", - "snapdragon": "^0.8.1", - "to-regex": "^3.0.1" - }, - "dependencies": { - "arr-diff": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-4.0.0.tgz", - "integrity": "sha1-1kYQdP6/7HHn4VI1dhoyml3HxSA=" - }, - "array-unique": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.3.2.tgz", - "integrity": "sha1-qJS3XUvE9s1nnvMkSp/Y9Gri1Cg=" - }, - "kind-of": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz", - "integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==" - } - } - }, - "natural-compare": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", - "integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=" - }, - "negotiator": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.1.tgz", - "integrity": "sha1-KzJxhOiZIQEXeyhWP7XnECrNDKk=" - }, - "neo-async": { - "version": "2.6.2", - "resolved": "https://registry.npmjs.org/neo-async/-/neo-async-2.6.2.tgz", - "integrity": "sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==" - }, - "nice-try": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/nice-try/-/nice-try-1.0.5.tgz", - "integrity": "sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==" - }, - "normalize-package-data": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.4.0.tgz", - "integrity": "sha1-EvlaMH1YNSB1oEkHuErIvpisAS8=", - "requires": { - "hosted-git-info": "^2.1.4", - "is-builtin-module": "^1.0.0", - "semver": "2 || 3 || 4 || 5", - "validate-npm-package-license": "^3.0.1" - } - }, - "normalize-path": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", - "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==" - }, - "normalize-url": { - "version": "4.5.1", - "resolved": "https://registry.npmjs.org/normalize-url/-/normalize-url-4.5.1.tgz", - "integrity": "sha512-9UZCFRHQdNrfTpGg8+1INIg93B6zE0aXMVFkw1WFwvO4SlZywU6aLg5Of0Ap/PgcbSw4LNxvMWXMeugwMCX0AA==" - }, - "npm-run-path": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-2.0.2.tgz", - "integrity": "sha1-NakjLfo11wZ7TLLd8jV7GHFTbF8=", - "requires": { - "path-key": "^2.0.0" - } - }, - "npmlog": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/npmlog/-/npmlog-4.1.2.tgz", - "integrity": "sha512-2uUqazuKlTaSI/dC8AzicUck7+IrEaOnN/e0jd3Xtt1KcGpwx30v50mL7oPyr/h9bL3E4aZccVwpwP+5W9Vjkg==", - "requires": { - "are-we-there-yet": "~1.1.2", - "console-control-strings": "~1.1.0", - "gauge": "~2.7.3", - "set-blocking": "~2.0.0" - } - }, - "number-is-nan": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", - "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=" - }, - "object-assign": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", - "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=" - }, - "object-copy": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/object-copy/-/object-copy-0.1.0.tgz", - "integrity": "sha1-fn2Fi3gb18mRpBupde04EnVOmYw=", - "requires": { - "copy-descriptor": "^0.1.0", - "define-property": "^0.2.5", - "kind-of": "^3.0.3" - }, - "dependencies": { - "define-property": { - "version": "0.2.5", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", - "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", - "requires": { - "is-descriptor": "^0.1.0" - } - } - } - }, - "object-keys": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-0.4.0.tgz", - "integrity": "sha1-KKaq50KN0sOpLz2V8hM13SBOAzY=" - }, - "object-visit": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/object-visit/-/object-visit-1.0.1.tgz", - "integrity": "sha1-95xEk68MU3e1n+OdOV5BBC3QRbs=", - "requires": { - "isobject": "^3.0.0" - }, - "dependencies": { - "isobject": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", - "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=" - } - } - }, - "object.assign": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.0.tgz", - "integrity": "sha512-exHJeq6kBKj58mqGyTQ9DFvrZC/eR6OwxzoM9YRoGBqrXYonaFyGiFMuc9VZrXf7DarreEwMpurG3dd+CNyW5w==", - "requires": { - "define-properties": "^1.1.2", - "function-bind": "^1.1.1", - "has-symbols": "^1.0.0", - "object-keys": "^1.0.11" - }, - "dependencies": { - "object-keys": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz", - "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==" - } - } - }, - "object.pick": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/object.pick/-/object.pick-1.3.0.tgz", - "integrity": "sha1-h6EKxMFpS9Lhy/U1kaZhQftd10c=", - "requires": { - "isobject": "^3.0.1" - }, - "dependencies": { - "isobject": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", - "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=" - } - } - }, - "observable-to-promise": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/observable-to-promise/-/observable-to-promise-1.0.0.tgz", - "integrity": "sha512-cqnGUrNsE6vdVDTPAX9/WeVzwy/z37vdxupdQXU8vgTXRFH72KCZiZga8aca2ulRPIeem8W3vW9rQHBwfIl2WA==", - "requires": { - "is-observable": "^2.0.0", - "symbol-observable": "^1.0.4" - } - }, - "on-finished": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", - "integrity": "sha1-IPEzZIGwg811M3mSoWlxqi2QaUc=", - "requires": { - "ee-first": "1.1.1" - } - }, - "once": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", - "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", - "requires": { - "wrappy": "1" - } - }, - "onetime": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/onetime/-/onetime-2.0.1.tgz", - "integrity": "sha1-BnQoIw/WdEOyeUsiu6UotoZ5YtQ=", - "requires": { - "mimic-fn": "^1.0.0" - } - }, - "optionator": { - "version": "0.8.2", - "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.2.tgz", - "integrity": "sha1-NkxeQJ0/TWMB1sC0wFu6UBgK62Q=", - "requires": { - "deep-is": "~0.1.3", - "fast-levenshtein": "~2.0.4", - "levn": "~0.3.0", - "prelude-ls": "~1.1.2", - "type-check": "~0.3.2", - "wordwrap": "~1.0.0" - }, - "dependencies": { - "wordwrap": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz", - "integrity": "sha1-J1hIEIkUVqQXHI0CJkQa3pDLyus=" - } - } - }, - "ora": { - "version": "3.4.0", - "resolved": "https://registry.npmjs.org/ora/-/ora-3.4.0.tgz", - "integrity": "sha512-eNwHudNbO1folBP3JsZ19v9azXWtQZjICdr3Q0TDPIaeBQ3mXLrh54wM+er0+hSp+dWKf+Z8KM58CYzEyIYxYg==", - "requires": { - "chalk": "^2.4.2", - "cli-cursor": "^2.1.0", - "cli-spinners": "^2.0.0", - "log-symbols": "^2.2.0", - "strip-ansi": "^5.2.0", - "wcwidth": "^1.0.1" - }, - "dependencies": { - "ansi-regex": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", - "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==" - }, - "chalk": { - "version": "2.4.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", - "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", - "requires": { - "ansi-styles": "^3.2.1", - "escape-string-regexp": "^1.0.5", - "supports-color": "^5.3.0" - } - }, - "strip-ansi": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", - "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", - "requires": { - "ansi-regex": "^4.1.0" - } - }, - "supports-color": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", - "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", - "requires": { - "has-flag": "^3.0.0" - } - } - } - }, - "os-browserify": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/os-browserify/-/os-browserify-0.3.0.tgz", - "integrity": "sha1-hUNzx/XCMVkU/Jv8a9gjj92h7Cc=" - }, - "os-homedir": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz", - "integrity": "sha1-/7xJiDNuDoM94MFox+8VISGqf7M=" - }, - "os-locale": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/os-locale/-/os-locale-2.1.0.tgz", - "integrity": "sha1-QrwpAKa1uL0XN2yOiCtlr8zyS/I=", - "requires": { - "execa": "^0.7.0", - "lcid": "^1.0.0", - "mem": "^1.1.0" - }, - "dependencies": { - "mem": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/mem/-/mem-1.1.0.tgz", - "integrity": "sha1-Xt1StIXKHZAP5kiVUFOZoN+kX3Y=", - "requires": { - "mimic-fn": "^1.0.0" - } - } - } - }, - "os-tmpdir": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", - "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=" - }, - "p-cancelable": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/p-cancelable/-/p-cancelable-1.1.0.tgz", - "integrity": "sha512-s73XxOZ4zpt1edZYZzvhqFa6uvQc1vwUa0K0BdtIZgQMAJj9IbebH+JkgKZc9h+B05PKHLOTl4ajG1BmNrVZlw==" - }, - "p-defer": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/p-defer/-/p-defer-1.0.0.tgz", - "integrity": "sha1-n26xgvbJqozXQwBKfU+WsZaw+ww=" - }, - "p-finally": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/p-finally/-/p-finally-1.0.0.tgz", - "integrity": "sha1-P7z7FbiZpEEjs0ttzBi3JDNqLK4=" - }, - "p-is-promise": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/p-is-promise/-/p-is-promise-2.1.0.tgz", - "integrity": "sha512-Y3W0wlRPK8ZMRbNq97l4M5otioeA5lm1z7bkNkxCka8HSPjR0xRWmpCmc9utiaLP9Jb1eD8BgeIxTW4AIF45Pg==" - }, - "p-limit": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-1.2.0.tgz", - "integrity": "sha512-Y/OtIaXtUPr4/YpMv1pCL5L5ed0rumAaAeBSj12F+bSlMdys7i8oQF/GUJmfpTS/QoaRrS/k6pma29haJpsMng==", - "requires": { - "p-try": "^1.0.0" - } - }, - "p-locate": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-2.0.0.tgz", - "integrity": "sha1-IKAQOyIqcMj9OcwuWAaA893l7EM=", - "requires": { - "p-limit": "^1.1.0" - } - }, - "p-map": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/p-map/-/p-map-2.1.0.tgz", - "integrity": "sha512-y3b8Kpd8OAN444hxfBbFfj1FY/RjtTd8tzYwhUqNYXx0fXx2iX4maP4Qr6qhIKbQXI02wTLAda4fYUbDagTUFw==" - }, - "p-try": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/p-try/-/p-try-1.0.0.tgz", - "integrity": "sha1-y8ec26+P1CKOE/Yh8rGiN8GyB7M=" - }, - "package-hash": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/package-hash/-/package-hash-4.0.0.tgz", - "integrity": "sha512-whdkPIooSu/bASggZ96BWVvZTRMOFxnyUG5PnTSGKoJE2gd5mbVNmR2Nj20QFzxYYgAXpoqC+AiXzl+UMRh7zQ==", - "requires": { - "graceful-fs": "^4.1.15", - "hasha": "^5.0.0", - "lodash.flattendeep": "^4.4.0", - "release-zalgo": "^1.0.0" - }, - "dependencies": { - "graceful-fs": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.0.tgz", - "integrity": "sha512-jpSvDPV4Cq/bgtpndIWbI5hmYxhQGHPC4d4cqBPb4DLniCfhJokdXhwhaDuLBGLQdvvRum/UiX6ECVIPvDXqdg==" - } - } - }, - "package-json": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/package-json/-/package-json-4.0.1.tgz", - "integrity": "sha1-iGmgQBJTZhxMTKPabCEh7VVfXu0=", - "requires": { - "got": "^6.7.1", - "registry-auth-token": "^3.0.1", - "registry-url": "^3.0.3", - "semver": "^5.1.0" - } - }, - "pako": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/pako/-/pako-1.0.6.tgz", - "integrity": "sha1-AQEhG6pwxLykoPY/Igbpe3368lg=" - }, - "parent-module": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", - "integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==", - "requires": { - "callsites": "^3.0.0" - } - }, - "parents": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/parents/-/parents-1.0.1.tgz", - "integrity": "sha1-/t1NK/GTp3dF/nHjcdc8MwfZx1E=", - "requires": { - "path-platform": "~0.11.15" - } - }, - "parse-asn1": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/parse-asn1/-/parse-asn1-5.1.1.tgz", - "integrity": "sha512-KPx7flKXg775zZpnp9SxJlz00gTd4BmJ2yJufSc44gMCRrRQ7NSzAcSJQfifuOLgW6bEi+ftrALtsgALeB2Adw==", - "requires": { - "asn1.js": "^4.0.0", - "browserify-aes": "^1.0.0", - "create-hash": "^1.1.0", - "evp_bytestokey": "^1.0.0", - "pbkdf2": "^3.0.3" - } - }, - "parse-github-repo-url": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/parse-github-repo-url/-/parse-github-repo-url-1.4.1.tgz", - "integrity": "sha1-nn2LslKmy2ukJZUGC3v23z28H1A=" - }, - "parse-json": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-2.2.0.tgz", - "integrity": "sha1-9ID0BDTvgHQfhGkJn43qGPVaTck=", - "requires": { - "error-ex": "^1.2.0" - } - }, - "parse-ms": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/parse-ms/-/parse-ms-2.1.0.tgz", - "integrity": "sha512-kHt7kzLoS9VBZfUsiKjv43mr91ea+U05EyKkEtqp7vNbHxmaVuEqN7XxeEVnGrMtYOAxGrDElSi96K7EgO1zCA==" - }, - "parse-passwd": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/parse-passwd/-/parse-passwd-1.0.0.tgz", - "integrity": "sha1-bVuTSkVpk7I9N/QKOC1vFmao5cY=" - }, - "parseurl": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.2.tgz", - "integrity": "sha1-/CidTtiZMRlGDBViUyYs3I3mW/M=" - }, - "pascalcase": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/pascalcase/-/pascalcase-0.1.1.tgz", - "integrity": "sha1-s2PlXoAGym/iF4TS2yK9FdeRfxQ=" - }, - "patch-text": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/patch-text/-/patch-text-1.0.2.tgz", - "integrity": "sha1-S/NuZeUXM9bpjwz2LgkDTaoDSKw=" - }, - "path-browserify": { - "version": "0.0.0", - "resolved": "https://registry.npmjs.org/path-browserify/-/path-browserify-0.0.0.tgz", - "integrity": "sha1-oLhwcpquIUAFt9UDLsLLuw+0RRo=" - }, - "path-dirname": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/path-dirname/-/path-dirname-1.0.2.tgz", - "integrity": "sha1-zDPSTVJeCZpTiMAzbG4yuRYGCeA=" - }, - "path-exists": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", - "integrity": "sha1-zg6+ql94yxiSXqfYENe1mwEP1RU=" - }, - "path-is-absolute": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", - "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" - }, - "path-is-inside": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/path-is-inside/-/path-is-inside-1.0.2.tgz", - "integrity": "sha1-NlQX3t5EQw0cEa9hAn+s8HS9/FM=" - }, - "path-key": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/path-key/-/path-key-2.0.1.tgz", - "integrity": "sha1-QRyttXTFoUDTpLGRDUDYDMn0C0A=" - }, - "path-parse": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", - "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==" - }, - "path-platform": { - "version": "0.11.15", - "resolved": "https://registry.npmjs.org/path-platform/-/path-platform-0.11.15.tgz", - "integrity": "sha1-6GQhf3TDaFDwhSt43Hv31KVyG/I=" - }, - "path-to-regexp": { - "version": "0.1.7", - "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz", - "integrity": "sha1-32BBeABfUi8V60SQ5yR6G/qmf4w=" - }, - "path-type": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/path-type/-/path-type-2.0.0.tgz", - "integrity": "sha1-8BLMuEFbcJb8LaoQVMPXI4lZTHM=", - "requires": { - "pify": "^2.0.0" - } - }, - "pathval": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.1.tgz", - "integrity": "sha512-Dp6zGqpTdETdR63lehJYPeIOqpiNBNtc7BpWSLrOje7UaIsE5aY92r/AunQA7rsXvet3lrJ3JnZX29UPTKXyKQ==" - }, - "pause-stream": { - "version": "0.0.11", - "resolved": "https://registry.npmjs.org/pause-stream/-/pause-stream-0.0.11.tgz", - "integrity": "sha1-/lo0sMvOErWqaitAPuLnO2AvFEU=", - "requires": { - "through": "~2.3" - } - }, - "pbkdf2": { - "version": "3.0.16", - "resolved": "https://registry.npmjs.org/pbkdf2/-/pbkdf2-3.0.16.tgz", - "integrity": "sha512-y4CXP3thSxqf7c0qmOF+9UeOTrifiVTIM+u7NWlq+PRsHbr7r7dpCmvzrZxa96JJUNi0Y5w9VqG5ZNeCVMoDcA==", - "requires": { - "create-hash": "^1.1.2", - "create-hmac": "^1.1.4", - "ripemd160": "^2.0.1", - "safe-buffer": "^5.0.1", - "sha.js": "^2.4.8" - } - }, - "picomatch": { - "version": "2.0.7", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.0.7.tgz", - "integrity": "sha512-oLHIdio3tZ0qH76NybpeneBhYVj0QFTfXEFTc/B3zKQspYfYYkWYgFsmzo+4kvId/bQRcNkVeguI3y+CD22BtA==" - }, - "pify": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", - "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=" - }, - "pkg-conf": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/pkg-conf/-/pkg-conf-3.1.0.tgz", - "integrity": "sha512-m0OTbR/5VPNPqO1ph6Fqbj7Hv6QU7gR/tQW40ZqrL1rjgCU85W6C1bJn0BItuJqnR98PWzw7Z8hHeChD1WrgdQ==", - "requires": { - "find-up": "^3.0.0", - "load-json-file": "^5.2.0" - }, - "dependencies": { - "find-up": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz", - "integrity": "sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg==", - "requires": { - "locate-path": "^3.0.0" - } - }, - "graceful-fs": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.0.tgz", - "integrity": "sha512-jpSvDPV4Cq/bgtpndIWbI5hmYxhQGHPC4d4cqBPb4DLniCfhJokdXhwhaDuLBGLQdvvRum/UiX6ECVIPvDXqdg==" - }, - "load-json-file": { - "version": "5.3.0", - "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-5.3.0.tgz", - "integrity": "sha512-cJGP40Jc/VXUsp8/OrnyKyTZ1y6v/dphm3bioS+RrKXjK2BB6wHUd6JptZEFDGgGahMT+InnZO5i1Ei9mpC8Bw==", - "requires": { - "graceful-fs": "^4.1.15", - "parse-json": "^4.0.0", - "pify": "^4.0.1", - "strip-bom": "^3.0.0", - "type-fest": "^0.3.0" - } - }, - "locate-path": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz", - "integrity": "sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A==", - "requires": { - "p-locate": "^3.0.0", - "path-exists": "^3.0.0" - } - }, - "p-limit": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.2.0.tgz", - "integrity": "sha512-pZbTJpoUsCzV48Mc9Nh51VbwO0X9cuPFE8gYwx9BTCt9SF8/b7Zljd2fVgOxhIF/HDTKgpVzs+GPhyKfjLLFRQ==", - "requires": { - "p-try": "^2.0.0" - } - }, - "p-locate": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-3.0.0.tgz", - "integrity": "sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==", - "requires": { - "p-limit": "^2.0.0" - } - }, - "p-try": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", - "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==" - }, - "parse-json": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-4.0.0.tgz", - "integrity": "sha1-vjX1Qlvh9/bHRxhPmKeIy5lHfuA=", - "requires": { - "error-ex": "^1.3.1", - "json-parse-better-errors": "^1.0.1" - } - }, - "pify": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/pify/-/pify-4.0.1.tgz", - "integrity": "sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g==" - }, - "type-fest": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.3.1.tgz", - "integrity": "sha512-cUGJnCdr4STbePCgqNFbpVNCepa+kAVohJs1sLhxzdH+gnEoOd8VhbYa7pD3zZYGiURWM2xzEII3fQcRizDkYQ==" - } - } - }, - "pkg-dir": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-4.2.0.tgz", - "integrity": "sha512-HRDzbaKjC+AOWVXxAU/x54COGeIv9eb+6CkDSQoNTt4XyWoIJvuPsXizxu/Fr23EiekbtZwmh1IcIG/l/a10GQ==", - "requires": { - "find-up": "^4.0.0" - }, - "dependencies": { - "find-up": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", - "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", - "requires": { - "locate-path": "^5.0.0", - "path-exists": "^4.0.0" - } - }, - "locate-path": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", - "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", - "requires": { - "p-locate": "^4.1.0" - } - }, - "p-limit": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.2.0.tgz", - "integrity": "sha512-pZbTJpoUsCzV48Mc9Nh51VbwO0X9cuPFE8gYwx9BTCt9SF8/b7Zljd2fVgOxhIF/HDTKgpVzs+GPhyKfjLLFRQ==", - "requires": { - "p-try": "^2.0.0" - } - }, - "p-locate": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", - "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", - "requires": { - "p-limit": "^2.2.0" - } - }, - "p-try": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", - "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==" - }, - "path-exists": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", - "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==" - } - } - }, - "plur": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/plur/-/plur-3.1.1.tgz", - "integrity": "sha512-t1Ax8KUvV3FFII8ltczPn2tJdjqbd1sIzu6t4JL7nQ3EyeL/lTrj5PWKb06ic5/6XYDr65rQ4uzQEGN70/6X5w==", - "requires": { - "irregular-plurals": "^2.0.0" - } - }, - "posix-character-classes": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/posix-character-classes/-/posix-character-classes-0.1.1.tgz", - "integrity": "sha1-AerA/jta9xoqbAL+q7jB/vfgDqs=" - }, - "prelude-ls": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz", - "integrity": "sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=" - }, - "prepend-http": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/prepend-http/-/prepend-http-1.0.4.tgz", - "integrity": "sha1-1PRWKwzjaW5BrFLQ4ALlemNdxtw=" - }, - "prettier": { - "version": "1.12.1", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-1.12.1.tgz", - "integrity": "sha1-wa0g6APndJ+vkFpAnSNn4Gu+cyU=" - }, - "pretty-ms": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/pretty-ms/-/pretty-ms-5.0.0.tgz", - "integrity": "sha512-94VRYjL9k33RzfKiGokPBPpsmloBYSf5Ri+Pq19zlsEcUKFob+admeXr5eFDRuPjFmEOcjJvPGdillYOJyvZ7Q==", - "requires": { - "parse-ms": "^2.1.0" - } - }, - "private": { - "version": "0.1.8", - "resolved": "https://registry.npmjs.org/private/-/private-0.1.8.tgz", - "integrity": "sha1-I4Hts2ifelPWUxkAYPz4ItLzaP8=" - }, - "process": { - "version": "0.11.10", - "resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz", - "integrity": "sha1-czIwDoQBYb2j5podHZGn1LwW8YI=" - }, - "process-nextick-args": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz", - "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==" - }, - "progress": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/progress/-/progress-2.0.3.tgz", - "integrity": "sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==" - }, - "proxy-addr": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.3.tgz", - "integrity": "sha512-jQTChiCJteusULxjBp8+jftSQE5Obdl3k4cnmLA6WXtK6XFuWRnvVL7aCiBqaLPM8c4ph0S4tKna8XvmIwEnXQ==", - "requires": { - "forwarded": "~0.1.2", - "ipaddr.js": "1.6.0" - } - }, - "ps-tree": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/ps-tree/-/ps-tree-1.1.0.tgz", - "integrity": "sha1-tCGyQUDWID8e08dplrRCewjowBQ=", - "requires": { - "event-stream": "~3.3.0" - } - }, - "pseudomap": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/pseudomap/-/pseudomap-1.0.2.tgz", - "integrity": "sha1-8FKijacOYYkX7wqKw0wa5aaChrM=" - }, - "public-encrypt": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/public-encrypt/-/public-encrypt-4.0.2.tgz", - "integrity": "sha512-4kJ5Esocg8X3h8YgJsKAuoesBgB7mqH3eowiDzMUPKiRDDE7E/BqqZD1hnTByIaAFiwAw246YEltSq7tdrOH0Q==", - "requires": { - "bn.js": "^4.1.0", - "browserify-rsa": "^4.0.0", - "create-hash": "^1.1.0", - "parse-asn1": "^5.0.0", - "randombytes": "^2.0.1" - } - }, - "pump": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz", - "integrity": "sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww==", - "requires": { - "end-of-stream": "^1.1.0", - "once": "^1.3.1" - } - }, - "punycode": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz", - "integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4=" - }, - "q": { - "version": "1.5.1", - "resolved": "https://registry.npmjs.org/q/-/q-1.5.1.tgz", - "integrity": "sha1-fjL3W0E4EpHQRhHxvxQQmsAGUdc=" - }, - "qs": { - "version": "6.5.1", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.1.tgz", - "integrity": "sha1-NJzfbu+J7EXBLX1es/wMhwNDptg=" - }, - "querystring": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/querystring/-/querystring-0.2.0.tgz", - "integrity": "sha1-sgmEkgO7Jd+CDadW50cAWHhSFiA=" - }, - "querystring-es3": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/querystring-es3/-/querystring-es3-0.2.1.tgz", - "integrity": "sha1-nsYfeQSYdXB9aUFFlv2Qek1xHnM=" - }, - "quick-lru": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/quick-lru/-/quick-lru-1.1.0.tgz", - "integrity": "sha1-Q2CxfGETatOAeDl/8RQW4Ybc+7g=" - }, - "randombytes": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.0.6.tgz", - "integrity": "sha512-CIQ5OFxf4Jou6uOKe9t1AOgqpeU5fd70A8NPdHSGeYXqXsPe6peOwI0cUl88RWZ6sP1vPMV3avd/R6cZ5/sP1A==", - "requires": { - "safe-buffer": "^5.1.0" - } - }, - "randomfill": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/randomfill/-/randomfill-1.0.4.tgz", - "integrity": "sha512-87lcbR8+MhcWcUiQ+9e+Rwx8MyR2P7qnt15ynUlbm3TU/fjbgz4GsvfSUDTemtCCtVCqb4ZcEFlyPNTh9bBTLw==", - "requires": { - "randombytes": "^2.0.5", - "safe-buffer": "^5.1.0" - } - }, - "range-parser": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.0.tgz", - "integrity": "sha1-9JvmtIeJTdxA3MlKMi9hEJLgDV4=" - }, - "raw-body": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.3.2.tgz", - "integrity": "sha1-vNYMd9Prk83gBQKVw/N5OJvIj4k=", - "requires": { - "bytes": "3.0.0", - "http-errors": "1.6.2", - "iconv-lite": "0.4.19", - "unpipe": "1.0.0" - }, - "dependencies": { - "depd": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.1.tgz", - "integrity": "sha1-V4O04cRZ8G+lyif5kfPQbnoxA1k=" - }, - "http-errors": { - "version": "1.6.2", - "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.6.2.tgz", - "integrity": "sha1-CgAsyFcHGSp+eUbO7cERVfYOxzY=", - "requires": { - "depd": "1.1.1", - "inherits": "2.0.3", - "setprototypeof": "1.0.3", - "statuses": ">= 1.3.1 < 2" - } - }, - "setprototypeof": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.0.3.tgz", - "integrity": "sha1-ZlZ+NwQ+608E2RvWWMDL77VbjgQ=" - } - } - }, - "rc": { - "version": "1.2.7", - "resolved": "https://registry.npmjs.org/rc/-/rc-1.2.7.tgz", - "integrity": "sha512-LdLD8xD4zzLsAT5xyushXDNscEjB7+2ulnl8+r1pnESlYtlJtVSoCMBGr30eDRJ3+2Gq89jK9P9e4tCEH1+ywA==", - "requires": { - "deep-extend": "^0.5.1", - "ini": "~1.3.0", - "minimist": "^1.2.0", - "strip-json-comments": "~2.0.1" - }, - "dependencies": { - "minimist": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", - "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" - } - } - }, - "read-cmd-shim": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/read-cmd-shim/-/read-cmd-shim-1.0.1.tgz", - "integrity": "sha1-LV0Vd4ajfAVdIgd8MsU/gynpHHs=", - "requires": { - "graceful-fs": "^4.1.2" - } - }, - "read-only-stream": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/read-only-stream/-/read-only-stream-2.0.0.tgz", - "integrity": "sha1-JyT9aoET1zdkrCiNQ4YnDB2/F/A=", - "requires": { - "readable-stream": "^2.0.2" - } - }, - "read-pkg": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-2.0.0.tgz", - "integrity": "sha1-jvHAYjxqbbDcZxPEv6xGMysjaPg=", - "requires": { - "load-json-file": "^2.0.0", - "normalize-package-data": "^2.3.2", - "path-type": "^2.0.0" - } - }, - "read-pkg-up": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-2.0.0.tgz", - "integrity": "sha1-a3KoBImE4MQeeVEP1en6mbO1Sb4=", - "requires": { - "find-up": "^2.0.0", - "read-pkg": "^2.0.0" - } - }, - "readable-stream": { - "version": "2.3.6", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", - "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", - "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.3", - "isarray": "~1.0.0", - "process-nextick-args": "~2.0.0", - "safe-buffer": "~5.1.1", - "string_decoder": "~1.1.1", - "util-deprecate": "~1.0.1" - } - }, - "readdirp": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.1.1.tgz", - "integrity": "sha512-XXdSXZrQuvqoETj50+JAitxz1UPdt5dupjT6T5nVB+WvjMv2XKYj+s7hPeAVCXvmJrL36O4YYyWlIC3an2ePiQ==", - "requires": { - "picomatch": "^2.0.4" - } - }, - "redent": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/redent/-/redent-1.0.0.tgz", - "integrity": "sha1-z5Fqsf1fHxbfsggi3W7H9zDCr94=", - "requires": { - "indent-string": "^2.1.0", - "strip-indent": "^1.0.1" - }, - "dependencies": { - "indent-string": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/indent-string/-/indent-string-2.1.0.tgz", - "integrity": "sha1-ji1INIdCEhtKghi3oTfppSBJ3IA=", - "requires": { - "repeating": "^2.0.0" - } - } - } - }, - "regenerate": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/regenerate/-/regenerate-1.4.0.tgz", - "integrity": "sha512-1G6jJVDWrt0rK99kBjvEtziZNCICAuvIPkSiUFIQxVP06RCVpq3dmDo2oi6ABpYaDYaTRr67BEhL8r1wgEZZKg==" - }, - "regenerate-unicode-properties": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/regenerate-unicode-properties/-/regenerate-unicode-properties-8.1.0.tgz", - "integrity": "sha512-LGZzkgtLY79GeXLm8Dp0BVLdQlWICzBnJz/ipWUgo59qBaZ+BHtq51P2q1uVZlppMuUAT37SDk39qUbjTWB7bA==", - "requires": { - "regenerate": "^1.4.0" - } - }, - "regenerator-runtime": { - "version": "0.11.1", - "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz", - "integrity": "sha512-MguG95oij0fC3QV3URf4V2SDYGJhJnJGqvIIgdECeODCT98wSWDAJ94SSuVpYQUoTcGUIL6L4yNB7j1DFFHSBg==" - }, - "regenerator-transform": { - "version": "0.10.1", - "resolved": "https://registry.npmjs.org/regenerator-transform/-/regenerator-transform-0.10.1.tgz", - "integrity": "sha1-HkmWg3Ix2ot/PPQRTXG1aRoGgN0=", - "requires": { - "babel-runtime": "^6.18.0", - "babel-types": "^6.19.0", - "private": "^0.1.6" - } - }, - "regex-not": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/regex-not/-/regex-not-1.0.2.tgz", - "integrity": "sha512-J6SDjUgDxQj5NusnOtdFxDwN/+HWykR8GELwctJ7mdqhcyy1xEc4SRFHUXvxTp661YaVKAjfRLZ9cCqS6tn32A==", - "requires": { - "extend-shallow": "^3.0.2", - "safe-regex": "^1.1.0" - } - }, - "regexpp": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-2.0.1.tgz", - "integrity": "sha512-lv0M6+TkDVniA3aD1Eg0DVpfU/booSu7Eev3TDO/mZKHBfVjgCGTV4t4buppESEYDtkArYFOxTJWv6S5C+iaNw==" - }, - "regexpu-core": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/regexpu-core/-/regexpu-core-2.0.0.tgz", - "integrity": "sha1-SdA4g3uNz4v6W5pCE5k45uoq4kA=", - "requires": { - "regenerate": "^1.2.1", - "regjsgen": "^0.2.0", - "regjsparser": "^0.1.4" - } - }, - "registry-auth-token": { - "version": "3.3.2", - "resolved": "https://registry.npmjs.org/registry-auth-token/-/registry-auth-token-3.3.2.tgz", - "integrity": "sha512-JL39c60XlzCVgNrO+qq68FoNb56w/m7JYvGR2jT5iR1xBrUA3Mfx5Twk5rqTThPmQKMWydGmq8oFtDlxfrmxnQ==", - "requires": { - "rc": "^1.1.6", - "safe-buffer": "^5.0.1" - } - }, - "registry-url": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/registry-url/-/registry-url-3.1.0.tgz", - "integrity": "sha1-PU74cPc93h138M+aOBQyRE4XSUI=", - "requires": { - "rc": "^1.0.1" - } - }, - "regjsgen": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/regjsgen/-/regjsgen-0.2.0.tgz", - "integrity": "sha1-bAFq3qxVT3WCP+N6wFuS1aTtsfc=" - }, - "regjsparser": { - "version": "0.1.5", - "resolved": "https://registry.npmjs.org/regjsparser/-/regjsparser-0.1.5.tgz", - "integrity": "sha1-fuj4Tcb6eS0/0K4ijSS9lJ6tIFw=", - "requires": { - "jsesc": "~0.5.0" - } - }, - "release-zalgo": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/release-zalgo/-/release-zalgo-1.0.0.tgz", - "integrity": "sha1-CXALflB0Mpc5Mw5TXFqQ+2eFFzA=", - "requires": { - "es6-error": "^4.0.1" - } - }, - "rename-function-calls": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/rename-function-calls/-/rename-function-calls-0.1.1.tgz", - "integrity": "sha1-f4M2nAB6MAf2q+MDPM+BaGoQjgE=", - "requires": { - "detective": "~3.1.0" - }, - "dependencies": { - "detective": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/detective/-/detective-3.1.0.tgz", - "integrity": "sha1-d3gkRKt1K4jKG+Lp0KA5Xx2iXu0=", - "requires": { - "escodegen": "~1.1.0", - "esprima-fb": "3001.1.0-dev-harmony-fb" - } - }, - "esprima-fb": { - "version": "3001.1.0-dev-harmony-fb", - "resolved": "https://registry.npmjs.org/esprima-fb/-/esprima-fb-3001.0001.0000-dev-harmony-fb.tgz", - "integrity": "sha1-t303q8046gt3Qmu4vCkizmtCZBE=" - } - } - }, - "repeat-element": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/repeat-element/-/repeat-element-1.1.2.tgz", - "integrity": "sha1-7wiaF40Ug7quTZPrmLT55OEdmQo=" - }, - "repeat-string": { - "version": "1.6.1", - "resolved": "https://registry.npmjs.org/repeat-string/-/repeat-string-1.6.1.tgz", - "integrity": "sha1-jcrkcOHIirwtYA//Sndihtp15jc=" - }, - "repeating": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/repeating/-/repeating-2.0.1.tgz", - "integrity": "sha1-UhTFOpJtNVJwdSf7q0FdvAjQbdo=", - "requires": { - "is-finite": "^1.0.0" - } - }, - "replace-requires": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/replace-requires/-/replace-requires-1.0.4.tgz", - "integrity": "sha1-AUtzMLa54lV7cQQ7ZvsCZgw79mc=", - "requires": { - "detective": "^4.5.0", - "has-require": "~1.2.1", - "patch-text": "~1.0.2", - "xtend": "~4.0.0" - } - }, - "require-directory": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", - "integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I=" - }, - "require-main-filename": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-1.0.1.tgz", - "integrity": "sha1-l/cXtp1IeE9fUmpsWqj/3aBVpNE=" - }, - "require-precompiled": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/require-precompiled/-/require-precompiled-0.1.0.tgz", - "integrity": "sha1-WhtS63Dr7UPrmC6XTIWrWVceVvo=" - }, - "resolve": { - "version": "1.7.1", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.7.1.tgz", - "integrity": "sha512-c7rwLofp8g1U+h1KNyHL/jicrKg1Ek4q+Lr33AL65uZTinUZHe30D5HlyN5V9NW0JX1D5dXQ4jqW5l7Sy/kGfw==", - "requires": { - "path-parse": "^1.0.5" - } - }, - "resolve-cwd": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/resolve-cwd/-/resolve-cwd-3.0.0.tgz", - "integrity": "sha512-OrZaX2Mb+rJCpH/6CpSqt9xFVpN++x01XnN2ie9g6P5/3xelLAkXWVADpdz1IHD/KFfEXyE6V0U01OQ3UO2rEg==", - "requires": { - "resolve-from": "^5.0.0" - } - }, - "resolve-from": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-5.0.0.tgz", - "integrity": "sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==" - }, - "resolve-url": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/resolve-url/-/resolve-url-0.2.1.tgz", - "integrity": "sha1-LGN/53yJOv0qZj/iGqkIAGjiBSo=" - }, - "responselike": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/responselike/-/responselike-1.0.2.tgz", - "integrity": "sha1-kYcg7ztjHFZCvgaPFa3lpG9Loec=", - "requires": { - "lowercase-keys": "^1.0.0" - } - }, - "restore-cursor": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-2.0.0.tgz", - "integrity": "sha1-n37ih/gv0ybU/RYpI9YhKe7g368=", - "requires": { - "onetime": "^2.0.0", - "signal-exit": "^3.0.2" - } - }, - "ret": { - "version": "0.1.15", - "resolved": "https://registry.npmjs.org/ret/-/ret-0.1.15.tgz", - "integrity": "sha512-TTlYpa+OL+vMMNG24xSlQGEJ3B/RzEfUlLct7b5G/ytav+wPrplCpVMFuwzXbkecJrb6IYo1iFb0S9v37754mg==" - }, - "reusify": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/reusify/-/reusify-1.0.4.tgz", - "integrity": "sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==" - }, - "rimraf": { - "version": "2.6.2", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.2.tgz", - "integrity": "sha1-LtgVDSShbqhlHm1u8PR8QVjOejY=", - "requires": { - "glob": "^7.0.5" - } - }, - "ripemd160": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/ripemd160/-/ripemd160-2.0.2.tgz", - "integrity": "sha512-ii4iagi25WusVoiC4B4lq7pbXfAp3D9v5CwfkY33vffw2+pkDjY1D8GaN7spsxvCSx8dkPqOZCEZyfxcmJG2IA==", - "requires": { - "hash-base": "^3.0.0", - "inherits": "^2.0.1" - } - }, - "rollup": { - "version": "0.50.1", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-0.50.1.tgz", - "integrity": "sha1-5Nr8v40rsNn1WJ0MxvZNdriBVzA=" - }, - "rollup-plugin-alias": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/rollup-plugin-alias/-/rollup-plugin-alias-1.4.0.tgz", - "integrity": "sha1-Egy6fEZiHAMTjwym/V3SremHLbk=", - "requires": { - "slash": "^1.0.0" - } - }, - "rollup-plugin-babel": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/rollup-plugin-babel/-/rollup-plugin-babel-3.0.4.tgz", - "integrity": "sha512-TGhQbliTZnRoUhd2214K3r4KJUBu9J1DPzcrAnkluVXOVrveU9OvAaYQ16KyOmujAoq+LMC1+x6YF2xBrU7t+g==", - "requires": { - "rollup-pluginutils": "^1.5.0" - } - }, - "rollup-plugin-commonjs": { - "version": "8.4.1", - "resolved": "https://registry.npmjs.org/rollup-plugin-commonjs/-/rollup-plugin-commonjs-8.4.1.tgz", - "integrity": "sha512-mg+WuD+jlwoo8bJtW3Mvx7Tz6TsIdMsdhuvCnDMoyjh0oxsVgsjB/N0X984RJCWwc5IIiqNVJhXeeITcc73++A==", - "requires": { - "acorn": "^5.2.1", - "estree-walker": "^0.5.0", - "magic-string": "^0.22.4", - "resolve": "^1.4.0", - "rollup-pluginutils": "^2.0.1" - }, - "dependencies": { - "acorn": { - "version": "5.5.3", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.5.3.tgz", - "integrity": "sha512-jd5MkIUlbbmb07nXH0DT3y7rDVtkzDi4XZOUVWAer8ajmF/DTSSbl5oNFyDOl/OXA33Bl79+ypHhl2pN20VeOQ==" - }, - "arr-diff": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-4.0.0.tgz", - "integrity": "sha1-1kYQdP6/7HHn4VI1dhoyml3HxSA=" - }, - "array-unique": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.3.2.tgz", - "integrity": "sha1-qJS3XUvE9s1nnvMkSp/Y9Gri1Cg=" - }, - "estree-walker": { - "version": "0.5.2", - "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-0.5.2.tgz", - "integrity": "sha512-XpCnW/AE10ws/kDAs37cngSkvgIR8aN3G0MS85m7dUpuK2EREo9VJ00uvw6Dg/hXEpfsE1I1TvJOJr+Z+TL+ig==" - }, - "expand-brackets": { - "version": "2.1.4", - "resolved": "https://registry.npmjs.org/expand-brackets/-/expand-brackets-2.1.4.tgz", - "integrity": "sha1-t3c14xXOMPa27/D4OwQVGiJEliI=", - "requires": { - "debug": "^2.3.3", - "define-property": "^0.2.5", - "extend-shallow": "^2.0.1", - "posix-character-classes": "^0.1.0", - "regex-not": "^1.0.0", - "snapdragon": "^0.8.1", - "to-regex": "^3.0.1" - }, - "dependencies": { - "define-property": { - "version": "0.2.5", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", - "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", - "requires": { - "is-descriptor": "^0.1.0" - } - }, - "extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "requires": { - "is-extendable": "^0.1.0" - } - }, - "is-accessor-descriptor": { - "version": "0.1.6", - "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz", - "integrity": "sha1-qeEss66Nh2cn7u84Q/igiXtcmNY=", - "requires": { - "kind-of": "^3.0.2" - }, - "dependencies": { - "kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "requires": { - "is-buffer": "^1.1.5" - } - } - } - }, - "is-data-descriptor": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz", - "integrity": "sha1-C17mSDiOLIYCgueT8YVv7D8wG1Y=", - "requires": { - "kind-of": "^3.0.2" - }, - "dependencies": { - "kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "requires": { - "is-buffer": "^1.1.5" - } - } - } - }, - "is-descriptor": { - "version": "0.1.6", - "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-0.1.6.tgz", - "integrity": "sha512-avDYr0SB3DwO9zsMov0gKCESFYqCnE4hq/4z3TdUlukEy5t9C0YRq7HLrsN52NAcqXKaepeCD0n+B0arnVG3Hg==", - "requires": { - "is-accessor-descriptor": "^0.1.6", - "is-data-descriptor": "^0.1.4", - "kind-of": "^5.0.0" - } - }, - "kind-of": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-5.1.0.tgz", - "integrity": "sha512-NGEErnH6F2vUuXDh+OlbcKW7/wOcfdRHaZ7VWtqCztfHri/++YKmP51OdWeGPuqCOba6kk2OTe5d02VmTB80Pw==" - } - } - }, - "extglob": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/extglob/-/extglob-2.0.4.tgz", - "integrity": "sha512-Nmb6QXkELsuBr24CJSkilo6UHHgbekK5UiZgfE6UHD3Eb27YC6oD+bhcT+tJ6cl8dmsgdQxnWlcry8ksBIBLpw==", - "requires": { - "array-unique": "^0.3.2", - "define-property": "^1.0.0", - "expand-brackets": "^2.1.4", - "extend-shallow": "^2.0.1", - "fragment-cache": "^0.2.1", - "regex-not": "^1.0.0", - "snapdragon": "^0.8.1", - "to-regex": "^3.0.1" - }, - "dependencies": { - "define-property": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", - "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", - "requires": { - "is-descriptor": "^1.0.0" - } - }, - "extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "requires": { - "is-extendable": "^0.1.0" - } - } - } - }, - "is-accessor-descriptor": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", - "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", - "requires": { - "kind-of": "^6.0.0" - } - }, - "is-data-descriptor": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", - "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", - "requires": { - "kind-of": "^6.0.0" - } - }, - "is-descriptor": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", - "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", - "requires": { - "is-accessor-descriptor": "^1.0.0", - "is-data-descriptor": "^1.0.0", - "kind-of": "^6.0.2" - } - }, - "kind-of": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz", - "integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==" - }, - "rollup-pluginutils": { - "version": "2.5.0", - "resolved": "https://registry.npmjs.org/rollup-pluginutils/-/rollup-pluginutils-2.5.0.tgz", - "integrity": "sha512-9Muh1H+XB5f5ONmKMayUoTYR1EZwHbwJJ9oZLrKT5yuTf/RLIQ5mYIGsrERquVucJmjmaAW0Y7+6Qo1Ep+5w3Q==", - "requires": { - "estree-walker": "^0.6.0", - "micromatch": "^3.1.10" - }, - "dependencies": { - "estree-walker": { - "version": "0.6.0", - "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-0.6.0.tgz", - "integrity": "sha512-peq1RfVAVzr3PU/jL31RaOjUKLoZJpObQWJJ+LgfcxDUifyLZ1RjPQZTl0pzj2uJ45b7A7XpyppXvxdEqzo4rw==" - }, - "micromatch": { - "version": "3.1.10", - "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-3.1.10.tgz", - "integrity": "sha512-MWikgl9n9M3w+bpsY3He8L+w9eF9338xRl8IAO5viDizwSzziFEyUzo2xrrloB64ADbTf8uA8vRqqttDTOmccg==", - "requires": { - "arr-diff": "^4.0.0", - "array-unique": "^0.3.2", - "braces": "^2.3.1", - "define-property": "^2.0.2", - "extend-shallow": "^3.0.2", - "extglob": "^2.0.4", - "fragment-cache": "^0.2.1", - "kind-of": "^6.0.2", - "nanomatch": "^1.2.9", - "object.pick": "^1.3.0", - "regex-not": "^1.0.0", - "snapdragon": "^0.8.1", - "to-regex": "^3.0.2" - } - } - } - } - } - }, - "rollup-plugin-node-resolve": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/rollup-plugin-node-resolve/-/rollup-plugin-node-resolve-3.3.0.tgz", - "integrity": "sha512-9zHGr3oUJq6G+X0oRMYlzid9fXicBdiydhwGChdyeNRGPcN/majtegApRKHLR5drboUvEWU+QeUmGTyEZQs3WA==", - "requires": { - "builtin-modules": "^2.0.0", - "is-module": "^1.0.0", - "resolve": "^1.1.6" - }, - "dependencies": { - "builtin-modules": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-2.0.0.tgz", - "integrity": "sha512-3U5kUA5VPsRUA3nofm/BXX7GVHKfxz0hOBAPxXrIvHzlDRkQVqEn6yi8QJegxl4LzOHLdvb7XF5dVawa/VVYBg==" - } - } - }, - "rollup-plugin-sourcemaps": { - "version": "0.4.2", - "resolved": "https://registry.npmjs.org/rollup-plugin-sourcemaps/-/rollup-plugin-sourcemaps-0.4.2.tgz", - "integrity": "sha1-YhJaqUCHqt97g+9N+vYptHMTXoc=", - "requires": { - "rollup-pluginutils": "^2.0.1", - "source-map-resolve": "^0.5.0" - }, - "dependencies": { - "estree-walker": { - "version": "0.6.0", - "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-0.6.0.tgz", - "integrity": "sha512-peq1RfVAVzr3PU/jL31RaOjUKLoZJpObQWJJ+LgfcxDUifyLZ1RjPQZTl0pzj2uJ45b7A7XpyppXvxdEqzo4rw==" - }, - "kind-of": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz", - "integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==" - }, - "rollup-pluginutils": { - "version": "2.5.0", - "resolved": "https://registry.npmjs.org/rollup-pluginutils/-/rollup-pluginutils-2.5.0.tgz", - "integrity": "sha512-9Muh1H+XB5f5ONmKMayUoTYR1EZwHbwJJ9oZLrKT5yuTf/RLIQ5mYIGsrERquVucJmjmaAW0Y7+6Qo1Ep+5w3Q==", - "requires": { - "estree-walker": "^0.6.0", - "micromatch": "^3.1.10" - }, - "dependencies": { - "micromatch": { - "version": "3.1.10", - "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-3.1.10.tgz", - "integrity": "sha512-MWikgl9n9M3w+bpsY3He8L+w9eF9338xRl8IAO5viDizwSzziFEyUzo2xrrloB64ADbTf8uA8vRqqttDTOmccg==", - "requires": { - "arr-diff": "^4.0.0", - "array-unique": "^0.3.2", - "braces": "^2.3.1", - "define-property": "^2.0.2", - "extend-shallow": "^3.0.2", - "extglob": "^2.0.4", - "fragment-cache": "^0.2.1", - "kind-of": "^6.0.2", - "nanomatch": "^1.2.9", - "object.pick": "^1.3.0", - "regex-not": "^1.0.0", - "snapdragon": "^0.8.1", - "to-regex": "^3.0.2" - } - } - } - } - } - }, - "rollup-pluginutils": { - "version": "1.5.2", - "resolved": "https://registry.npmjs.org/rollup-pluginutils/-/rollup-pluginutils-1.5.2.tgz", - "integrity": "sha1-HhVud4+UtyVb+hs9AXi+j1xVJAg=", - "requires": { - "estree-walker": "^0.2.1", - "minimatch": "^3.0.2" - } - }, - "run-async": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/run-async/-/run-async-2.3.0.tgz", - "integrity": "sha1-A3GrSuC91yDUFm19/aZP96RFpsA=", - "requires": { - "is-promise": "^2.1.0" - } - }, - "run-parallel": { - "version": "1.1.9", - "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.1.9.tgz", - "integrity": "sha512-DEqnSRTDw/Tc3FXf49zedI638Z9onwUotBMiUFKmrO2sdFKIbXamXGQ3Axd4qgphxKB4kw/qP1w5kTxnfU1B9Q==" - }, - "rx-lite": { - "version": "4.0.8", - "resolved": "https://registry.npmjs.org/rx-lite/-/rx-lite-4.0.8.tgz", - "integrity": "sha1-Cx4Rr4vESDbwSmQH6S2kJGe3lEQ=" - }, - "rx-lite-aggregates": { - "version": "4.0.8", - "resolved": "https://registry.npmjs.org/rx-lite-aggregates/-/rx-lite-aggregates-4.0.8.tgz", - "integrity": "sha1-dTuHqJoRyVRnxKwWJsTvxOBcZ74=", - "requires": { - "rx-lite": "*" - } - }, - "rxjs": { - "version": "6.5.2", - "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.5.2.tgz", - "integrity": "sha512-HUb7j3kvb7p7eCUHE3FqjoDsC1xfZQ4AHFWfTKSpZ+sAhhz5X1WX0ZuUqWbzB2QhSLp3DoLUG+hMdEDKqWo2Zg==", - "requires": { - "tslib": "^1.9.0" - } - }, - "safe-buffer": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" - }, - "safe-regex": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/safe-regex/-/safe-regex-1.1.0.tgz", - "integrity": "sha1-QKNmnzsHfR6UPURinhV91IAjvy4=", - "requires": { - "ret": "~0.1.10" - } - }, - "safer-buffer": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", - "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" - }, - "semver": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.5.0.tgz", - "integrity": "sha512-4SJ3dm0WAwWy/NVeioZh5AntkdJoWKxHxcmyP622fOkgHa4z3R0TdBJICINyaSDE6uNwVc8gZr+ZinwZAH4xIA==" - }, - "semver-diff": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/semver-diff/-/semver-diff-2.1.0.tgz", - "integrity": "sha1-S7uEN8jTfksM8aaP1ybsbWRdbTY=", - "requires": { - "semver": "^5.0.3" - } - }, - "send": { - "version": "0.16.2", - "resolved": "https://registry.npmjs.org/send/-/send-0.16.2.tgz", - "integrity": "sha512-E64YFPUssFHEFBvpbbjr44NCLtI1AohxQ8ZSiJjQLskAdKuriYEP6VyGEsRDH8ScozGpkaX1BGvhanqCwkcEZw==", - "requires": { - "debug": "2.6.9", - "depd": "~1.1.2", - "destroy": "~1.0.4", - "encodeurl": "~1.0.2", - "escape-html": "~1.0.3", - "etag": "~1.8.1", - "fresh": "0.5.2", - "http-errors": "~1.6.2", - "mime": "1.4.1", - "ms": "2.0.0", - "on-finished": "~2.3.0", - "range-parser": "~1.2.0", - "statuses": "~1.4.0" - }, - "dependencies": { - "ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" - } - } - }, - "serialize-error": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/serialize-error/-/serialize-error-2.1.0.tgz", - "integrity": "sha1-ULZ51WNc34Rme9yOWa9OW4HV9go=" - }, - "serve-static": { - "version": "1.13.2", - "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.13.2.tgz", - "integrity": "sha512-p/tdJrO4U387R9oMjb1oj7qSMaMfmOyd4j9hOFoxZe2baQszgHcSWjuya/CiT5kgZZKRudHNOA0pYXOl8rQ5nw==", - "requires": { - "encodeurl": "~1.0.2", - "escape-html": "~1.0.3", - "parseurl": "~1.3.2", - "send": "0.16.2" - } - }, - "set-blocking": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", - "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=" - }, - "set-value": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/set-value/-/set-value-4.1.0.tgz", - "integrity": "sha512-zTEg4HL0RwVrqcWs3ztF+x1vkxfm0lP+MQQFPiMJTKVceBwEV0A569Ou8l9IYQG8jOZdMVI1hGsc0tmeD2o/Lw==", - "requires": { - "is-plain-object": "^2.0.4", - "is-primitive": "^3.0.1" - } - }, - "setprototypeof": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.0.tgz", - "integrity": "sha1-0L2FU2iHtv58DYGMuWLZ2RxU5lY=" - }, - "sha.js": { - "version": "2.4.11", - "resolved": "https://registry.npmjs.org/sha.js/-/sha.js-2.4.11.tgz", - "integrity": "sha512-QMEp5B7cftE7APOjk5Y6xgrbWu+WkLVQwk8JNjZ8nKRciZaByEW6MubieAiToS7+dwvrjGhH8jRXz3MVd0AYqQ==", - "requires": { - "inherits": "^2.0.1", - "safe-buffer": "^5.0.1" - } - }, - "shasum": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/shasum/-/shasum-1.0.2.tgz", - "integrity": "sha1-5wEjENj0F/TetXEhUOVni4euVl8=", - "requires": { - "json-stable-stringify": "~0.0.0", - "sha.js": "~2.4.4" - } - }, - "shebang-command": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-1.2.0.tgz", - "integrity": "sha1-RKrGW2lbAzmJaMOfNj/uXer98eo=", - "requires": { - "shebang-regex": "^1.0.0" - } - }, - "shebang-regex": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-1.0.0.tgz", - "integrity": "sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=" - }, - "shell-quote": { - "version": "1.6.1", - "resolved": "https://registry.npmjs.org/shell-quote/-/shell-quote-1.6.1.tgz", - "integrity": "sha1-9HgZSczkAmlxJ0MOo7PFR29IF2c=", - "requires": { - "array-filter": "~0.0.0", - "array-map": "~0.0.0", - "array-reduce": "~0.0.0", - "jsonify": "~0.0.0" - } - }, - "signal-exit": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", - "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=" - }, - "slash": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/slash/-/slash-1.0.0.tgz", - "integrity": "sha1-xB8vbDn8FtHNF61LXYlhFK5HDVU=" - }, - "slice-ansi": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-2.1.0.tgz", - "integrity": "sha512-Qu+VC3EwYLldKa1fCxuuvULvSJOKEgk9pi8dZeCVK7TqBfUNTH4sFkk4joj8afVSfAYgJoSOetjx9QWOJ5mYoQ==", - "requires": { - "ansi-styles": "^3.2.0", - "astral-regex": "^1.0.0", - "is-fullwidth-code-point": "^2.0.0" - } - }, - "snapdragon": { - "version": "0.8.2", - "resolved": "https://registry.npmjs.org/snapdragon/-/snapdragon-0.8.2.tgz", - "integrity": "sha512-FtyOnWN/wCHTVXOMwvSv26d+ko5vWlIDD6zoUJ7LW8vh+ZBC8QdljveRP+crNrtBwioEUWy/4dMtbBjA4ioNlg==", - "requires": { - "base": "^0.11.1", - "debug": "^2.2.0", - "define-property": "^0.2.5", - "extend-shallow": "^2.0.1", - "map-cache": "^0.2.2", - "source-map": "^0.5.6", - "source-map-resolve": "^0.5.0", - "use": "^3.1.0" - }, - "dependencies": { - "define-property": { - "version": "0.2.5", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", - "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", - "requires": { - "is-descriptor": "^0.1.0" - } - }, - "extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "requires": { - "is-extendable": "^0.1.0" - } - } - } - }, - "snapdragon-node": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/snapdragon-node/-/snapdragon-node-2.1.1.tgz", - "integrity": "sha512-O27l4xaMYt/RSQ5TR3vpWCAB5Kb/czIcqUFOM/C4fYcLnbZUc1PkjTAMjof2pBWaSTwOUd6qUHcFGVGj7aIwnw==", - "requires": { - "define-property": "^1.0.0", - "isobject": "^3.0.0", - "snapdragon-util": "^3.0.1" - }, - "dependencies": { - "define-property": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", - "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", - "requires": { - "is-descriptor": "^1.0.0" - } - }, - "is-accessor-descriptor": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", - "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", - "requires": { - "kind-of": "^6.0.0" - } - }, - "is-data-descriptor": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", - "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", - "requires": { - "kind-of": "^6.0.0" - } - }, - "is-descriptor": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", - "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", - "requires": { - "is-accessor-descriptor": "^1.0.0", - "is-data-descriptor": "^1.0.0", - "kind-of": "^6.0.2" - } - }, - "isobject": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", - "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=" - }, - "kind-of": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz", - "integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==" - } - } - }, - "snapdragon-util": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/snapdragon-util/-/snapdragon-util-3.0.1.tgz", - "integrity": "sha512-mbKkMdQKsjX4BAL4bRYTj21edOf8cN7XHdYUJEe+Zn99hVEYcMvKPct1IqNe7+AZPirn8BCDOQBHQZknqmKlZQ==", - "requires": { - "kind-of": "^3.2.0" - } - }, - "sort-keys": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/sort-keys/-/sort-keys-2.0.0.tgz", - "integrity": "sha1-ZYU1WEhh7JfXMNbPQYIuH1ZoQSg=", - "requires": { - "is-plain-obj": "^1.0.0" - } - }, - "source-map": { - "version": "0.5.7", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", - "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=" - }, - "source-map-resolve": { - "version": "0.5.2", - "resolved": "https://registry.npmjs.org/source-map-resolve/-/source-map-resolve-0.5.2.tgz", - "integrity": "sha512-MjqsvNwyz1s0k81Goz/9vRBe9SZdB09Bdw+/zYyO+3CuPk6fouTaxscHkgtE8jKvf01kVfl8riHzERQ/kefaSA==", - "requires": { - "atob": "^2.1.1", - "decode-uri-component": "^0.2.0", - "resolve-url": "^0.2.1", - "source-map-url": "^0.4.0", - "urix": "^0.1.0" - } - }, - "source-map-support": { - "version": "0.4.18", - "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.4.18.tgz", - "integrity": "sha1-Aoam3ovkJkEzhZTpfM6nXwosWF8=", - "requires": { - "source-map": "^0.5.6" - } - }, - "source-map-url": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/source-map-url/-/source-map-url-0.4.0.tgz", - "integrity": "sha1-PpNdfd1zYxuXZZlW1VEo6HtQhKM=" - }, - "spdx-correct": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.0.0.tgz", - "integrity": "sha512-N19o9z5cEyc8yQQPukRCZ9EUmb4HUpnrmaL/fxS2pBo2jbfcFRVuFZ/oFC+vZz0MNNk0h80iMn5/S6qGZOL5+g==", - "requires": { - "spdx-expression-parse": "^3.0.0", - "spdx-license-ids": "^3.0.0" - } - }, - "spdx-exceptions": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/spdx-exceptions/-/spdx-exceptions-2.1.0.tgz", - "integrity": "sha512-4K1NsmrlCU1JJgUrtgEeTVyfx8VaYea9J9LvARxhbHtVtohPs/gFGG5yy49beySjlIMhhXZ4QqujIZEfS4l6Cg==" - }, - "spdx-expression-parse": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-3.0.0.tgz", - "integrity": "sha512-Yg6D3XpRD4kkOmTpdgbUiEJFKghJH03fiC1OPll5h/0sO6neh2jqRDVHOQ4o/LMea0tgCkbMgea5ip/e+MkWyg==", - "requires": { - "spdx-exceptions": "^2.1.0", - "spdx-license-ids": "^3.0.0" - } - }, - "spdx-license-ids": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.0.tgz", - "integrity": "sha512-2+EPwgbnmOIl8HjGBXXMd9NAu02vLjOO1nWw4kmeRDFyHn+M/ETfHxQUK0oXg8ctgVnl9t3rosNVsZ1jG61nDA==" - }, - "split": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/split/-/split-1.0.1.tgz", - "integrity": "sha512-mTyOoPbrivtXnwnIxZRFYRrPNtEFKlpB2fvjSnCQUiAA6qAZzqwna5envK4uk6OIeP17CsdF3rSBGYVBsU0Tkg==", - "requires": { - "through": "2" - } - }, - "split-string": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/split-string/-/split-string-3.1.0.tgz", - "integrity": "sha512-NzNVhJDYpwceVVii8/Hu6DKfD2G+NrQHlS/V/qgv763EYudVwEcMQNxd2lh+0VrUByXN/oJkl5grOhYWvQUYiw==", - "requires": { - "extend-shallow": "^3.0.0" - } - }, - "split2": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/split2/-/split2-2.2.0.tgz", - "integrity": "sha512-RAb22TG39LhI31MbreBgIuKiIKhVsawfTgEGqKHTK87aG+ul/PB8Sqoi3I7kVdRWiCfrKxK3uo4/YUkpNvhPbw==", - "requires": { - "through2": "^2.0.2" - } - }, - "sprintf-js": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", - "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=" - }, - "stack-utils": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/stack-utils/-/stack-utils-1.0.2.tgz", - "integrity": "sha512-MTX+MeG5U994cazkjd/9KNAapsHnibjMLnfXodlkXw76JEea0UiNzrqidzo1emMwk7w5Qhc9jd4Bn9TBb1MFwA==" - }, - "static-extend": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/static-extend/-/static-extend-0.1.2.tgz", - "integrity": "sha1-YICcOcv/VTNyJv1eC1IPNB8ftcY=", - "requires": { - "define-property": "^0.2.5", - "object-copy": "^0.1.0" - }, - "dependencies": { - "define-property": { - "version": "0.2.5", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", - "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", - "requires": { - "is-descriptor": "^0.1.0" - } - } - } - }, - "statuses": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.4.0.tgz", - "integrity": "sha512-zhSCtt8v2NDrRlPQpCNtw/heZLtfUDqxBM1udqikb/Hbk52LK4nQSwr10u77iopCW5LsyHpuXS0GnEc48mLeew==" - }, - "stream-browserify": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/stream-browserify/-/stream-browserify-2.0.1.tgz", - "integrity": "sha1-ZiZu5fm9uZQKTkUUyvtDu3Hlyds=", - "requires": { - "inherits": "~2.0.1", - "readable-stream": "^2.0.2" - } - }, - "stream-combiner": { - "version": "0.0.4", - "resolved": "https://registry.npmjs.org/stream-combiner/-/stream-combiner-0.0.4.tgz", - "integrity": "sha1-TV5DPBhSYd3mI8o/RMWGvPXErRQ=", - "requires": { - "duplexer": "~0.1.1" - } - }, - "stream-combiner2": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/stream-combiner2/-/stream-combiner2-1.1.1.tgz", - "integrity": "sha1-+02KFCDqNidk4hrUeAOXvry0HL4=", - "requires": { - "duplexer2": "~0.1.0", - "readable-stream": "^2.0.2" - } - }, - "stream-http": { - "version": "2.8.2", - "resolved": "https://registry.npmjs.org/stream-http/-/stream-http-2.8.2.tgz", - "integrity": "sha512-QllfrBhqF1DPcz46WxKTs6Mz1Bpc+8Qm6vbqOpVav5odAXwbyzwnEczoWqtxrsmlO+cJqtPrp/8gWKWjaKLLlA==", - "requires": { - "builtin-status-codes": "^3.0.0", - "inherits": "^2.0.1", - "readable-stream": "^2.3.6", - "to-arraybuffer": "^1.0.0", - "xtend": "^4.0.0" - } - }, - "stream-splicer": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/stream-splicer/-/stream-splicer-2.0.0.tgz", - "integrity": "sha1-G2O+Q4oTPktnHMGTUZdgAXWRDYM=", - "requires": { - "inherits": "^2.0.1", - "readable-stream": "^2.0.2" - } - }, - "string-width": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", - "integrity": "sha1-q5Pyeo3BPSjKyBXEYhQ6bZASrp4=", - "requires": { - "is-fullwidth-code-point": "^2.0.0", - "strip-ansi": "^4.0.0" - } - }, - "string_decoder": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", - "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", - "requires": { - "safe-buffer": "~5.1.0" - } - }, - "strip-ansi": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", - "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", - "requires": { - "ansi-regex": "^3.0.0" - }, - "dependencies": { - "ansi-regex": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", - "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=" - } - } - }, - "strip-bom": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", - "integrity": "sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM=" - }, - "strip-bom-buf": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/strip-bom-buf/-/strip-bom-buf-2.0.0.tgz", - "integrity": "sha512-gLFNHucd6gzb8jMsl5QmZ3QgnUJmp7qn4uUSHNwEXumAp7YizoGYw19ZUVfuq4aBOQUtyn2k8X/CwzWB73W2lQ==", - "requires": { - "is-utf8": "^0.2.1" - } - }, - "strip-eof": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/strip-eof/-/strip-eof-1.0.0.tgz", - "integrity": "sha1-u0P/VZim6wXYm1n80SnJgzE2Br8=" - }, - "strip-indent": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/strip-indent/-/strip-indent-1.0.1.tgz", - "integrity": "sha1-DHlipq3vp7vUrDZkYKY4VSrhoKI=", - "requires": { - "get-stdin": "^4.0.1" - } - }, - "strip-json-comments": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", - "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=" - }, - "strong-log-transformer": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/strong-log-transformer/-/strong-log-transformer-1.0.6.tgz", - "integrity": "sha1-9/uTdYpppXEUAYEnfuoMLrEwH6M=", - "requires": { - "byline": "^5.0.0", - "duplexer": "^0.1.1", - "minimist": "^0.1.0", - "moment": "^2.6.0", - "through": "^2.3.4" - }, - "dependencies": { - "minimist": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.1.0.tgz", - "integrity": "sha1-md9lelJXTCHJBXSX33QnkLK0wN4=" - } - } - }, - "subarg": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/subarg/-/subarg-1.0.0.tgz", - "integrity": "sha1-9izxdYHplrSPyWVpn1TAauJouNI=", - "requires": { - "minimist": "^1.1.0" - }, - "dependencies": { - "minimist": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", - "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" - } - } - }, - "supertap": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/supertap/-/supertap-1.0.0.tgz", - "integrity": "sha512-HZJ3geIMPgVwKk2VsmO5YHqnnJYl6bV5A9JW2uzqV43WmpgliNEYbuvukfor7URpaqpxuw3CfZ3ONdVbZjCgIA==", - "requires": { - "arrify": "^1.0.1", - "indent-string": "^3.2.0", - "js-yaml": "^3.10.0", - "serialize-error": "^2.1.0", - "strip-ansi": "^4.0.0" - } - }, - "supports-color": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.0.0.tgz", - "integrity": "sha512-WRt32iTpYEZWYOpcetGm0NPeSvaebccx7hhS/5M6sAiqnhedtFCHFxkjzZlJvFNCPowiKSFGiZk5USQDFy83vQ==", - "requires": { - "has-flag": "^4.0.0" - }, - "dependencies": { - "has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==" - } - } - }, - "symbol-observable": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/symbol-observable/-/symbol-observable-1.2.0.tgz", - "integrity": "sha512-e900nM8RRtGhlV36KGEU9k65K3mPb1WV70OdjfxlG2EAuM1noi/E/BaW/uMhL7bPEssK8QV57vN3esixjUvcXQ==" - }, - "syntax-error": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/syntax-error/-/syntax-error-1.4.0.tgz", - "integrity": "sha512-YPPlu67mdnHGTup2A8ff7BC2Pjq0e0Yp/IyTFN03zWO0RcK07uLcbi7C2KpGR2FvWbaB0+bfE27a+sBKebSo7w==", - "requires": { - "acorn-node": "^1.2.0" - } - }, - "table": { - "version": "5.4.6", - "resolved": "https://registry.npmjs.org/table/-/table-5.4.6.tgz", - "integrity": "sha512-wmEc8m4fjnob4gt5riFRtTu/6+4rSe12TpAELNSqHMfF3IqnA+CH37USM6/YR3qRZv7e56kAEAtd6nKZaxe0Ug==", - "requires": { - "ajv": "^6.10.2", - "lodash": "^4.17.14", - "slice-ansi": "^2.1.0", - "string-width": "^3.0.0" - }, - "dependencies": { - "ansi-regex": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", - "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==" - }, - "string-width": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz", - "integrity": "sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w==", - "requires": { - "emoji-regex": "^7.0.1", - "is-fullwidth-code-point": "^2.0.0", - "strip-ansi": "^5.1.0" - } - }, - "strip-ansi": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", - "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", - "requires": { - "ansi-regex": "^4.1.0" - } - } - } - }, - "temp-dir": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/temp-dir/-/temp-dir-1.0.0.tgz", - "integrity": "sha1-CnwOom06Oa+n4OvqnB/AvE2qAR0=" - }, - "temp-write": { - "version": "3.4.0", - "resolved": "https://registry.npmjs.org/temp-write/-/temp-write-3.4.0.tgz", - "integrity": "sha1-jP9jD7fp2gXwR8dM5M5NaFRX1JI=", - "requires": { - "graceful-fs": "^4.1.2", - "is-stream": "^1.1.0", - "make-dir": "^1.0.0", - "pify": "^3.0.0", - "temp-dir": "^1.0.0", - "uuid": "^3.0.1" - }, - "dependencies": { - "pify": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/pify/-/pify-3.0.0.tgz", - "integrity": "sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY=" - }, - "uuid": { - "version": "3.3.2", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.2.tgz", - "integrity": "sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA==" - } - } - }, - "tempfile": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/tempfile/-/tempfile-1.1.1.tgz", - "integrity": "sha1-W8xOrsxKsscH2LwR2ZzMmiyyh/I=", - "requires": { - "os-tmpdir": "^1.0.0", - "uuid": "^2.0.1" - } - }, - "term-size": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/term-size/-/term-size-1.2.0.tgz", - "integrity": "sha1-RYuDiH8oj8Vtb/+/rSYuJmOO+mk=", - "requires": { - "execa": "^0.7.0" - } - }, - "ternary": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/ternary/-/ternary-1.0.0.tgz", - "integrity": "sha1-RXAnJWCMlJnUapYQ6bDkn/JveJ4=" - }, - "text-extensions": { - "version": "1.7.0", - "resolved": "https://registry.npmjs.org/text-extensions/-/text-extensions-1.7.0.tgz", - "integrity": "sha1-+qq6JiXtdG1WiiPk0KrNm/CKizk=" - }, - "text-table": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", - "integrity": "sha1-f17oI66AUgfACvLfSoTsP8+lcLQ=" - }, - "through": { - "version": "2.3.8", - "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", - "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=" - }, - "through2": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/through2/-/through2-2.0.3.tgz", - "integrity": "sha1-AARWmzfHx0ujnEPzzteNGtlBQL4=", - "requires": { - "readable-stream": "^2.1.5", - "xtend": "~4.0.1" - } - }, - "time-zone": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/time-zone/-/time-zone-1.0.0.tgz", - "integrity": "sha1-mcW/VZWJZq9tBtg73zgA3IL67F0=" - }, - "timed-out": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/timed-out/-/timed-out-4.0.1.tgz", - "integrity": "sha1-8y6srFoXW+ol1/q1Zas+2HQe9W8=" - }, - "timers-browserify": { - "version": "1.4.2", - "resolved": "https://registry.npmjs.org/timers-browserify/-/timers-browserify-1.4.2.tgz", - "integrity": "sha1-ycWLV1voQHN1y14kYtrO50NZ9B0=", - "requires": { - "process": "~0.11.0" - } - }, - "tmp": { - "version": "0.0.33", - "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz", - "integrity": "sha1-bTQzWIl2jSGyvNoKonfO07G/rfk=", - "requires": { - "os-tmpdir": "~1.0.2" - } - }, - "to-arraybuffer": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/to-arraybuffer/-/to-arraybuffer-1.0.1.tgz", - "integrity": "sha1-fSKbH8xjfkZsoIEYCDanqr/4P0M=" - }, - "to-fast-properties": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-1.0.3.tgz", - "integrity": "sha1-uDVx+k2MJbguIxsG46MFXeTKGkc=" - }, - "to-object-path": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/to-object-path/-/to-object-path-0.3.0.tgz", - "integrity": "sha1-KXWIt7Dn4KwI4E5nL4XB9JmeF68=", - "requires": { - "kind-of": "^3.0.2" - } - }, - "to-readable-stream": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/to-readable-stream/-/to-readable-stream-1.0.0.tgz", - "integrity": "sha512-Iq25XBt6zD5npPhlLVXGFN3/gyR2/qODcKNNyTMd4vbm39HUaOiAM4PMq0eMVC/Tkxz+Zjdsc55g9yyz+Yq00Q==" - }, - "to-regex": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/to-regex/-/to-regex-3.0.2.tgz", - "integrity": "sha512-FWtleNAtZ/Ki2qtqej2CXTOayOH9bHDQF+Q48VpWyDXjbYxA4Yz8iDB31zXOBUlOHHKidDbqGVrTUvQMPmBGBw==", - "requires": { - "define-property": "^2.0.2", - "extend-shallow": "^3.0.2", - "regex-not": "^1.0.2", - "safe-regex": "^1.1.0" - } - }, - "to-regex-range": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-2.1.1.tgz", - "integrity": "sha1-fIDBe53+vlmeJzZ+DU3VWQFB2zg=", - "requires": { - "is-number": "^3.0.0", - "repeat-string": "^1.6.1" - }, - "dependencies": { - "is-number": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-number/-/is-number-3.0.0.tgz", - "integrity": "sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU=", - "requires": { - "kind-of": "^3.0.2" - } - } - } - }, - "transformify": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/transformify/-/transformify-0.1.2.tgz", - "integrity": "sha1-mk9CoVRDPdcnuAV1Qoo8nlSJ6/E=", - "requires": { - "readable-stream": "~1.1.9" - }, - "dependencies": { - "isarray": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=" - }, - "readable-stream": { - "version": "1.1.14", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", - "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=", - "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.1", - "isarray": "0.0.1", - "string_decoder": "~0.10.x" - } - }, - "string_decoder": { - "version": "0.10.31", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", - "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=" - } - } - }, - "trim-newlines": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/trim-newlines/-/trim-newlines-1.0.0.tgz", - "integrity": "sha1-WIeWa7WCpFA6QetST301ARgVphM=" - }, - "trim-off-newlines": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/trim-off-newlines/-/trim-off-newlines-1.0.1.tgz", - "integrity": "sha1-n5up2e+odkw4dpi8v+sshI8RrbM=" - }, - "trim-right": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/trim-right/-/trim-right-1.0.1.tgz", - "integrity": "sha1-yy4SAwZ+DI3h9hQJS5/kVwTqYAM=" - }, - "ts-node": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-3.3.0.tgz", - "integrity": "sha1-wTxqMCTjC+EYDdUwOPwgkonUv2k=", - "requires": { - "arrify": "^1.0.0", - "chalk": "^2.0.0", - "diff": "^3.1.0", - "make-error": "^1.1.1", - "minimist": "^1.2.0", - "mkdirp": "^0.5.1", - "source-map-support": "^0.4.0", - "tsconfig": "^6.0.0", - "v8flags": "^3.0.0", - "yn": "^2.0.0" - }, - "dependencies": { - "minimist": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", - "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" - } - } - }, - "tsc-watch": { - "version": "1.0.21", - "resolved": "https://registry.npmjs.org/tsc-watch/-/tsc-watch-1.0.21.tgz", - "integrity": "sha512-KATWj+KYbT+hPxnC4tyqHuzEDgUeDdM5EuePo/lHoDuWzkTl8sr/2pNG4szCocl3mqoujskVf1PhQThvsYQ6vA==", - "requires": { - "chalk": "^2.3.0", - "cross-spawn": "^5.1.0", - "ps-tree": "^1.1.0", - "strip-ansi": "^4.0.0", - "typescript": "*" - } - }, - "tsconfig": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/tsconfig/-/tsconfig-6.0.0.tgz", - "integrity": "sha1-aw6DdgA9evGGT434+J3QBZ/80DI=", - "requires": { - "strip-bom": "^3.0.0", - "strip-json-comments": "^2.0.0" - } - }, - "tslib": { - "version": "1.9.1", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.9.1.tgz", - "integrity": "sha512-avfPS28HmGLLc2o4elcc2EIq2FcH++Yo5YxpBZi9Yw93BCTGFthI4HPE4Rpep6vSYQaK8e69PelM44tPj+RaQg==" - }, - "tty-browserify": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/tty-browserify/-/tty-browserify-0.0.1.tgz", - "integrity": "sha512-C3TaO7K81YvjCgQH9Q1S3R3P3BtN3RIM8n+OvX4il1K1zgE8ZhI0op7kClgkxtutIE8hQrcrHBXvIheqKUUCxw==" - }, - "type-check": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz", - "integrity": "sha1-WITKtRLPHTVeP7eE8wgEsrUg23I=", - "requires": { - "prelude-ls": "~1.1.2" - } - }, - "type-detect": { - "version": "4.0.8", - "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", - "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==" - }, - "type-fest": { - "version": "0.5.2", - "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.5.2.tgz", - "integrity": "sha512-DWkS49EQKVX//Tbupb9TFa19c7+MK1XmzkrZUR8TAktmE/DizXoaoJV6TZ/tSIPXipqNiRI6CyAe7x69Jb6RSw==" - }, - "type-is": { - "version": "1.6.16", - "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.16.tgz", - "integrity": "sha512-HRkVv/5qY2G6I8iab9cI7v1bOIdhm94dVjQCPFElW9W+3GeDOSHmy2EBYe4VTApuzolPcmgFTN3ftVJRKR2J9Q==", - "requires": { - "media-typer": "0.3.0", - "mime-types": "~2.1.18" - } - }, - "typedarray": { - "version": "0.0.6", - "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", - "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=" - }, - "typedarray-to-buffer": { - "version": "3.1.5", - "resolved": "https://registry.npmjs.org/typedarray-to-buffer/-/typedarray-to-buffer-3.1.5.tgz", - "integrity": "sha512-zdu8XMNEDepKKR+XYOXAVPtWui0ly0NtohUscw+UmaHiAWT8hrV1rr//H6V+0DvJ3OQ19S979M0laLfX8rm82Q==", - "requires": { - "is-typedarray": "^1.0.0" - } - }, - "typescript": { - "version": "3.5.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.5.2.tgz", - "integrity": "sha512-7KxJovlYhTX5RaRbUdkAXN1KUZ8PwWlTzQdHV6xNqvuFOs7+WBo10TQUqT19Q/Jz2hk5v9TQDIhyLhhJY4p5AA==" - }, - "uglify-js": { - "version": "3.13.5", - "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.13.5.tgz", - "integrity": "sha512-xtB8yEqIkn7zmOyS2zUNBsYCBRhDkvlNxMMY2smuJ/qA8NCHeQvKCF3i9Z4k8FJH4+PJvZRtMrPynfZ75+CSZw==", - "optional": true - }, - "uid2": { - "version": "0.0.3", - "resolved": "https://registry.npmjs.org/uid2/-/uid2-0.0.3.tgz", - "integrity": "sha1-SDEm4Rd03y9xuLY53NeZw3YWK4I=" - }, - "umd": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/umd/-/umd-3.0.3.tgz", - "integrity": "sha512-4IcGSufhFshvLNcMCV80UnQVlZ5pMOC8mvNPForqwA4+lzYQuetTESLDQkeLmihq8bRcnpbQa48Wb8Lh16/xow==" - }, - "unicode-canonical-property-names-ecmascript": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/unicode-canonical-property-names-ecmascript/-/unicode-canonical-property-names-ecmascript-1.0.4.tgz", - "integrity": "sha512-jDrNnXWHd4oHiTZnx/ZG7gtUTVp+gCcTTKr8L0HjlwphROEW3+Him+IpvC+xcJEFegapiMZyZe02CyuOnRmbnQ==" - }, - "unicode-match-property-ecmascript": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/unicode-match-property-ecmascript/-/unicode-match-property-ecmascript-1.0.4.tgz", - "integrity": "sha512-L4Qoh15vTfntsn4P1zqnHulG0LdXgjSO035fEpdtp6YxXhMT51Q6vgM5lYdG/5X3MjS+k/Y9Xw4SFCY9IkR0rg==", - "requires": { - "unicode-canonical-property-names-ecmascript": "^1.0.4", - "unicode-property-aliases-ecmascript": "^1.0.4" - } - }, - "unicode-match-property-value-ecmascript": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/unicode-match-property-value-ecmascript/-/unicode-match-property-value-ecmascript-1.1.0.tgz", - "integrity": "sha512-hDTHvaBk3RmFzvSl0UVrUmC3PuW9wKVnpoUDYH0JDkSIovzw+J5viQmeYHxVSBptubnr7PbH2e0fnpDRQnQl5g==" - }, - "unicode-property-aliases-ecmascript": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/unicode-property-aliases-ecmascript/-/unicode-property-aliases-ecmascript-1.0.5.tgz", - "integrity": "sha512-L5RAqCfXqAwR3RriF8pM0lU0w4Ryf/GgzONwi6KnL1taJQa7x1TCxdJnILX59WIGOwR57IVxn7Nej0fz1Ny6fw==" - }, - "union-value": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/union-value/-/union-value-1.0.0.tgz", - "integrity": "sha1-XHHDTLW61dzr4+oM0IIHulqhrqQ=", - "requires": { - "arr-union": "^3.1.0", - "get-value": "^2.0.6", - "is-extendable": "^0.1.1", - "set-value": "^0.4.3" - }, - "dependencies": { - "extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "requires": { - "is-extendable": "^0.1.0" - } - }, - "set-value": { - "version": "0.4.3", - "resolved": "https://registry.npmjs.org/set-value/-/set-value-0.4.3.tgz", - "integrity": "sha1-fbCPnT0i3H945Trzw79GZuzfzPE=", - "requires": { - "extend-shallow": "^2.0.1", - "is-extendable": "^0.1.1", - "is-plain-object": "^2.0.1", - "to-object-path": "^0.3.0" - } - } - } - }, - "unique-string": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/unique-string/-/unique-string-1.0.0.tgz", - "integrity": "sha1-nhBXzKhRq7kzmPizOuGHuZyuwRo=", - "requires": { - "crypto-random-string": "^1.0.0" - } - }, - "unique-temp-dir": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/unique-temp-dir/-/unique-temp-dir-1.0.0.tgz", - "integrity": "sha1-bc6VsmgcoAPuv7MEpBX5y6vMU4U=", - "requires": { - "mkdirp": "^0.5.1", - "os-tmpdir": "^1.0.1", - "uid2": "0.0.3" - } - }, - "universalify": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", - "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==" - }, - "unpipe": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", - "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=" - }, - "unset-value": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/unset-value/-/unset-value-1.0.0.tgz", - "integrity": "sha1-g3aHP30jNRef+x5vw6jtDfyKtVk=", - "requires": { - "has-value": "^0.3.1", - "isobject": "^3.0.0" - }, - "dependencies": { - "has-value": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/has-value/-/has-value-0.3.1.tgz", - "integrity": "sha1-ex9YutpiyoJ+wKIHgCVlSEWZXh8=", - "requires": { - "get-value": "^2.0.3", - "has-values": "^0.1.4", - "isobject": "^2.0.0" - }, - "dependencies": { - "isobject": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/isobject/-/isobject-2.1.0.tgz", - "integrity": "sha1-8GVWEJaj8dou9GJy+BXIQNh+DIk=", - "requires": { - "isarray": "1.0.0" - } - } - } - }, - "has-values": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/has-values/-/has-values-0.1.4.tgz", - "integrity": "sha1-bWHeldkd/Km5oCCJrThL/49it3E=" - }, - "isobject": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", - "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=" - } - } - }, - "unzip-response": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/unzip-response/-/unzip-response-2.0.1.tgz", - "integrity": "sha1-0vD3N9FrBhXnKmk17QQhRXLVb5c=" - }, - "update-notifier": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/update-notifier/-/update-notifier-3.0.1.tgz", - "integrity": "sha512-grrmrB6Zb8DUiyDIaeRTBCkgISYUgETNe7NglEbVsrLWXeESnlCSP50WfRSj/GmzMPl6Uchj24S/p80nP/ZQrQ==", - "requires": { - "boxen": "^3.0.0", - "chalk": "^2.0.1", - "configstore": "^4.0.0", - "has-yarn": "^2.1.0", - "import-lazy": "^2.1.0", - "is-ci": "^2.0.0", - "is-installed-globally": "^0.1.0", - "is-npm": "^3.0.0", - "is-yarn-global": "^0.3.0", - "latest-version": "^5.0.0", - "semver-diff": "^2.0.0", - "xdg-basedir": "^3.0.0" - }, - "dependencies": { - "ci-info": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-2.0.0.tgz", - "integrity": "sha512-5tK7EtrZ0N+OLFMthtqOj4fI2Jeb88C4CAZPu25LDVUgXJ0A3Js4PMGqrn0JU1W0Mh1/Z8wZzYPxqUrXeBboCQ==" - }, - "is-ci": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/is-ci/-/is-ci-2.0.0.tgz", - "integrity": "sha512-YfJT7rkpQB0updsdHLGWrvhBJfcfzNNawYDNIyQXJz0IViGf75O8EBPKSdvw2rF+LGCsX4FZ8tcr3b19LcZq4w==", - "requires": { - "ci-info": "^2.0.0" - } - } - } - }, - "uri-js": { - "version": "4.2.2", - "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.2.2.tgz", - "integrity": "sha512-KY9Frmirql91X2Qgjry0Wd4Y+YTdrdZheS8TFwvkbLWf/G5KNJDCh6pKL5OZctEW4+0Baa5idK2ZQuELRwPznQ==", - "requires": { - "punycode": "^2.1.0" - }, - "dependencies": { - "punycode": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", - "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==" - } - } - }, - "urix": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/urix/-/urix-0.1.0.tgz", - "integrity": "sha1-2pN/emLiH+wf0Y1Js1wpNQZ6bHI=" - }, - "url": { - "version": "0.11.0", - "resolved": "https://registry.npmjs.org/url/-/url-0.11.0.tgz", - "integrity": "sha1-ODjpfPxgUh63PFJajlW/3Z4uKPE=", - "requires": { - "punycode": "1.3.2", - "querystring": "0.2.0" - }, - "dependencies": { - "punycode": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.3.2.tgz", - "integrity": "sha1-llOgNvt8HuQjQvIyXM7v6jkmxI0=" - } - } - }, - "url-parse-lax": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/url-parse-lax/-/url-parse-lax-1.0.0.tgz", - "integrity": "sha1-evjzA2Rem9eaJy56FKxovAYJ2nM=", - "requires": { - "prepend-http": "^1.0.1" - } - }, - "use": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/use/-/use-3.1.1.tgz", - "integrity": "sha512-cwESVXlO3url9YWlFW/TA9cshCEhtu7IKJ/p5soJ/gGpj7vbvFrAY/eIioQ6Dw23KjZhYgiIo8HOs1nQ2vr/oQ==" - }, - "util": { - "version": "0.10.3", - "resolved": "https://registry.npmjs.org/util/-/util-0.10.3.tgz", - "integrity": "sha1-evsa/lCAUkZInj23/g7TeTNqwPk=", - "requires": { - "inherits": "2.0.1" - }, - "dependencies": { - "inherits": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz", - "integrity": "sha1-sX0I0ya0Qj5Wjv9xn5GwscvfafE=" - } - } - }, - "util-deprecate": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", - "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=" - }, - "utils-merge": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", - "integrity": "sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM=" - }, - "uuid": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-2.0.3.tgz", - "integrity": "sha1-Z+LoY3lyFVMN/zGOW/nc6/1Hsho=" - }, - "v8-compile-cache": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.1.0.tgz", - "integrity": "sha512-usZBT3PW+LOjM25wbqIlZwPeJV+3OSz3M1k1Ws8snlW39dZyYL9lOGC5FgPVHfk0jKmjiDV8Z0mIbVQPiwFs7g==" - }, - "v8flags": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/v8flags/-/v8flags-3.1.0.tgz", - "integrity": "sha512-0m69VIK2dudEf2Ub0xwLQhZkDZu85OmiOpTw+UGDt56ibviYICHziM/3aE+oVg7IjGPp0c83w3eSVqa+lYZ9UQ==", - "requires": { - "homedir-polyfill": "^1.0.1" - } - }, - "validate-npm-package-license": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.3.tgz", - "integrity": "sha512-63ZOUnL4SIXj4L0NixR3L1lcjO38crAbgrTpl28t8jjrfuiOBL5Iygm+60qPs/KsZGzPNg6Smnc/oY16QTjF0g==", - "requires": { - "spdx-correct": "^3.0.0", - "spdx-expression-parse": "^3.0.0" - } - }, - "vary": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", - "integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw=" - }, - "vlq": { - "version": "0.2.3", - "resolved": "https://registry.npmjs.org/vlq/-/vlq-0.2.3.tgz", - "integrity": "sha1-jz5DKM9jsVQMDWfhsneDhviXWyY=" - }, - "vm-browserify": { - "version": "0.0.4", - "resolved": "https://registry.npmjs.org/vm-browserify/-/vm-browserify-0.0.4.tgz", - "integrity": "sha1-XX6kW7755Kb/ZflUOOCofDV9WnM=", - "requires": { - "indexof": "0.0.1" - } - }, - "wcwidth": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/wcwidth/-/wcwidth-1.0.1.tgz", - "integrity": "sha1-8LDc+RW8X/FSivrbLA4XtTLaL+g=", - "requires": { - "defaults": "^1.0.3" - } - }, - "well-known-symbols": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/well-known-symbols/-/well-known-symbols-2.0.0.tgz", - "integrity": "sha512-ZMjC3ho+KXo0BfJb7JgtQ5IBuvnShdlACNkKkdsqBmYw3bPAaJfPeYUo6tLUaT5tG/Gkh7xkpBhKRQ9e7pyg9Q==" - }, - "which": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/which/-/which-1.3.0.tgz", - "integrity": "sha1-/wS9/AEO5UfXgL7DjhrBwnd9JTo=", - "requires": { - "isexe": "^2.0.0" - } - }, - "which-module": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.0.tgz", - "integrity": "sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho=" - }, - "wide-align": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.3.tgz", - "integrity": "sha512-QGkOQc8XL6Bt5PwnsExKBPuMKBxnGxWWW3fU55Xt4feHozMUhdUMaBCk290qpm/wG5u/RSKzwdAC4i51YigihA==", - "requires": { - "string-width": "^1.0.2 || 2" - } - }, - "widest-line": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/widest-line/-/widest-line-2.0.1.tgz", - "integrity": "sha512-Ba5m9/Fa4Xt9eb2ELXt77JxVDV8w7qQrH0zS/TWSJdLyAwQjWoOzpzj5lwVftDz6n/EOu3tNACS84v509qwnJA==", - "requires": { - "string-width": "^2.1.1" - } - }, - "wordwrap": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz", - "integrity": "sha1-J1hIEIkUVqQXHI0CJkQa3pDLyus=" - }, - "wrap-ansi": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-2.1.0.tgz", - "integrity": "sha1-2Pw9KE3QV5T+hJc8rs3Rz4JP3YU=", - "requires": { - "string-width": "^1.0.1", - "strip-ansi": "^3.0.1" - }, - "dependencies": { - "is-fullwidth-code-point": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", - "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", - "requires": { - "number-is-nan": "^1.0.0" - } - }, - "string-width": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", - "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", - "requires": { - "code-point-at": "^1.0.0", - "is-fullwidth-code-point": "^1.0.0", - "strip-ansi": "^3.0.0" - } - }, - "strip-ansi": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", - "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", - "requires": { - "ansi-regex": "^2.0.0" - } - } - } - }, - "wrappy": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" - }, - "write": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/write/-/write-1.0.3.tgz", - "integrity": "sha512-/lg70HAjtkUgWPVZhZcm+T4hkL8Zbtp1nFNOn3lRrxnlv50SRBv7cR7RqR+GMsd3hUXy9hWBo4CHTbFTcOYwig==", - "requires": { - "mkdirp": "^0.5.1" - } - }, - "write-file-atomic": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-2.3.0.tgz", - "integrity": "sha1-H/YVdcLipOjlENb6TiQ8zhg5mas=", - "requires": { - "graceful-fs": "^4.1.11", - "imurmurhash": "^0.1.4", - "signal-exit": "^3.0.2" - } - }, - "write-json-file": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/write-json-file/-/write-json-file-2.3.0.tgz", - "integrity": "sha1-K2TIozAE1UuGmMdtWFp3zrYdoy8=", - "requires": { - "detect-indent": "^5.0.0", - "graceful-fs": "^4.1.2", - "make-dir": "^1.0.0", - "pify": "^3.0.0", - "sort-keys": "^2.0.0", - "write-file-atomic": "^2.0.0" - }, - "dependencies": { - "detect-indent": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/detect-indent/-/detect-indent-5.0.0.tgz", - "integrity": "sha1-OHHMCmoALow+Wzz38zYmRnXwa50=" - }, - "pify": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/pify/-/pify-3.0.0.tgz", - "integrity": "sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY=" - } - } - }, - "write-pkg": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/write-pkg/-/write-pkg-3.1.0.tgz", - "integrity": "sha1-AwqZlMyZk9JbTnWp8aGSNgcpHOk=", - "requires": { - "sort-keys": "^2.0.0", - "write-json-file": "^2.2.0" - } - }, - "xdg-basedir": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/xdg-basedir/-/xdg-basedir-3.0.0.tgz", - "integrity": "sha1-SWsswQnsqNus/i3HK2A8F8WHCtQ=" - }, - "xregexp": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/xregexp/-/xregexp-4.2.0.tgz", - "integrity": "sha512-IyMa7SVe9FyT4WbQVW3b95mTLVceHhLEezQ02+QMvmIqDnKTxk0MLWIQPSW2MXAr1zQb+9yvwYhcyQULneh3wA==" - }, - "xtend": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz", - "integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68=" - }, - "y18n": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/y18n/-/y18n-3.2.2.tgz", - "integrity": "sha512-uGZHXkHnhF0XeeAPgnKfPv1bgKAYyVvmNL1xlKsPYZPaIHxGti2hHqvOCQv71XMsLxu1QjergkqogUnms5D3YQ==" - }, - "yallist": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-2.1.2.tgz", - "integrity": "sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI=" - }, - "yargs": { - "version": "8.0.2", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-8.0.2.tgz", - "integrity": "sha1-YpmpBVsc78lp/355wdkY3Osiw2A=", - "requires": { - "camelcase": "^4.1.0", - "cliui": "^3.2.0", - "decamelize": "^1.1.1", - "get-caller-file": "^1.0.1", - "os-locale": "^2.0.0", - "read-pkg-up": "^2.0.0", - "require-directory": "^2.1.1", - "require-main-filename": "^1.0.1", - "set-blocking": "^2.0.0", - "string-width": "^2.0.0", - "which-module": "^2.0.0", - "y18n": "^3.2.1", - "yargs-parser": "^7.0.0" - }, - "dependencies": { - "camelcase": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-4.1.0.tgz", - "integrity": "sha1-1UVjW+HjPFQmScaRc+Xeas+uNN0=" - }, - "cliui": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/cliui/-/cliui-3.2.0.tgz", - "integrity": "sha1-EgYBU3qRbSmUD5NNo7SNWFo5IT0=", - "requires": { - "string-width": "^1.0.1", - "strip-ansi": "^3.0.1", - "wrap-ansi": "^2.0.0" - }, - "dependencies": { - "string-width": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", - "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", - "requires": { - "code-point-at": "^1.0.0", - "is-fullwidth-code-point": "^1.0.0", - "strip-ansi": "^3.0.0" - } - } - } - }, - "is-fullwidth-code-point": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", - "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", - "requires": { - "number-is-nan": "^1.0.0" - } - }, - "strip-ansi": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", - "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", - "requires": { - "ansi-regex": "^2.0.0" - } - }, - "yargs-parser": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-7.0.0.tgz", - "integrity": "sha1-jQrELxbqVd69MyyvTEA4s+P139k=", - "requires": { - "camelcase": "^4.1.0" - } - } - } - }, - "yargs-parser": { - "version": "19.0.4", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-19.0.4.tgz", - "integrity": "sha512-eXeQm7yXRjPFFyf1voPkZgXQZJjYfjgQUmGPbD2TLtZeIYzvacgWX7sQ5a1HsRgVP+pfKAkRZDNtTGev4h9vhw==" - }, - "yn": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/yn/-/yn-2.0.0.tgz", - "integrity": "sha1-5a2ryKz0CPY4X8dklWhMiOavaJo=" - } - } -} diff --git a/JavaScript/package.json b/JavaScript/package.json deleted file mode 100644 index bb7c1de317..0000000000 --- a/JavaScript/package.json +++ /dev/null @@ -1,116 +0,0 @@ -{ - "name": "recognizers", - "version": "1.3.0", - "license": "MIT", - "repository": { - "type": "git", - "url": "https://github.com/Microsoft/Recognizers-Text" - }, - "bugs": { - "url": "https://github.com/Microsoft/Recognizers-Text/issues" - }, - "scripts": { - "build": "lerna clean --yes && lerna bootstrap --hoist", - "lint": "eslint **/*.ts --ignore-pattern node_modules/", - "lint-fix": "eslint **/*.ts --ignore-pattern node_modules/ --fix", - "test": "ava", - "browserify": "browserify -d -o ./test/browser-specs/index.js package.json ./test/runner-browser.js", - "browser-test": "npm run browserify && node ./test/browser-specs/server.js" - }, - "browserify-shim": { - "@microsoft/recognizers-text": "global:microsoftRecognizersTextBase", - "@microsoft/recognizers-text-choice": "global:microsoftRecognizersTextChoice", - "@microsoft/recognizers-text-number": "global:microsoftRecognizersTextNumber", - "@microsoft/recognizers-text-number-with-unit": "global:microsoftRecognizersTextNumberWithUnit", - "@microsoft/recognizers-text-sequence": "global:microsoftRecognizersSequence", - "@microsoft/recognizers-text-date-time": "global:microsoftRecognizersTextDateTime" - }, - "browserify": { - "transform": [ - "browserify-shim", - "babelify" - ] - }, - "ava": { - "files": [ - "./test/index-number.js", - "./test/index-number-with-unit.js", - "./test/index-datetime.js", - "./test/index-choice.js", - "./test/index-sequence.js" - ] - }, - "devDependencies": { - "@types/js-yaml": "^3.9.0", - "@types/lodash.escaperegexp": "^4.1.3", - "@types/lodash.isequal": "^4.5.2", - "@types/lodash.last": "^3.0.3", - "@types/lodash.max": "^4.0.3", - "@types/lodash.sortby": "^4.7.3", - "@types/lodash.tonumber": "^4.0.3", - "@types/lodash.trimend": "^4.5.1", - "@types/node": "^10.3.0", - "@types/npm": "^2.0.29", - "@typescript-eslint/eslint-plugin": "^1.10.2", - "@typescript-eslint/parser": "^1.10.2", - "acorn": ">=5.7.4", - "ava": "^2.2.0", - "ava-spec": "^1.1.0", - "babel-eslint": "^10.0.2", - "babel-plugin-external-helpers": "^6.22.0", - "babel-preset-es2015": "^6.24.1", - "babel-preset-stage-0": "^6.24.1", - "babelify": "^7.3.0", - "bignumber.js": "^7.2.1", - "braces": "^2.3.1", - "browserify": "^14.4.0", - "browserify-shim": "^3.8.14", - "cached-path-relative": ">=1.0.2", - "colors": "^1.1.2", - "dot-prop": ">=5.1.1", - "eslint": "^6.2.2", - "eslint-config-prettier": "^6.1.0", - "eslint-plugin-only-warn": "^1.0.1", - "eslint-utils": "^1.4.2", - "express": "^4.16.1", - "handlebars": "^4.3.0", - "js-yaml": "^3.13.1", - "lerna": "^2.11.0", - "lodash": "^4.17.14", - "lodash.camelcase": "^4.3.0", - "lodash.keys": "^4.2.0", - "lodash.merge": ">=4.6.2", - "lodash.template": ">=4.5.0", - "mem": ">=4.0.0", - "minimist": ">=1.2.2", - "mixin-deep": ">=1.3.2", - "path-parse": ">=1.0.7", - "prettier": "^1.6.1", - "rimraf": "^2.6.1", - "rollup": "^0.50.0", - "rollup-plugin-alias": "^1.4.0", - "rollup-plugin-babel": "^3.0.2", - "rollup-plugin-commonjs": "^8.2.0", - "rollup-plugin-node-resolve": "^3.0.0", - "rollup-plugin-sourcemaps": "^0.4.2", - "set-value": ">=4.0.1", - "ts-node": "^3.3.0", - "tsc-watch": "^1.0.8", - "typescript": "^3.2.1", - "xregexp": "^4.2.0", - "yargs-parser": ">=13.1.2" - }, - "dependencies": { - "@microsoft/recognizers-text": "file:./packages/recognizers-text", - "@microsoft/recognizers-text-choice": "file:./packages/recognizers-choice", - "@microsoft/recognizers-text-data-types-timex-expression": "file:./packages/datatypes-date-time", - "@microsoft/recognizers-text-date-time": "file:./packages/recognizers-date-time", - "@microsoft/recognizers-text-number": "file:./packages/recognizers-number", - "@microsoft/recognizers-text-number-with-unit": "file:./packages/recognizers-number-with-unit", - "@microsoft/recognizers-text-sequence": "file:./packages/recognizers-sequence", - "@microsoft/recognizers-text-suite": "file:./packages/recognizers-text-suite" - }, - "engines": { - "node": ">=10.3.0" - } -} diff --git a/JavaScript/packages/datatypes-date-time/.npmignore b/JavaScript/packages/datatypes-date-time/.npmignore deleted file mode 100644 index 757fb9517d..0000000000 --- a/JavaScript/packages/datatypes-date-time/.npmignore +++ /dev/null @@ -1,4 +0,0 @@ -* -!dist/*.js -!dist/types/**/* -!README.md \ No newline at end of file diff --git a/JavaScript/packages/datatypes-date-time/index.js b/JavaScript/packages/datatypes-date-time/index.js deleted file mode 100644 index 315aa0ab7b..0000000000 --- a/JavaScript/packages/datatypes-date-time/index.js +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -module.exports = { - Time: require('./src/time.js').Time, - TimexProperty: require('./src/timexProperty.js').TimexProperty, - TimexSet: require('./src/timexSet.js').TimexSet, - creator: require('./src/timexCreator.js'), - resolver: require('./src/timexRangeResolver.js'), - valueResolver: require('./src/timexResolver.js') -}; - diff --git a/JavaScript/packages/datatypes-date-time/package-lock.json b/JavaScript/packages/datatypes-date-time/package-lock.json deleted file mode 100644 index 6ceea73ab2..0000000000 --- a/JavaScript/packages/datatypes-date-time/package-lock.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "requires": true, - "lockfileVersion": 1, - "dependencies": { - "assertion-error": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", - "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==" - }, - "chai": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chai/-/chai-4.1.2.tgz", - "integrity": "sha1-D2RYS6ZC8PKs4oBiefTwbKI61zw=", - "requires": { - "assertion-error": "^1.0.1", - "check-error": "^1.0.1", - "deep-eql": "^3.0.0", - "get-func-name": "^2.0.0", - "pathval": "^1.1.1", - "type-detect": "^4.0.0" - } - }, - "chai-as-promised": { - "version": "7.1.1", - "resolved": "https://registry.npmjs.org/chai-as-promised/-/chai-as-promised-7.1.1.tgz", - "integrity": "sha512-azL6xMoi+uxu6z4rhWQ1jbdUhOMhis2PvscD/xjLqNMkv3BPPp2JyyuTHOrf9BOosGpNQ11v6BKv/g57RXbiaA==", - "requires": { - "check-error": "^1.0.2" - } - }, - "check-error": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.2.tgz", - "integrity": "sha1-V00xLt2Iu13YkS6Sht1sCu1KrII=" - }, - "deep-eql": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-3.0.1.tgz", - "integrity": "sha512-+QeIQyN5ZuO+3Uk5DYh6/1eKO0m0YmJFGNmFHGACpf1ClL1nmlV/p4gNgbl2pJGxgXb4faqo6UE+M5ACEMyVcw==", - "requires": { - "type-detect": "^4.0.0" - } - }, - "get-func-name": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.0.tgz", - "integrity": "sha1-6td0q+5y4gQJQzoGY2YCPdaIekE=" - }, - "pathval": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.1.tgz", - "integrity": "sha512-Dp6zGqpTdETdR63lehJYPeIOqpiNBNtc7BpWSLrOje7UaIsE5aY92r/AunQA7rsXvet3lrJ3JnZX29UPTKXyKQ==" - }, - "type-detect": { - "version": "4.0.8", - "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", - "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==" - } - }, - "version": "1.3.0" -} diff --git a/JavaScript/packages/datatypes-date-time/package.json b/JavaScript/packages/datatypes-date-time/package.json deleted file mode 100644 index 646735460f..0000000000 --- a/JavaScript/packages/datatypes-date-time/package.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "name": "@microsoft/recognizers-text-data-types-timex-expression", - "version": "1.3.0", - "description": "Support for TIMEX-based representation of datetime entities", - "author": "Microsoft", - "license": "MIT", - "keywords": [ - "bot", - "timex", - "luis" - ], - "main": "dist/recognizers-text-data-types-timex-expression.umd.js", - "module": "dist/recognizers-text-data-types-timex-expression.es5.js", - "browser": "dist/recognizers-text-data-types-timex-expression.browser.js", - "repository": { - "type": "git", - "url": "https://github.com/Microsoft/Recognizers-Text" - }, - "bugs": { - "url": "https://github.com/Microsoft/Recognizers-Text/issues" - }, - "engines": { - "node": ">=10.3.0" - }, - "scripts": { - "test": "mocha", - "clean-build": "rimraf dist", - "prepare": "npm run clean-build && rollup -c" - }, - "devDependencies": { - "chai": "^4.1.2", - "chai-as-promised": "^7.1.1" - } -} diff --git a/JavaScript/packages/datatypes-date-time/rollup.config.js b/JavaScript/packages/datatypes-date-time/rollup.config.js deleted file mode 100644 index 11afa8ffe2..0000000000 --- a/JavaScript/packages/datatypes-date-time/rollup.config.js +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import resolve from 'rollup-plugin-node-resolve'; -import commonjs from 'rollup-plugin-commonjs'; -import sourceMaps from 'rollup-plugin-sourcemaps'; -import pkg from './package.json'; -import camelCase from 'lodash.camelcase'; - -export default { - input: `index.js`, - output: [ - { file: pkg.module, format: 'es' }, - { file: pkg.main, name: camelCase(pkg.name), format: 'umd', exports: 'named' }, - { file: pkg.browser, format: 'iife', name: camelCase(pkg.name), exports: 'named' } - ], - exports: 'named', - sourcemap: true, - plugins: [ - // Allow bundling cjs modules (unlike webpack, rollup doesn't understand cjs) - commonjs(), - // Allow node_modules resolution, so you can use 'external' to control - // which external modules to include in the bundle - // https://github.com/rollup/rollup-plugin-node-resolve#usage - resolve(), - // Resolve source maps to the original source - sourceMaps() - ] -}; diff --git a/JavaScript/packages/datatypes-date-time/src/en/timexConstants.js b/JavaScript/packages/datatypes-date-time/src/en/timexConstants.js deleted file mode 100644 index ee00be7260..0000000000 --- a/JavaScript/packages/datatypes-date-time/src/en/timexConstants.js +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -module.exports.days = [ - 'Monday', - 'Tuesday', - 'Wednesday', - 'Thursday', - 'Friday', - 'Saturday', - 'Sunday' -]; - -module.exports.months = [ - 'January', - 'Februrary', - 'March', - 'April', - 'May', - 'June', - 'July', - 'August', - 'September', - 'October', - 'November', - 'December' -]; - -module.exports.dateAbbreviation = { 0: 'th', 1: 'st', 2: 'nd', 3: 'rd', 4: 'th', 5: 'th', 6: 'th', 7: 'th', 8: 'th', 9: 'th' }; - -module.exports.hours = [ - 'midnight', '1AM', '2AM', '3AM', '4AM', '5AM', '6AM', '7AM', '8AM', '9AM', '10AM', '11AM', - 'midday', '1PM', '2PM', '3PM', '4PM', '5PM', '6PM', '7PM', '8PM', '9PM', '10PM', '11PM' -]; - -module.exports.seasons = { SP: 'spring', SU: 'summer', FA: 'fall', WI: 'winter' }; - -module.exports.weeks = [ 'first', 'second', 'third', 'forth' ]; - -module.exports.dayParts = { DT: 'daytime', NI: 'night', MO: 'morning', AF: 'afternoon', EV: 'evening' }; diff --git a/JavaScript/packages/datatypes-date-time/src/en/timexConvert.js b/JavaScript/packages/datatypes-date-time/src/en/timexConvert.js deleted file mode 100644 index d5873aeb86..0000000000 --- a/JavaScript/packages/datatypes-date-time/src/en/timexConvert.js +++ /dev/null @@ -1,153 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -const timexConstants = require('./timexConstants.js'); -const timexInference = require('../timexInference.js'); - -const convertDate = function(timex) { - if ('dayOfWeek' in timex) { - return timexConstants.days[timex.dayOfWeek - 1]; - } - const month = timexConstants.months[timex.month - 1]; - const date = timex.dayOfMonth.toString(); - const abbreviation = timexConstants.dateAbbreviation[date.slice(-1)]; - if ('year' in timex) { - return `${date}${abbreviation} ${month} ${timex.year}`.trim(); - } - return `${date}${abbreviation} ${month}`; -}; - -const convertTime = function(timex) { - if (timex.hour === 0 && timex.minute === 0 && timex.second === 0) { - return 'midnight'; - } - if (timex.hour === 12 && timex.minute === 0 && timex.second === 0) { - return 'midday'; - } - const pad = function (s) { return (s.length === 1) ? '0' + s : s; }; - const hour = (timex.hour === 0) ? '12' : (timex.hour > 12) ? (timex.hour - 12).toString() : timex.hour.toString(); - const minute = (timex.minute === 0 && timex.second === 0) ? '' : ':' + pad(timex.minute.toString()); - const second = (timex.second === 0) ? '' : ':' + pad(timex.second.toString()); - const period = timex.hour < 12 ? 'AM' : 'PM'; - return `${hour}${minute}${second}${period}`; -}; - -const convertDurationPropertyToString = function (timex, property, includeSingleCount) { - const propertyName = property + 's'; - const value = timex[propertyName]; - if (value !== undefined) { - if (value === 1) { - return includeSingleCount ? '1 ' + property : property; - } - else { - return `${value} ${property}s`; - } - } - return false; -}; - -const convertTimexDurationToString = function (timex, includeSingleCount) { - return convertDurationPropertyToString(timex, 'year', includeSingleCount) - || convertDurationPropertyToString(timex, 'month', includeSingleCount) - || convertDurationPropertyToString(timex, 'week', includeSingleCount) - || convertDurationPropertyToString(timex, 'day', includeSingleCount) - || convertDurationPropertyToString(timex, 'hour', includeSingleCount) - || convertDurationPropertyToString(timex, 'minute', includeSingleCount) - || convertDurationPropertyToString(timex, 'second', includeSingleCount); -}; - -const convertDuration = function(timex) { - return convertTimexDurationToString(timex, true); -}; - -const convertDateRange = function(timex) { - const season = ('season' in timex) ? timexConstants.seasons[timex.season] : ''; - const year = ('year' in timex) ? timex.year.toString() : ''; - if ('weekOfYear' in timex) { - if (timex.weekend) { - return ''; - } - else { - return ''; - } - } - if ('month' in timex) { - const month = `${timexConstants.months[timex.month - 1]}`; - if ('weekOfMonth' in timex) { - return `${timexConstants.weeks[timex.weekOfMonth - 1]} week of ${month}`; - } - else { - return `${month} ${year}`.trim(); - } - } - return `${season} ${year}`.trim(); -}; - -const convertTimeRange = function(timex) { - return timexConstants.dayParts[timex.partOfDay]; -}; - -const convertDateTime = function(timex) { - return `${convertTime(timex)} ${convertDate(timex)}`; -}; - -const convertDateTimeRange = function(timex) { - if (timex.types.has('timerange')) { - return `${convertDate(timex)} ${convertTimeRange(timex)}`; - } - // date + time + duration - // - OR - - // date + duration - return ''; -}; - -const convertTimexToString = function (timex) { - - const types = ('types' in timex) ? timex.types : timexInference.infer(timex); - - if (types.has('present')) { - return 'now'; - } - if (types.has('datetimerange')) { - return convertDateTimeRange(timex); - } - if (types.has('daterange')) { - return convertDateRange(timex); - } - if (types.has('duration')) { - return convertDuration(timex); - } - if (types.has('timerange')) { - return convertTimeRange(timex); - } - - // TODO: where appropriate delegate most the formatting delegate to Date.toLocaleString(options) - if (types.has('datetime')) { - return convertDateTime(timex); - } - if (types.has('date')) { - return convertDate(timex); - } - if (types.has('time')) { - return convertTime(timex); - } - return ''; -}; - -const convertTimexSetToString = function(timexSet) { - - const timex = timexSet.timex; - if (timex.types.has('duration')) { - return `every ${convertTimexDurationToString(timex, false)}`; - } - else { - return `every ${convertTimexToString(timex)}`; - } -}; - -module.exports = { - convertDate: convertDate, - convertTime: convertTime, - convertTimexToString: convertTimexToString, - convertTimexSetToString: convertTimexSetToString -}; diff --git a/JavaScript/packages/datatypes-date-time/src/en/timexRelativeConvert.js b/JavaScript/packages/datatypes-date-time/src/en/timexRelativeConvert.js deleted file mode 100644 index 6cc12214cc..0000000000 --- a/JavaScript/packages/datatypes-date-time/src/en/timexRelativeConvert.js +++ /dev/null @@ -1,140 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -const timexDateHelpers = require('../timexDateHelpers.js'); -const timexInference = require('../timexInference.js'); -const timexConstants = require('./timexConstants.js'); -const timexConvert = require('./timexConvert.js'); - -const getDateDay = function (day) { - const index = (day === 0) ? 6 : day - 1; - return timexConstants.days[index]; -}; - -const convertDate = function(timex, date) { - if ('year' in timex && 'month' in timex && 'dayOfMonth' in timex) { - const timexDate = new Date(timex.year, timex.month - 1, timex.dayOfMonth); - - if (timexDateHelpers.datePartEquals(timexDate, date)) { - return 'today'; - } - const tomorrow = timexDateHelpers.tomorrow(date); - if (timexDateHelpers.datePartEquals(timexDate, tomorrow)) { - return 'tomorrow'; - } - const yesterday = timexDateHelpers.yesterday(date); - if (timexDateHelpers.datePartEquals(timexDate, yesterday)) { - return 'yesterday'; - } - if (timexDateHelpers.isThisWeek(timexDate, date)) { - return `this ${getDateDay(timexDate.getDay())}`; - } - if (timexDateHelpers.isNextWeek(timexDate, date)) { - return `next ${getDateDay(timexDate.getDay())}`; - } - if (timexDateHelpers.isLastWeek(timexDate, date)) { - return `last ${getDateDay(timexDate.getDay())}`; - } - } - return timexConvert.convertDate(timex); -}; - -const convertDateTime = function (timex, date) { - return `${convertDate(timex, date)} ${timexConvert.convertTime(timex)}`; -}; - -const convertDateRange = function(timex, date) { - if ('year' in timex) { - const year = date.getFullYear(); - if (timex.year === year) { - if ('weekOfYear' in timex) { - const thisWeek = timexDateHelpers.weekOfYear(date); - if (thisWeek === timex.weekOfYear) { - return timex.weekend ? 'this weekend' : 'this week'; - } - if (thisWeek === timex.weekOfYear + 1) { - return timex.weekend ? 'last weekend' : 'last week'; - } - if (thisWeek === timex.weekOfYear - 1) { - return timex.weekend ? 'next weekend' : 'next week'; - } - } - if ('month' in timex) { - const isoMonth = date.getMonth() + 1; - if (timex.month === isoMonth) { - return 'this month'; - } - if (timex.month === isoMonth + 1) { - return 'next month'; - } - if (timex.month === isoMonth - 1) { - return 'last month'; - } - } - return ('season' in timex) ? `this ${timexConstants.seasons[timex.season]}` : 'this year'; - } - if (timex.year === year + 1) { - return ('season' in timex) ? `next ${timexConstants.seasons[timex.season]}` : 'next year'; - } - if (timex.year === year - 1) { - return ('season' in timex) ? `last ${timexConstants.seasons[timex.season]}` : 'last year'; - } - } - return ''; -}; - -const convertDateTimeRange = function(timex, date) { - if ('year' in timex && 'month' in timex && 'dayOfMonth' in timex) { - const timexDate = new Date(timex.year, timex.month - 1, timex.dayOfMonth); - - if ('partOfDay' in timex) { - if (timexDateHelpers.datePartEquals(timexDate, date)) { - if (timex.partOfDay === 'NI') { - return 'tonight'; - } - else { - return `this ${timexConstants.dayParts[timex.partOfDay]}`; - } - } - const tomorrow = timexDateHelpers.tomorrow(date); - if (timexDateHelpers.datePartEquals(timexDate, tomorrow)) { - return `tomorrow ${timexConstants.dayParts[timex.partOfDay]}`; - } - const yesterday = timexDateHelpers.yesterday(date); - if (timexDateHelpers.datePartEquals(timexDate, yesterday)) { - return `yesterday ${timexConstants.dayParts[timex.partOfDay]}`; - } - - if (timexDateHelpers.isNextWeek(timexDate, date)) { - return `next ${getDateDay(timexDate.getDay())} ${timexConstants.dayParts[timex.partOfDay]}`; - } - - if (timexDateHelpers.isLastWeek(timexDate, date)) { - return `last ${getDateDay(timexDate.getDay())} ${timexConstants.dayParts[timex.partOfDay]}`; - } - } - } - return ''; -}; - -const convertTimexToStringRelative = function (timex, date) { - - const types = ('types' in timex) ? timex.types : timexInference.infer(timex); - - if (types.has('datetimerange')) { - return convertDateTimeRange(timex, date); - } - if (types.has('daterange')) { - return convertDateRange(timex, date); - } - if (types.has('datetime')) { - return convertDateTime(timex, date); - } - if (types.has('date')) { - return convertDate(timex, date); - } - - return timexConvert.convertTimexToString(timex); -}; - -module.exports.convertTimexToStringRelative = convertTimexToStringRelative; diff --git a/JavaScript/packages/datatypes-date-time/src/time.js b/JavaScript/packages/datatypes-date-time/src/time.js deleted file mode 100644 index 007151f1bf..0000000000 --- a/JavaScript/packages/datatypes-date-time/src/time.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -class Time { - constructor(hour, minute, second) { - if (arguments.length === 1) { - this.hour = Math.floor(hour / 3600000); - this.minute = Math.floor((hour - (this.hour * 3600000)) / 60000); - this.second = (hour - (this.hour * 3600000) - (this.minute * 60000)) / 1000; - } - else { - this.hour = hour; - this.minute = minute; - this.second = second; - } - } - - getTime () { - return (this.second * 1000) + (this.minute * 60000) + (this.hour * 3600000); - } -} - -module.exports.Time = Time; \ No newline at end of file diff --git a/JavaScript/packages/datatypes-date-time/src/timexConstraintsHelper.js b/JavaScript/packages/datatypes-date-time/src/timexConstraintsHelper.js deleted file mode 100644 index f5aa956a60..0000000000 --- a/JavaScript/packages/datatypes-date-time/src/timexConstraintsHelper.js +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -const isOverlapping = function (r1, r2) { - return r1.end.getTime() > r2.start.getTime() && r1.start.getTime() <= r2.start.getTime() - || r1.start.getTime() < r2.end.getTime() && r1.start.getTime() >= r2.start.getTime(); -}; - -const collapseOverlapping = function (r1, r2, T) { - return { - start: new T(Math.max(r1.start.getTime(), r2.start.getTime())), - end: new T(Math.min(r1.end.getTime(), r2.end.getTime())) - }; -}; - -const innerCollapse = function (ranges, T) { - if (ranges.length === 1) { - return false; - } - for (let i=0; i a.start.getTime() - b.start.getTime()); - return r; -}; - -module.exports = { - collapse: collapse, - isOverlapping: isOverlapping -}; diff --git a/JavaScript/packages/datatypes-date-time/src/timexConvert.js b/JavaScript/packages/datatypes-date-time/src/timexConvert.js deleted file mode 100644 index 5dd6687aa9..0000000000 --- a/JavaScript/packages/datatypes-date-time/src/timexConvert.js +++ /dev/null @@ -1,9 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -const en = require('./en/timexConvert.js'); - -module.exports = { - convertTimexToString: en.convertTimexToString, - convertTimexSetToString: en.convertTimexSetToString -}; diff --git a/JavaScript/packages/datatypes-date-time/src/timexCreator.js b/JavaScript/packages/datatypes-date-time/src/timexCreator.js deleted file mode 100644 index 9897fbc017..0000000000 --- a/JavaScript/packages/datatypes-date-time/src/timexCreator.js +++ /dev/null @@ -1,94 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -const timexHelpers = require('./timexHelpers.js'); -const timexDateHelpers = require('./timexDateHelpers.js'); -const TimexProperty = require('./timexProperty.js').TimexProperty; - -const today = function (date) { - return TimexProperty.fromDate(date || new Date()).timex; -}; - -const tomorrow = function (date) { - const d = (date === undefined) ? new Date() : new Date(date.getTime()); - d.setDate(d.getDate() + 1); - return TimexProperty.fromDate(d).timex; -}; - -const yesterday = function (date) { - const d = (date === undefined) ? new Date() : new Date(date.getTime()); - d.setDate(d.getDate() - 1); - return TimexProperty.fromDate(d).timex; -}; - -const weekFromToday = function (date) { - const d = (date === undefined) ? new Date() : new Date(date.getTime()); - return (new TimexProperty(Object.assign(TimexProperty.fromDate(d), { days: 7 }))).timex; -}; - -const weekBackFromToday = function (date) { - const d = (date === undefined) ? new Date() : new Date(date.getTime()); - d.setDate(d.getDate() - 7); - return (new TimexProperty(Object.assign(TimexProperty.fromDate(d), { days: 7 }))).timex; -}; - -const thisWeek = function (date) { - const d = (date === undefined) ? new Date() : new Date(date.getTime()); - d.setDate(d.getDate() - 7); - const start = timexDateHelpers.dateOfNextDay(1, d); - return (new TimexProperty(Object.assign(TimexProperty.fromDate(start), { days: 7 }))).timex; -}; - -const nextWeek = function (date) { - const d = (date === undefined) ? new Date() : new Date(date.getTime()); - const start = timexDateHelpers.dateOfNextDay(1, d); - return (new TimexProperty(Object.assign(TimexProperty.fromDate(start), { days: 7 }))).timex; -}; - -const lastWeek = function (date) { - const d = (date === undefined) ? new Date() : new Date(date.getTime()); - const start = timexDateHelpers.dateOfLastDay(1, d); - start.setDate(start.getDate() - 7); - return (new TimexProperty(Object.assign(TimexProperty.fromDate(start), { days: 7 }))).timex; -}; - -const nextWeeksFromToday = function (n, date) { - const d = (date === undefined) ? new Date() : new Date(date.getTime()); - return (new TimexProperty(Object.assign(TimexProperty.fromDate(d), { days: 7 * n }))).timex; -}; - -// The following constants are consistent with the Recognizer results -const monday = 'XXXX-WXX-1'; -const tuesday = 'XXXX-WXX-2'; -const wednesday = 'XXXX-WXX-3'; -const thursday = 'XXXX-WXX-4'; -const friday = 'XXXX-WXX-5'; -const saturday = 'XXXX-WXX-6'; -const sunday = 'XXXX-WXX-7'; -const morning = '(T08,T12,PT4H)'; -const afternoon = '(T12,T16,PT4H)'; -const evening = '(T16,T20,PT4H)'; -const daytime = '(T08,T18,PT10H)'; - -module.exports = { - today: today, - tomorrow: tomorrow, - yesterday: yesterday, - weekFromToday: weekFromToday, - weekBackFromToday: weekBackFromToday, - thisWeek: thisWeek, - nextWeek: nextWeek, - lastWeek: lastWeek, - nextWeeksFromToday: nextWeeksFromToday, - monday: monday, - tuesday: tuesday, - wednesday: wednesday, - thursday: thursday, - friday: friday, - saturday: saturday, - sunday: sunday, - morning: morning, - afternoon: afternoon, - evening: evening, - daytime: daytime -}; diff --git a/JavaScript/packages/datatypes-date-time/src/timexDateHelpers.js b/JavaScript/packages/datatypes-date-time/src/timexDateHelpers.js deleted file mode 100644 index 384075fa0c..0000000000 --- a/JavaScript/packages/datatypes-date-time/src/timexDateHelpers.js +++ /dev/null @@ -1,124 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -const cloneDate = function (date) { - const result = new Date(); - result.setTime(date.getTime()); - return result; -}; - -const tomorrow = function (date) { - const result = cloneDate(date); - result.setDate(result.getDate() + 1); - return result; -}; - -const yesterday = function (date) { - const result = cloneDate(date); - result.setDate(result.getDate() - 1); - return result; -}; - -const datePartEquals = function (dateX, dateY) { - return (dateX.getFullYear() === dateY.getFullYear()) - && (dateX.getMonth() === dateY.getMonth()) - && (dateX.getDate() === dateY.getDate()); -}; - -const isDateInWeek = function (date, startOfWeek) { - let d = cloneDate(startOfWeek); - for (let i=0; i<7; i++) { - if (datePartEquals(date, d)) { - return true; - } - d = tomorrow(d); - } - return false; -}; - -const isThisWeek = function (date, referenceDate) { - const startOfThisWeek = cloneDate(referenceDate); - startOfThisWeek.setDate(startOfThisWeek.getDate() - startOfThisWeek.getDay()); - return isDateInWeek(date, startOfThisWeek); -}; - -const isNextWeek = function (date, referenceDate) { - const startOfNextWeek = cloneDate(referenceDate); - startOfNextWeek.setDate(startOfNextWeek.getDate() + (7 - startOfNextWeek.getDay())); - return isDateInWeek(date, startOfNextWeek); -}; - -const isLastWeek = function (date, referenceDate) { - const startOfLastWeek = cloneDate(referenceDate); - startOfLastWeek.setDate(startOfLastWeek.getDate() - (7 + startOfLastWeek.getDay())); - return isDateInWeek(date, startOfLastWeek); -}; - -const weekOfYear = function (date) { - const ds = new Date(date.getFullYear(), 0); - const de = new Date(date.getFullYear(), date.getMonth(), date.getDate()); - let weeks = 1; - while (ds.getTime() < de.getTime()) { - const jsDayOfWeek = ds.getDay(); - const isoDayOfWeek = jsDayOfWeek == 0 ? 7 : jsDayOfWeek; - if (isoDayOfWeek === 7) { - weeks++; - } - ds.setDate(ds.getDate() + 1); - } - return weeks; -}; - -const fixedFormatNumber = function (n, size) { - const s = n.toString(); - let zeros = ''; - const np = size - s.length; - for (let i=0; i 23) { - const days = Math.floor(result.hour / 24); - const hour = result.hour % 24; - result.hour = hour; - if ('year' in result && 'month' in result && 'dayOfMonth' in result) { - const d = new Date(result.year, result.month - 1, result.dayOfMonth, 0, 0, 0); - for (let i=0; i 59) { - result.hour++; - result.minute = 0; - } - return result; - } - return start; -}; - -const timexDateTimeAdd = function (start, duration) { - return timexTimeAdd(timexDateAdd(start, duration), duration); -}; - -const format = function(timex) { - - const types = ('types' in timex) ? timex.types : timexInference.infer(timex); - - if (types.has('present')) { - return 'PRESENT_REF'; - } - if ((types.has('datetimerange') || types.has('daterange') || types.has('timerange')) && types.has('duration')) { - const range = timexHelpers.expandDateTimeRange(timex); - return `(${format(range.start)},${format(range.end)},${format(range.duration)})`; - } - if (types.has('datetimerange')) { - return `${formatDate(timex)}${formatTimeRange(timex)}`; - } - if (types.has('daterange')) { - return `${formatDateRange(timex)}`; - } - if (types.has('timerange')) { - return `${formatTimeRange(timex)}`; - } - if (types.has('datetime')) { - return `${formatDate(timex)}${formatTime(timex)}`; - } - if (types.has('duration')) { - return `${formatDuration(timex)}`; - } - if (types.has('date')) { - return `${formatDate(timex)}`; - } - if (types.has('time')) { - return `${formatTime(timex)}`; - } - return ''; -}; - -module.exports.format = format; diff --git a/JavaScript/packages/datatypes-date-time/src/timexHelpers.js b/JavaScript/packages/datatypes-date-time/src/timexHelpers.js deleted file mode 100644 index 19d69f1f7f..0000000000 --- a/JavaScript/packages/datatypes-date-time/src/timexHelpers.js +++ /dev/null @@ -1,227 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -const Time = require('./time.js').Time; -const timexInference = require('./timexInference.js'); - -const cloneDateTime = function (timex) { - const result = Object.assign({}, timex); - delete result.years; - delete result.months; - delete result.weeks; - delete result.days; - delete result.hours; - delete result.minutes; - delete result.seconds; - return result; -}; - -const cloneDuration = function (timex) { - const result = Object.assign({}, timex); - delete result.year; - delete result.month; - delete result.dayOfMonth; - delete result.dayOfWeek; - delete result.weekOfYear; - delete result.weekOfMonth; - delete result.season; - delete result.hour; - delete result.minute; - delete result.second; - delete result.weekend; - delete result.partOfDay; - return result; -}; - -const timexDateAdd = function (start, duration) { - if ('dayOfWeek' in start) { - const end = Object.assign({}, start); - if ('days' in duration) { - end.dayOfWeek += duration.days; - } - return end; - } - if ('month' in start && 'dayOfMonth' in start) { - var durationDays = duration.days; - if (durationDays === undefined && duration.weeks !== undefined) { - durationDays = 7 * duration.weeks; - } - if (durationDays !== undefined) { - if ('year' in start) { - const d = new Date(start.year, start.month - 1, start.dayOfMonth, 0, 0, 0); - for (let i=0; i < durationDays; i++) { - d.setDate(d.getDate() + 1); - } - return { year: d.getFullYear(), month: d.getMonth() + 1, dayOfMonth: d.getDate() }; - } - else { - const d = new Date(2001, start.month - 1, start.dayOfMonth, 0, 0, 0); - for (let i=0; i < durationDays; i++) { - d.setDate(d.getDate() + 1); - } - return { month: d.getMonth() + 1, dayOfMonth: d.getDate() }; - } - } - if ('years' in duration) { - if ('year' in start) { - return { year: start.year + duration.years, month: start.month, dayOfMonth: start.dayOfMonth }; - } - } - if ('months' in duration) { - if ('month' in start) { - return { year: start.year, month: start.month + duration.months, dayOfMonth: start.dayOfMonth }; - } - } - } - return start; -}; - -const timexTimeAdd = function (start, duration) { - if ('hours' in duration) { - const result = Object.assign({}, start); - result.hour += duration.hours; - if (result.hour > 23) { - const days = Math.floor(result.hour / 24); - const hour = result.hour % 24; - result.hour = hour; - if ('year' in result && 'month' in result && 'dayOfMonth' in result) { - const d = new Date(result.year, result.month - 1, result.dayOfMonth, 0, 0, 0); - for (let i=0; i 59) { - result.hour++; - result.minute = 0; - } - return result; - } - return start; -}; - -const timexDateTimeAdd = function (start, duration) { - return timexTimeAdd(timexDateAdd(start, duration), duration); -}; - -const expandDateTimeRange = function (timex) { - const types = ('types' in timex) ? timex.types : timexInference.infer(timex); - if (types.has('duration')) { - const start = cloneDateTime(timex); - const duration = cloneDuration(timex); - return { start: start, end: timexDateTimeAdd(start, duration), duration: duration }; - } - else { - if ('year' in timex) { - const range = { start: { year: timex.year }, end: {} }; - if ('month' in timex) { - range.start.month = timex.month; - range.start.dayOfMonth = 1; - range.end.year = timex.year; - range.end.month = timex.month + 1; - range.end.dayOfMonth = 1; - } - else { - range.start.month = 1; - range.start.dayOfMonth = 1; - range.end.year = timex.year + 1; - range.end.month = 1; - range.end.dayOfMonth = 1; - } - return range; - } - } - return { start: {}, end: {} }; -}; - -const timeAdd = function (start, duration) { - const hours = duration.hours || 0; - const minutes = duration.minutes || 0; - const seconds = duration.seconds || 0; - return { hour: start.hour + hours, minute: start.minute + minutes, second: start.second + seconds }; -}; - -const expandTimeRange = function (timex) { - - if (!timex.types.has('timerange')) - { - throw new exception('argument must be a timerange'); - } - - if (timex.partOfDay !== undefined) { - switch (timex.partOfDay) { - case 'DT': - timex = { hour: 8, minute: 0, second: 0, hours: 10, minutes: 0, seconds: 0 }; - break; - case 'MO': - timex = { hour: 8, minute: 0, second: 0, hours: 4, minutes: 0, seconds: 0 }; - break; - case 'AF': - timex = { hour: 12, minute: 0, second: 0, hours: 4, minutes: 0, seconds: 0 }; - break; - case 'EV': - timex = { hour: 16, minute: 0, second: 0, hours: 4, minutes: 0, seconds: 0 }; - break; - case 'NI': - timex = { hour: 20, minute: 0, second: 0, hours: 4, minutes: 0, seconds: 0 }; - break; - default: - throw new exception('unrecognized part of day timerange'); - } - } - - const start = { hour: timex.hour, minute: timex.minute, second: timex.second }; - const duration = cloneDuration(timex); - return { start: start, end: timeAdd(start, duration), duration: duration }; -}; - -const dateFromTimex = function (timex) { - const year = 'year' in timex ? timex.year : 2001; - const month = 'month' in timex ? timex.month - 1 : 0; - const date = 'dayOfMonth' in timex ? timex.dayOfMonth : 1; - const hour = 'hour' in timex ? timex.hour : 0; - const minute = 'minute' in timex ? timex.minute : 0; - const second = 'second' in timex ? timex.second : 0; - return new Date(year, month, date, hour, minute, second); -}; - -const timeFromTimex = function (timex) { - const hour = timex.hour || 0; - const minute = timex.minute || 0; - const second = timex.second || 0; - return new Time(hour, minute, second); -}; - -const dateRangeFromTimex = function (timex) { - const expanded = expandDateTimeRange(timex); - return { start: dateFromTimex(expanded.start), end: dateFromTimex(expanded.end) }; -}; - -const timeRangeFromTimex = function (timex) { - const expanded = expandTimeRange(timex); - return { start: timeFromTimex(expanded.start), end: timeFromTimex(expanded.end) }; -}; - -module.exports = { - expandDateTimeRange: expandDateTimeRange, - expandTimeRange: expandTimeRange, - dateFromTimex: dateFromTimex, - timeFromTimex: timeFromTimex, - dateRangeFromTimex: dateRangeFromTimex, - timeRangeFromTimex: timeRangeFromTimex, - timexTimeAdd: timexTimeAdd, - timexDateTimeAdd: timexDateTimeAdd -}; diff --git a/JavaScript/packages/datatypes-date-time/src/timexInference.js b/JavaScript/packages/datatypes-date-time/src/timexInference.js deleted file mode 100644 index ffc0b1928e..0000000000 --- a/JavaScript/packages/datatypes-date-time/src/timexInference.js +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -const isPresent = function (obj) { - return obj.now === true; -}; - -const isDuration = function (obj) { - return 'years' in obj || 'months' in obj || 'weeks' in obj || 'days' in obj - || 'hours' in obj || 'minutes' in obj || 'seconds' in obj; -}; - -const isTime = function (obj) { - return 'hour' in obj && 'minute' in obj && 'second' in obj; -}; - -const isDate = function (obj) { - return ('month' in obj && 'dayOfMonth' in obj) || 'dayOfWeek' in obj; -}; - -const isTimeRange = function (obj) { - return 'partOfDay' in obj; -}; - -const isDateRange = function (obj) { - return ('year' in obj && !('dayOfMonth' in obj)) - || ('year' in obj && 'month' in obj && !('dayOfMonth' in obj)) - || ('month' in obj && !('dayOfMonth' in obj)) - || 'season' in obj - || 'weekOfYear' in obj - || 'weekOfMonth' in obj; -}; - -const isDefinite = function (obj) { - return 'year' in obj && 'month' in obj && 'dayOfMonth' in obj; -}; - -const infer = function (obj) { - const types = new Set(); - if (isPresent(obj)) { - types.add('present'); - } - if (isDefinite(obj)) { - types.add('definite'); - } - if (isDate(obj)) { - types.add('date'); - } - if (isDateRange(obj)) { - types.add('daterange'); - } - if (isDuration(obj)) { - types.add('duration'); - } - if (isTime(obj)) { - types.add('time'); - } - if (isTimeRange(obj)) { - types.add('timerange'); - } - if (types.has('present')) { - types.add('date'); - types.add('time'); - } - if (types.has('time') && types.has('duration')) { - types.add('timerange'); - } - if (types.has('date') && types.has('time')) { - types.add('datetime'); - } - if (types.has('date') && types.has('duration')) { - types.add('daterange'); - } - if (types.has('datetime') && types.has('duration')) { - types.add('datetimerange'); - } - if (types.has('date') && types.has('timerange')) { - types.add('datetimerange'); - } - return types; -}; - -module.exports.infer = infer; diff --git a/JavaScript/packages/datatypes-date-time/src/timexParsing.js b/JavaScript/packages/datatypes-date-time/src/timexParsing.js deleted file mode 100644 index 70c3cb8e6e..0000000000 --- a/JavaScript/packages/datatypes-date-time/src/timexParsing.js +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -const timexregex = require('./timexRegex.js'); - -const parseString = function (timex, obj) { - // a reference to the present - if (timex === 'PRESENT_REF') { - obj.now = true; - } - // duration - else if (timex.startsWith('P')) { - extractDuration(timex, obj); - } - // range indicated with start and end dates and a duration - else if (timex.startsWith('(') && timex.endsWith(')')) { - extractStartEndRange(timex, obj); - } - // date and time and their respective ranges - else { - extractDateTime(timex, obj); - } -}; - -const extractDuration = function (s, obj) { - const extracted = {}; - timexregex.extract('period', s, extracted); - if (extracted.dateUnit) { - obj[{ Y: 'years', M: 'months', W: 'weeks', D: 'days' }[extracted.dateUnit]] = extracted.amount; - } - else if (extracted.timeUnit) { - obj[{ H: 'hours', M: 'minutes', S: 'seconds' }[extracted.timeUnit]] = extracted.amount; - } -}; - -const extractStartEndRange = function (s, obj) { - const parts = s.substring(1, s.length - 1).split(','); - if (parts.length === 3) { - extractDateTime(parts[0], obj); - extractDuration(parts[2], obj); - } -}; - -const extractDateTime = function (s, obj) { - const indexOfT = s.indexOf('T'); - if (indexOfT === -1) { - timexregex.extract('date', s, obj); - } - else { - timexregex.extract('date', s.substr(0, indexOfT), obj); - timexregex.extract('time', s.substr(indexOfT), obj); - } -}; - -const fromObject = function (source, obj) { - Object.assign(obj, source); - if ('hour' in obj) { - if (!('minute' in obj)) { - obj.minute = 0; - } - if (!('second' in obj)) { - obj.second = 0; - } - } -}; - -module.exports = { - parseString: parseString, - fromObject: fromObject -}; diff --git a/JavaScript/packages/datatypes-date-time/src/timexProperty.js b/JavaScript/packages/datatypes-date-time/src/timexProperty.js deleted file mode 100644 index d9128ac517..0000000000 --- a/JavaScript/packages/datatypes-date-time/src/timexProperty.js +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -const timexParsing = require('./timexParsing.js'); -const timexInference = require('./timexInference.js'); -const timexFormat = require('./timexFormat.js'); -const timexConvert = require('./timexConvert.js'); -const timexRelativeConvert = require('./timexRelativeConvert.js'); - -class TimexProperty { - constructor (timex) { - if (typeof timex === 'string') { - timexParsing.parseString(timex, this); - } - else { - timexParsing.fromObject(timex, this); - } - // TODO: constructing a Timex from a Timex should be very cheap - } - - get timex() { - return timexFormat.format(this); - } - - get types () { - return timexInference.infer(this); - } - - toString () { - return timexConvert.convertTimexToString(this); - } - - // TODO: consider [locales[, options]] similar to Date.toLocaleString([locales[, options]]) - toNaturalLanguage (referenceDate) { - return timexRelativeConvert.convertTimexToStringRelative(this, referenceDate); - } - - static fromDate (date) { - return new TimexProperty({ - year: date.getFullYear(), - month: date.getMonth() + 1, - dayOfMonth: date.getDate() - }); - } - - static fromDateTime (date) { - return new TimexProperty({ - year: date.getFullYear(), - month: date.getMonth() + 1, - dayOfMonth: date.getDate(), - hour: date.getHours(), - minute: date.getMinutes(), - second: date.getSeconds() - }); - } - - static fromTime (time) { - return new TimexProperty(time); - } -} - -module.exports.TimexProperty = TimexProperty; diff --git a/JavaScript/packages/datatypes-date-time/src/timexRangeResolver.js b/JavaScript/packages/datatypes-date-time/src/timexRangeResolver.js deleted file mode 100644 index be0c745f05..0000000000 --- a/JavaScript/packages/datatypes-date-time/src/timexRangeResolver.js +++ /dev/null @@ -1,234 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -const timexHelpers = require('./timexHelpers.js'); -const timexDateHelpers = require('./timexDateHelpers.js'); -const timexConstraintsHelper = require('./timexConstraintsHelper.js'); -const Time = require('./time.js').Time; -const TimexProperty = require('./timexProperty.js').TimexProperty; - -const resolveDefiniteAgainstConstraint = function (timex, constraint) { - const timexDate = timexHelpers.dateFromTimex(timex); - if (timexDate.getTime() >= constraint.start.getTime() && timexDate.getTime() < constraint.end.getTime()) { - return [ timex.timex ]; - } - return []; -}; - -const resolveDefinite = function (timex, constraints) { - const result = []; - for (const constraint of constraints) { - Array.prototype.push.apply(result, resolveDefiniteAgainstConstraint(timex, constraint)); - } - return result; -}; - -const resolveDateAgainstConstraint = function (timex, constraint) { - if ('month' in timex && 'dayOfMonth' in timex) { - const result = []; - for (let year = constraint.start.getFullYear(); year <= constraint.end.getFullYear(); year++) { - const r = resolveDefiniteAgainstConstraint(new TimexProperty(Object.assign({}, timex, { year: year })), constraint); - if (r.length > 0) { - result.push(r[0]); - } - } - return result; - } - if ('dayOfWeek' in timex) { - const day = timex.dayOfWeek === 7 ? 0 : timex.dayOfWeek; - const dates = timexDateHelpers.datesMatchingDay(day, constraint.start, constraint.end); - const result = []; - for (const d of dates) { - const t = Object.assign({}, timex); - delete t.dayOfWeek; - const r = new TimexProperty(Object.assign({}, t, { year: d.getFullYear(), month: d.getMonth() + 1, dayOfMonth: d.getDate() })); - result.push(r.timex); - } - return result; - } - return []; -}; - -const resolveDate = function (timex, constraints) { - const result = []; - for (const constraint of constraints) { - Array.prototype.push.apply(result, resolveDateAgainstConstraint(timex, constraint)); - } - return result; -}; - -const resolveTimeAgainstConstraint = function (timex, constraint) { - const t = new Time(timex.hour, timex.minute, timex.second); - if (t.getTime() >= constraint.start.getTime() && t.getTime() < constraint.end.getTime()) { - return [ timex.timex ]; - } - return []; -}; - -const resolveTime = function (timex, constraints) { - const result = []; - for (const constraint of constraints) { - Array.prototype.push.apply(result, resolveTimeAgainstConstraint(timex, constraint)); - } - return result; -}; - -const removeDuplicates = function (array) { - var seen = new Set(); - return array.filter(item => { return seen.has(item) ? false : seen.add(item); }); -}; - -const resolveByDateRangeConstraints = function (candidates, timexConstraints) { - - const dateRangeConstraints = timexConstraints - .filter((timex) => { - return timex.types.has('daterange'); }) - .map((timex) => { - return timexHelpers.dateRangeFromTimex(timex); - }); - const collapsedDateRanges = timexConstraintsHelper.collapse(dateRangeConstraints, Date); - - if (collapsedDateRanges.length === 0) { - return candidates; - } - - const resolution = []; - for (const timex of candidates) { - const r = resolveDate(new TimexProperty(timex), collapsedDateRanges); - Array.prototype.push.apply(resolution, r); - } - - return removeDuplicates(resolution); -}; - -const resolveByTimeConstraints = function (candidates, timexConstraints) { - - const times = timexConstraints - .filter((timex) => { - return timex.types.has('time'); }) - .map((timex) => { - return timexHelpers.timeFromTimex(timex); - }); - - if (times.length === 0) { - return candidates; - } - - const resolution = []; - for (const timex of candidates.map(t => new TimexProperty(t))) { - if (timex.types.has('date') && !timex.types.has('time')) { - for (const time of times) { - timex.hour = time.hour; - timex.minute = time.minute; - timex.second = time.second; - resolution.push(timex.timex); - } - } - else { - resolution.push(timex.timex); - } - } - return removeDuplicates(resolution); -}; - -const resolveByTimeRangeConstraints = function (candidates, timexConstraints) { - - const timeRangeConstraints = timexConstraints - .filter((timex) => { - return timex.types.has('timerange'); }) - .map((timex) => { - return timexHelpers.timeRangeFromTimex(timex); - }); - const collapsedTimeRanges = timexConstraintsHelper.collapse(timeRangeConstraints, Time); - - if (collapsedTimeRanges.length === 0) { - return candidates; - } - - const resolution = []; - for (const timex of candidates) { - const t = new TimexProperty(timex); - if (t.types.has('timerange')) { - const r = resolveTimeRange(t, collapsedTimeRanges); - Array.prototype.push.apply(resolution, r); - } - else if (t.types.has('time')) { - const r = resolveTime(t, collapsedTimeRanges); - Array.prototype.push.apply(resolution, r); - } - } - - return removeDuplicates(resolution); -}; - -const resolveTimeRange = function (timex, constraints) { - - const candidate = timexHelpers.timeRangeFromTimex(timex); - - const result = []; - for (const constraint of constraints) { - - if (timexConstraintsHelper.isOverlapping(candidate, constraint)) { - - const start = Math.max(candidate.start.getTime(), constraint.start.getTime()); - const time = new Time(start); - - // TODO: refer to comments in C# - consider first classing this clone/overwrite behavior - const resolved = new TimexProperty(timex.timex); - delete resolved.partOfDay; - delete resolved.seconds; - delete resolved.minutes; - delete resolved.hours; - resolved.second = time.second; - resolved.minute = time.minute; - resolved.hour = time.hour; - - result.push(resolved.timex); - } - } - return result; -}; - -const resolveDuration = function (candidate, constraints) { - const results = []; - for (const constraint of constraints) { - if (constraint.types.has('datetime')) { - results.push(new TimexProperty(timexHelpers.timexDateTimeAdd(constraint, candidate))); - } - else if (constraint.types.has('time')) { - results.push(new TimexProperty(timexHelpers.timexTimeAdd(constraint, candidate))); - } - } - return results; -}; - -const resolveDurations = function (candidates, constraints) { - const results = []; - for (const candidate of candidates) { - const timex = new TimexProperty(candidate); - if (timex.types.has('duration')) { - const r = resolveDuration(timex, constraints); - for (const resolved of r) { - results.push(resolved.timex); - } - } - else { - results.push(candidate); - } - } - return results; -}; - -const evaluate = function (candidates, constraints) { - const timexConstraints = constraints.map((x) => { return new TimexProperty(x); }); - const candidatesWithDurationsResolved = resolveDurations(candidates, timexConstraints); - const candidatesAccordingToDate = resolveByDateRangeConstraints(candidatesWithDurationsResolved, timexConstraints); - const candidatesWithAddedTime = resolveByTimeConstraints(candidatesAccordingToDate, timexConstraints); - const candidatesFilteredByTime = resolveByTimeRangeConstraints(candidatesWithAddedTime, timexConstraints); - const timexResults = candidatesFilteredByTime.map((x) => { return new TimexProperty(x); }); - return timexResults; -}; - -module.exports = { - evaluate: evaluate -}; diff --git a/JavaScript/packages/datatypes-date-time/src/timexRegex.js b/JavaScript/packages/datatypes-date-time/src/timexRegex.js deleted file mode 100644 index e82e63ab13..0000000000 --- a/JavaScript/packages/datatypes-date-time/src/timexRegex.js +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -const value = function (s) { return s; }; -const isTrue = function () { return true; }; -const zero = function () { return 0; }; - -const timexRegex = { - - date: [ - // date - { regex: /^(\d\d\d\d)-(\d\d)-(\d\d)$/, props: { year: Number, month: Number, dayOfMonth: Number } }, - { regex: /^XXXX-WXX-(\d)$/, props: { dayOfWeek: Number } }, - { regex: /^XXXX-(\d\d)-(\d\d)$/, props: { month: Number, dayOfMonth: Number } }, - // daterange - { regex: /^(\d\d\d\d)$/, props: { year: Number } }, - { regex: /^(\d\d\d\d)-(\d\d)$/, props: { year: Number, month: Number } }, - { regex: /^(SP|SU|FA|WI)$/, props: { season: value } }, - { regex: /^(\d\d\d\d)-(SP|SU|FA|WI)$/, props: { year: Number, season: value } }, - { regex: /^(\d\d\d\d)-W(\d\d)$/, props: { year: Number, weekOfYear: Number } }, - { regex: /^(\d\d\d\d)-W(\d\d)-WE$/, props: { year: Number, weekOfYear: Number, weekend: isTrue } }, - { regex: /^XXXX-(\d\d)$/, props: { month: Number } }, - { regex: /^XXXX-(\d\d)-W(\d\d)$/, props: { month: Number, weekOfMonth: Number } }, - { regex: /^XXXX-(\d\d)-WXX-(\d)-(\d)$/, props: { month: Number, weekOfMonth: Number, dayOfWeek: Number } } - ], - - time: [ - // time - { regex: /^T(\d\d)$/, props: { hour: Number, minute: zero, second: zero } }, - { regex: /^T(\d\d):(\d\d)$/, props: { hour: Number, minute: Number, second: zero } }, - { regex: /^T(\d\d):(\d\d):(\d\d)$/, props: { hour: Number, minute: Number, second: Number } }, - // timerange - { regex: /^T(DT|NI|MO|AF|EV)$/, props: { partOfDay: value } } - ], - - period: [ - { regex: /^P(\d*\.?\d+)(Y|M|W|D)$/, props: { amount: Number, dateUnit: value } }, - { regex: /^PT(\d*\.?\d+)(H|M|S)$/, props: { amount: Number, timeUnit: value } } - ] -}; - -const tryExtract = function (entry, timex, result) { - const regexResult = timex.match(entry.regex); - if (!regexResult) { - return false; - } - let index = 1; - for (const name in entry.props) { - const val = regexResult[index++]; - result[name] = entry.props[name](val); - } - return true; -}; - -const extract = function (name, timex, result) { - for (const entry of timexRegex[name]) { - if (tryExtract(entry, timex, result)) { - return true; - } - } - return false; -}; - -module.exports.extract = extract; diff --git a/JavaScript/packages/datatypes-date-time/src/timexRelativeConvert.js b/JavaScript/packages/datatypes-date-time/src/timexRelativeConvert.js deleted file mode 100644 index 4c5365c47d..0000000000 --- a/JavaScript/packages/datatypes-date-time/src/timexRelativeConvert.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -module.exports.convertTimexToStringRelative = require('./en/timexRelativeConvert.js').convertTimexToStringRelative; - diff --git a/JavaScript/packages/datatypes-date-time/src/timexResolver.js b/JavaScript/packages/datatypes-date-time/src/timexResolver.js deleted file mode 100644 index 8f7352e70f..0000000000 --- a/JavaScript/packages/datatypes-date-time/src/timexResolver.js +++ /dev/null @@ -1,233 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -const TimexProperty = require('./timexProperty.js').TimexProperty; -const timexValue = require('./timexValue.js'); -const timexInference = require('./timexInference.js'); -const timexHelpers = require('./timexHelpers.js'); - -const dateOfLastDay = require('./timexDateHelpers.js').dateOfLastDay; -const dateOfNextDay = require('./timexDateHelpers.js').dateOfNextDay; - -const resolveDefiniteTime = function (timex, date) { - return [{ timex: timex.timex, type: 'datetime', value: `${timexValue.dateValue(timex)} ${timexValue.timeValue(timex)}` }]; -}; - -const resolveDefinite = function (timex, date) { - return [{ timex: timex.timex, type: 'date', value: timexValue.dateValue(timex) }]; -}; - -const lastDateValue = function (timex, date) { - if (timex.month !== undefined && timex.dayOfMonth !== undefined) { - return timexValue.dateValue({ year: date.getFullYear() - 1, month: timex.month, dayOfMonth: timex.dayOfMonth }); - } - if (timex.dayOfWeek !== undefined) { - const day = timex.dayOfWeek === 7 ? 0 : timex.dayOfWeek; - const result = dateOfLastDay(day, date); - return timexValue.dateValue({ year: result.getFullYear(), month: result.getMonth() + 1, dayOfMonth: result.getDate() }); - } -}; - -const nextDateValue = function (timex, date) { - if (timex.month !== undefined && timex.dayOfMonth !== undefined) { - return timexValue.dateValue({ year: date.getFullYear(), month: timex.month, dayOfMonth: timex.dayOfMonth }); - } - if (timex.dayOfWeek !== undefined) { - const day = timex.dayOfWeek === 7 ? 0 : timex.dayOfWeek; - const result = dateOfNextDay(day, date); - return timexValue.dateValue({ year: result.getFullYear(), month: result.getMonth() + 1, dayOfMonth: result.getDate() }); - } -}; - -const resolveDate = function (timex, date) { - return [ - { timex: timex.timex, type: 'date', value: lastDateValue(timex, date) }, - { timex: timex.timex, type: 'date', value: nextDateValue(timex, date) } - ]; -}; - -const resolveTime = function (timex) { - return [ { timex: timex.timex, type: 'time', value: timexValue.timeValue(timex) } ]; -}; - -const resolveDuration = function (timex) { - return [ { timex: timex.timex, type: 'duration', value: timexValue.durationValue(timex) }]; -}; - -const weekDateRange = function (year, weekOfYear) { - var dateInWeek = new Date(year, 0, 1); - dateInWeek.setDate(dateInWeek.getDate() + ((weekOfYear - 1) * 7)); - - var start = dateOfLastDay(1, dateInWeek); - dateInWeek.setDate(dateInWeek.getDate() + 7); - var end = dateOfLastDay(1, dateInWeek); - - return { - start: timexValue.dateValue({ year: start.getFullYear(), month: start.getMonth() + 1, dayOfMonth: start.getDate() }), - end: timexValue.dateValue({ year: end.getFullYear(), month: end.getMonth() + 1, dayOfMonth: end.getDate() }) - } -} - -const monthDateRange = function (year, month) { - return { - start: timexValue.dateValue({ year: year, month: month, dayOfMonth: 1 }), - end: timexValue.dateValue({ year: month == 12 ? year + 1 : year, month: month == 12 ? 1 : month + 1, dayOfMonth: 1 }) - }; -}; - -const yearDateRange = function (year) { - return { - start: timexValue.dateValue({ year: year, month: 1, dayOfMonth: 1 }), - end: timexValue.dateValue({ year: year + 1, month: 1, dayOfMonth: 1 }) - }; -} - -const resolveDateRange = function (timex, date) { - if ('season' in timex) { - return [{ timex: timex.timex, type: 'daterange', value: 'not resolved' }]; - } - else { - if (timex.year !== undefined && timex.month !== undefined) { - const dateRange = monthDateRange(timex.year, timex.month); - return [{ timex: timex.timex, type: 'daterange', start: dateRange.start, end: dateRange.end }]; - } - if (timex.year !== undefined && timex.weekOfYear !== undefined) { - const dateRange = weekDateRange(timex.year, timex.weekOfYear); - return [{ timex: timex.timex, type: 'daterange', start: dateRange.start, end: dateRange.end }]; - } - if (timex.month !== undefined) { - const y = date.getFullYear(); - const lastYearDateRange = monthDateRange(y - 1, timex.month); - const thisYearDateRange = monthDateRange(y, timex.month); - - return [ - { timex: timex.timex, type: 'daterange', start: lastYearDateRange.start, end: lastYearDateRange.end }, - { timex: timex.timex, type: 'daterange', start: thisYearDateRange.start, end: thisYearDateRange.end } - ]; - } - if (timex.year !== undefined) { - const dateRange = yearDateRange(timex.year); - return [{ timex: timex.timex, type: 'daterange', start: dateRange.start, end: dateRange.end }]; - } - return []; - } -}; - -const partOfDayTimeRange = function (timex) { - switch (timex.partOfDay) { - case 'MO': return { start: '08:00:00', end: '12:00:00' }; - case 'AF': return { start: '12:00:00', end: '16:00:00' }; - case 'EV': return { start: '16:00:00', end: '20:00:00' }; - case 'NI': return { start: '20:00:00', end: '24:00:00' }; - } - return { start: 'not resolved', end: 'not resolved' }; -}; - -const resolveTimeRange = function (timex, date) { - if ('partOfDay' in timex) { - const range = partOfDayTimeRange(timex); - return [{ timex: timex.timex, type: 'timerange', start: range.start, end: range.end }]; - } - else { - const range = timexHelpers.expandTimeRange(timex); - return [{ - timex: timex.timex, - type: 'timerange', - start: timexValue.timeValue(range.start), - end: timexValue.timeValue(range.end) - }]; - } -}; - -const resolveDateTime = function (timex, date) { - const resolvedDates = resolveDate(timex, date); - for (const resolved of resolvedDates) { - resolved.type = 'datetime'; - resolved.value = `${resolved.value} ${timexValue.timeValue(timex)}`; - - } - return resolvedDates; -}; - -const resolveDateTimeRange = function (timex) { - if ('partOfDay' in timex) { - const date = timexValue.dateValue(timex); - const timeRange = partOfDayTimeRange(timex); - return [{ - timex: timex.timex, - type: 'datetimerange', - start: `${date} ${timeRange.start}`, - end: `${date} ${timeRange.end}` - }]; - } - else { - const range = timexHelpers.expandDateTimeRange(timex); - return [{ - timex: timex.timex, - type: 'datetimerange', - start: `${timexValue.dateValue(range.start)} ${timexValue.timeValue(range.start)}`, - end: `${timexValue.dateValue(range.end)} ${timexValue.timeValue(range.end)}` - }]; - } -}; - -const resolveDefiniteDateRange = function (timex) { - var range = timexHelpers.expandDateTimeRange(timex); - return [{ - timex: timex.timex, - type: 'daterange', - start: `${timexValue.dateValue(range.start)}`, - end: `${timexValue.dateValue(range.end)}` - }]; -}; - -const resolveTimex = function (timex, date) { - - const types = ('types' in timex) ? timex.types : timexInference.infer(timex); - - if (types.has('datetimerange')) { - return resolveDateTimeRange(timex); - } - if (types.has('definite') && types.has('time')) { - return resolveDefiniteTime(timex, date); - } - if (types.has('definite') && types.has('daterange')) { - return resolveDefiniteDateRange(timex, date); - } - if (types.has('definite')) { - return resolveDefinite(timex, date); - } - if (types.has('daterange')) { - return resolveDateRange(timex, date); - } - if (types.has('timerange')) { - return resolveTimeRange(timex); - } - if (types.has('datetime')) { - return resolveDateTime(timex, date); - } - if (types.has('duration')) { - return resolveDuration(timex); - } - if (types.has('date')) { - return resolveDate(timex, date); - } - if (types.has('time')) { - return resolveTime(timex); - } - return []; -}; - -const resolve = function (timexArray, date) { - const resolution = { values: [] }; - for (const timex of timexArray) { - const t = new TimexProperty(timex); - const r = resolveTimex(t, date); - Array.prototype.push.apply(resolution.values, r); - } - return resolution; -}; - -module.exports = { - resolve: resolve -}; diff --git a/JavaScript/packages/datatypes-date-time/src/timexSet.js b/JavaScript/packages/datatypes-date-time/src/timexSet.js deleted file mode 100644 index ff6b1839b8..0000000000 --- a/JavaScript/packages/datatypes-date-time/src/timexSet.js +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -const TimexProperty = require('./timexProperty.js').TimexProperty; - -class TimexSet { - constructor (timex) { - this.timex = new TimexProperty(timex); - } -} - -module.exports.TimexSet = TimexSet; diff --git a/JavaScript/packages/datatypes-date-time/src/timexValue.js b/JavaScript/packages/datatypes-date-time/src/timexValue.js deleted file mode 100644 index 2a0c291e62..0000000000 --- a/JavaScript/packages/datatypes-date-time/src/timexValue.js +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -const fixedFormatNumber = require('./timexDateHelpers.js').fixedFormatNumber; - -const dateValue = function (obj) { - if (obj.year !== undefined && obj.month !== undefined && obj.dayOfMonth !== undefined) { - return `${fixedFormatNumber(obj.year, 4)}-${fixedFormatNumber(obj.month, 2)}-${fixedFormatNumber(obj.dayOfMonth, 2)}`; - } - return ''; -}; - -const timeValue = function (obj) { - if (obj.hour !== undefined && obj.minute !== undefined && obj.second !== undefined) { - return `${fixedFormatNumber(obj.hour, 2)}:${fixedFormatNumber(obj.minute, 2)}:${fixedFormatNumber(obj.second, 2)}`; - } - return ''; -}; - -const datetimeValue = function (obj) { - return `${dateValue(obj)} ${timeValue(obj)}`; -}; - -const durationValue = function (obj) { - if (obj.years !== undefined) { - return (31536000 * obj.years).toString(); - } - if (obj.months !== undefined) { - return (2592000 * obj.months).toString(); - } - if (obj.weeks !== undefined) { - return (604800 * obj.weeks).toString(); - } - if (obj.days !== undefined) { - return (86400 * obj.days).toString(); - } - if (obj.hours !== undefined) { - return (3600 * obj.hours).toString(); - } - if (obj.minutes !== undefined) { - return (60 * obj.minutes).toString(); - } - if (obj.seconds !== undefined) { - return obj.seconds.toString(); - } - return ''; -}; - -module.exports = { - dateValue: dateValue, - timeValue: timeValue, - datetimeValue: datetimeValue, - durationValue: durationValue -}; diff --git a/JavaScript/packages/datatypes-date-time/test/time.spec.js b/JavaScript/packages/datatypes-date-time/test/time.spec.js deleted file mode 100644 index 19bf5c481c..0000000000 --- a/JavaScript/packages/datatypes-date-time/test/time.spec.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -const chai = require('chai'); -const { Time } = require('../index.js'); - -const assert = chai.assert; -const expect = chai.expect; -chai.should(); - -describe('No Network', () => { - describe('Datatypes', () => { - describe('Time', () => { - it('constructor', () => { - const t = new Time(23, 45, 32); - t.hour.should.equal(23); - t.minute.should.equal(45); - t.second.should.equal(32); - }); - it('getTime', () => { - (new Time(23, 45, 32)).getTime().should.equal(85532000); - }); - }); - }); -}); diff --git a/JavaScript/packages/datatypes-date-time/test/timexConstraints.spec.js b/JavaScript/packages/datatypes-date-time/test/timexConstraints.spec.js deleted file mode 100644 index 9690ad78c8..0000000000 --- a/JavaScript/packages/datatypes-date-time/test/timexConstraints.spec.js +++ /dev/null @@ -1,171 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -const chai = require('chai'); -const timexConstraintsHelper = require('../src/timexConstraintsHelper.js'); -const { Time, TimexProperty } = require('../index.js'); - -const assert = chai.assert; -const expect = chai.expect; -chai.should(); - -describe('No Network', () => { - describe('Datatypes', () => { - describe('Timex constraints collapse', () => { - describe('Date collapse helper function', () => { - it('collapse pair', () => { - const ranges = [ - { start: new Date(2017, 9, 2), end: new Date(2017, 9, 4) }, - { start: new Date(2017, 9, 3), end: new Date(2017, 9, 6) } - ]; - const result = timexConstraintsHelper.collapse(ranges, Date); - result.should.be.an('array').lengthOf(1); - result[0]['start'].getTime().should.equal((new Date(2017, 9, 3)).getTime()); - result[0]['end'].getTime().should.equal((new Date(2017, 9, 4)).getTime()); - }); - it('collapse many', () => { - const ranges = [ - { start: new Date(2017, 9, 2), end: new Date(2017, 9, 6) }, - { start: new Date(2017, 9, 3), end: new Date(2017, 9, 17) }, - { start: new Date(2017, 9, 4), end: new Date(2017, 9, 8) }, - { start: new Date(2017, 9, 5), end: new Date(2017, 9, 15) }, - { start: new Date(2017, 9, 1), end: new Date(2017, 9, 20) } - ]; - const result = timexConstraintsHelper.collapse(ranges, Date); - result.should.be.an('array').lengthOf(1); - result[0]['start'].getTime().should.equal((new Date(2017, 9, 5)).getTime()); - result[0]['end'].getTime().should.equal((new Date(2017, 9, 6)).getTime()); - }); - it('collapse - disjoint', () => { - const ranges = [ - { start: new Date(2017, 9, 2), end: new Date(2017, 9, 6) }, - { start: new Date(2017, 9, 3), end: new Date(2017, 9, 7) }, - { start: new Date(2017, 9, 4), end: new Date(2017, 9, 8) }, - { start: new Date(2017, 9, 10), end: new Date(2017, 9, 15) }, - { start: new Date(2017, 9, 11), end: new Date(2017, 9, 14) }, - { start: new Date(2017, 9, 12), end: new Date(2017, 9, 16) } - ]; - const result = timexConstraintsHelper.collapse(ranges, Date); - result.should.be.an('array').lengthOf(2); - result[0]['start'].getTime().should.equal((new Date(2017, 9, 4)).getTime()); - result[0]['end'].getTime().should.equal((new Date(2017, 9, 6)).getTime()); - result[1]['start'].getTime().should.equal((new Date(2017, 9, 12)).getTime()); - result[1]['end'].getTime().should.equal((new Date(2017, 9, 14)).getTime()); - }); - it('collapse - disjoint and sorted', () => { - const ranges = [ - { start: new Date(2017, 9, 11), end: new Date(2017, 9, 14) }, - { start: new Date(2017, 9, 2), end: new Date(2017, 9, 6) }, - { start: new Date(2017, 9, 12), end: new Date(2017, 9, 16) }, - { start: new Date(2017, 9, 4), end: new Date(2017, 9, 8) }, - { start: new Date(2017, 9, 3), end: new Date(2017, 9, 7) }, - { start: new Date(2017, 9, 10), end: new Date(2017, 9, 15) } - ]; - const result = timexConstraintsHelper.collapse(ranges, Date); - result.should.be.an('array').lengthOf(2); - result[0]['start'].getTime().should.equal((new Date(2017, 9, 4)).getTime()); - result[0]['end'].getTime().should.equal((new Date(2017, 9, 6)).getTime()); - result[1]['start'].getTime().should.equal((new Date(2017, 9, 12)).getTime()); - result[1]['end'].getTime().should.equal((new Date(2017, 9, 14)).getTime()); - }); - it('disjoint and sorted', () => { - const ranges = [ - { start: new Date(2017, 1, 5), end: new Date(2017, 1, 10) }, - { start: new Date(2017, 6, 24), end: new Date(2017, 7, 4) }, - { start: new Date(2017, 2, 5), end: new Date(2017, 2, 10) }, - { start: new Date(2017, 5, 29), end: new Date(2017, 5, 30) } - ]; - const result = timexConstraintsHelper.collapse(ranges, Date); - result.should.be.an('array').lengthOf(4); - result[0]['start'].getTime().should.equal((new Date(2017, 1, 5)).getTime()); - result[0]['end'].getTime().should.equal((new Date(2017, 1, 10)).getTime()); - result[1]['start'].getTime().should.equal((new Date(2017, 2, 5)).getTime()); - result[1]['end'].getTime().should.equal((new Date(2017, 2, 10)).getTime()); - result[2]['start'].getTime().should.equal((new Date(2017, 5, 29)).getTime()); - result[2]['end'].getTime().should.equal((new Date(2017, 5, 30)).getTime()); - result[3]['start'].getTime().should.equal((new Date(2017, 6, 24)).getTime()); - result[3]['end'].getTime().should.equal((new Date(2017, 7, 4)).getTime()); - }); - }); - describe('Time', () => { - it('constructor(hour, minute, second)', () => { - const t = new Time(17, 30, 45); - t.should.have.property('hour', 17); - t.should.have.property('minute', 30); - t.should.have.property('second', 45); - }); - it('constructor(value)', () => { - const t = new Time((9 * 3600000) + (28 * 60000) + (15 * 1000)); - t.should.have.property('hour', 9); - t.should.have.property('minute', 28); - t.should.have.property('second', 15); - }); - it('getTime()', () => { - const t = new Time(17, 30, 45); - t.getTime().should.equal((17 * 3600000) + (30 * 60000) + (45 * 1000)); - }); - }); - describe('Time collapse helper function', () => { - it('collapse pair', () => { - const ranges = [ - { start: new Time(9, 20, 0), end: new Time(12, 0, 1) }, - { start: new Time(9, 30, 15), end: new Time(16, 0, 0) } - ]; - const result = timexConstraintsHelper.collapse(ranges, Time); - result.should.be.an('array').lengthOf(1); - result[0]['start'].getTime().should.equal((new Time(9, 30, 15)).getTime()); - result[0]['end'].getTime().should.equal((new Time(12, 0, 1)).getTime()); - }); - it('collapse many', () => { - const ranges = [ - { start: new Time(9, 20, 0), end: new Time(17, 0, 0) }, - { start: new Time(8, 45, 0), end: new Time(18, 0, 0) }, - { start: new Time(7, 0, 0), end: new Time(14, 0, 0) }, - { start: new Time(8, 0, 0), end: new Time(12, 0, 0) }, - { start: new Time(6, 0, 0), end: new Time(10, 30, 0) } - ]; - const result = timexConstraintsHelper.collapse(ranges, Time); - result.should.be.an('array').lengthOf(1); - result[0]['start'].getTime().should.equal((new Time(9, 20, 0)).getTime()); - result[0]['end'].getTime().should.equal((new Time(10, 30, 0)).getTime()); - }); - it('collapse - disjoint', () => { - const ranges = [ - { start: new Time(9, 0, 0), end: new Time(12, 0, 0) }, - { start: new Time(13, 0, 0), end: new Time(17, 30, 0) }, - { start: new Time(14, 0, 0), end: new Time(16, 30, 8) }, - { start: new Time(15, 30, 0), end: new Time(15, 45, 0) }, - { start: new Time(14, 20, 15), end: new Time(14, 20, 45) }, - { start: new Time(10, 15, 0), end: new Time(10, 30, 0) } - ]; - const result = timexConstraintsHelper.collapse(ranges, Time); - result.should.be.an('array').lengthOf(3); - result[0]['start'].getTime().should.equal((new Time(10, 15, 0)).getTime()); - result[0]['end'].getTime().should.equal((new Time(10, 30, 0)).getTime()); - result[1]['start'].getTime().should.equal((new Time(14, 20, 15)).getTime()); - result[1]['end'].getTime().should.equal((new Time(14, 20, 45)).getTime()); - result[2]['start'].getTime().should.equal((new Time(15, 30, 0)).getTime()); - result[2]['end'].getTime().should.equal((new Time(15, 45, 0)).getTime()); - }); - it('collapse - disjoint and sorted', () => { - const ranges = [ - { start: new Time(9, 0, 0), end: new Time(12, 0, 0) }, - { start: new Time(15, 30, 0), end: new Time(15, 45, 0) }, - { start: new Time(14, 20, 15), end: new Time(14, 20, 45) }, - { start: new Time(10, 15, 0), end: new Time(10, 30, 0) }, - { start: new Time(14, 0, 0), end: new Time(16, 30, 8) }, - { start: new Time(13, 0, 0), end: new Time(17, 30, 0) } - ]; - const result = timexConstraintsHelper.collapse(ranges, Time); - result.should.be.an('array').lengthOf(3); - result[0]['start'].getTime().should.equal((new Time(10, 15, 0)).getTime()); - result[0]['end'].getTime().should.equal((new Time(10, 30, 0)).getTime()); - result[1]['start'].getTime().should.equal((new Time(14, 20, 15)).getTime()); - result[1]['end'].getTime().should.equal((new Time(14, 20, 45)).getTime()); - result[2]['start'].getTime().should.equal((new Time(15, 30, 0)).getTime()); - result[2]['end'].getTime().should.equal((new Time(15, 45, 0)).getTime()); - }); - }); - }); - }); -}); diff --git a/JavaScript/packages/datatypes-date-time/test/timexConvert.spec.js b/JavaScript/packages/datatypes-date-time/test/timexConvert.spec.js deleted file mode 100644 index 071f21557b..0000000000 --- a/JavaScript/packages/datatypes-date-time/test/timexConvert.spec.js +++ /dev/null @@ -1,204 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -const chai = require('chai'); - -const { TimexProperty, TimexSet } = require('../index.js'); -const timexconvert = require('../src/timexConvert.js'); - -const assert = chai.assert; -const expect = chai.expect; -chai.should(); - -describe('No Network', () => { - describe('Datatypes', () => { - describe('Timex convert to string', () => { - describe('date', () => { - it('complete date', () => { - const timex = new TimexProperty('2017-05-29'); - timexconvert.convertTimexToString(timex).should.equal('29th May 2017'); - }); - it('month and dayOfMonth', () => { - timexconvert.convertTimexToString(new TimexProperty('XXXX-01-05')).should.equal('5th January'); - timexconvert.convertTimexToString(new TimexProperty('XXXX-02-05')).should.equal('5th Februrary'); - timexconvert.convertTimexToString(new TimexProperty('XXXX-03-05')).should.equal('5th March'); - timexconvert.convertTimexToString(new TimexProperty('XXXX-04-05')).should.equal('5th April'); - timexconvert.convertTimexToString(new TimexProperty('XXXX-05-05')).should.equal('5th May'); - timexconvert.convertTimexToString(new TimexProperty('XXXX-06-05')).should.equal('5th June'); - timexconvert.convertTimexToString(new TimexProperty('XXXX-07-05')).should.equal('5th July'); - timexconvert.convertTimexToString(new TimexProperty('XXXX-08-05')).should.equal('5th August'); - timexconvert.convertTimexToString(new TimexProperty('XXXX-09-05')).should.equal('5th September'); - timexconvert.convertTimexToString(new TimexProperty('XXXX-10-05')).should.equal('5th October'); - timexconvert.convertTimexToString(new TimexProperty('XXXX-11-05')).should.equal('5th November'); - timexconvert.convertTimexToString(new TimexProperty('XXXX-12-05')).should.equal('5th December'); - }); - it('month and dayOfMonth with correct abbreviation', () => { - timexconvert.convertTimexToString(new TimexProperty('XXXX-06-01')).should.equal('1st June'); - timexconvert.convertTimexToString(new TimexProperty('XXXX-06-02')).should.equal('2nd June'); - timexconvert.convertTimexToString(new TimexProperty('XXXX-06-03')).should.equal('3rd June'); - timexconvert.convertTimexToString(new TimexProperty('XXXX-06-04')).should.equal('4th June'); - }); - it('dayOfWeek', () => { - timexconvert.convertTimexToString(new TimexProperty('XXXX-WXX-1')).should.equal('Monday'); - timexconvert.convertTimexToString(new TimexProperty('XXXX-WXX-2')).should.equal('Tuesday'); - timexconvert.convertTimexToString(new TimexProperty('XXXX-WXX-3')).should.equal('Wednesday'); - timexconvert.convertTimexToString(new TimexProperty('XXXX-WXX-4')).should.equal('Thursday'); - timexconvert.convertTimexToString(new TimexProperty('XXXX-WXX-5')).should.equal('Friday'); - timexconvert.convertTimexToString(new TimexProperty('XXXX-WXX-6')).should.equal('Saturday'); - timexconvert.convertTimexToString(new TimexProperty('XXXX-WXX-7')).should.equal('Sunday'); - }); - }); - describe('time', () => { - it('hours, minutes and seconds', () => { - timexconvert.convertTimexToString(new TimexProperty('T17:30:05')).should.equal('5:30:05PM'); - timexconvert.convertTimexToString(new TimexProperty('T02:30:30')).should.equal('2:30:30AM'); - timexconvert.convertTimexToString(new TimexProperty('T00:30:30')).should.equal('12:30:30AM'); - timexconvert.convertTimexToString(new TimexProperty('T12:30:30')).should.equal('12:30:30PM'); - }); - it('hours and minutes', () => { - timexconvert.convertTimexToString(new TimexProperty('T17:30')).should.equal('5:30PM'); - timexconvert.convertTimexToString(new TimexProperty('T17:00')).should.equal('5PM'); - timexconvert.convertTimexToString(new TimexProperty('T01:30')).should.equal('1:30AM'); - timexconvert.convertTimexToString(new TimexProperty('T01:00')).should.equal('1AM'); - }); - it('hours', () => { - timexconvert.convertTimexToString(new TimexProperty('T00')).should.equal('midnight'); - timexconvert.convertTimexToString(new TimexProperty('T01')).should.equal('1AM'); - timexconvert.convertTimexToString(new TimexProperty('T02')).should.equal('2AM'); - timexconvert.convertTimexToString(new TimexProperty('T03')).should.equal('3AM'); - timexconvert.convertTimexToString(new TimexProperty('T04')).should.equal('4AM'); - timexconvert.convertTimexToString(new TimexProperty('T12')).should.equal('midday'); - timexconvert.convertTimexToString(new TimexProperty('T13')).should.equal('1PM'); - timexconvert.convertTimexToString(new TimexProperty('T14')).should.equal('2PM'); - timexconvert.convertTimexToString(new TimexProperty('T23')).should.equal('11PM'); - }); - }); - describe('now', () => { - it('now', () => { - timexconvert.convertTimexToString(new TimexProperty('PRESENT_REF')).should.equal('now'); - }); - }); - describe('datetime', () => { - it('full datetime', () => { - timexconvert.convertTimexToString(new TimexProperty('1984-01-03T18:30:45')).should.equal('6:30:45PM 3rd January 1984'); - timexconvert.convertTimexToString(new TimexProperty('2000-01-01T00')).should.equal('midnight 1st January 2000'); - timexconvert.convertTimexToString(new TimexProperty('1967-05-29T19:30:00')).should.equal('7:30PM 29th May 1967'); - }); - it('paricular time on particular day of week', () => { - timexconvert.convertTimexToString(new TimexProperty('XXXX-WXX-3T16')).should.equal('4PM Wednesday'); - timexconvert.convertTimexToString(new TimexProperty('XXXX-WXX-5T18:30')).should.equal('6:30PM Friday'); - }); - }); - describe('daterange', () => { - it('year', () => { - timexconvert.convertTimexToString(new TimexProperty('2016')).should.equal('2016'); - }); - it('year season (e.g. "summer of 1999")', () => { - timexconvert.convertTimexToString(new TimexProperty('1999-SU')).should.equal('summer 1999'); - }); - it('season', () => { - timexconvert.convertTimexToString(new TimexProperty('SU')).should.equal('summer'); - timexconvert.convertTimexToString(new TimexProperty('WI')).should.equal('winter'); - }); - it('month', () => { - timexconvert.convertTimexToString(new TimexProperty('XXXX-01')).should.equal('January'); - timexconvert.convertTimexToString(new TimexProperty('XXXX-05')).should.equal('May'); - timexconvert.convertTimexToString(new TimexProperty('XXXX-12')).should.equal('December'); - }); - it('month and year', () => { - timexconvert.convertTimexToString(new TimexProperty('2018-05')).should.equal('May 2018'); - }); - it('week of month', () => { - timexconvert.convertTimexToString(new TimexProperty('XXXX-01-W01')).should.equal('first week of January'); - timexconvert.convertTimexToString(new TimexProperty('XXXX-08-W03')).should.equal('third week of August'); - }); - }); - describe('TimeRange', () => { - it('part of the day (daytime, night, morning etc.)', () => { - timexconvert.convertTimexToString(new TimexProperty('TDT')).should.equal('daytime'); - timexconvert.convertTimexToString(new TimexProperty('TNI')).should.equal('night'); - timexconvert.convertTimexToString(new TimexProperty('TMO')).should.equal('morning'); - timexconvert.convertTimexToString(new TimexProperty('TAF')).should.equal('afternoon'); - timexconvert.convertTimexToString(new TimexProperty('TEV')).should.equal('evening'); - }); - }); - describe.skip('DateTimeRange', () => { - it('friday evening', () => { - timexconvert.convertTimexToString(new TimexProperty('XXXX-WXX-5TEV')).should.equal('Friday evening'); - }); - it('date and part of the day (morning, evening etc.)', () => { - timexconvert.convertTimexToString(new TimexProperty('2017-09-07TNI')).should.equal('7th September 2017 night'); - }); - it('last 5 minutes', () => { - // date + time + duration - const timex = new TimexProperty('(2017-09-08T21:19:29,2017-09-08T21:24:29,PT5M)'); - // TODO - }); - it('wednesday to saturday', () => { - // date + duration - const timex = new TimexProperty('(XXXX-WXX-3,XXXX-WXX-6,P3D)'); - // TODO - }); - }); - describe('Duration', () => { - it('years', () => { - timexconvert.convertTimexToString(new TimexProperty('P2Y')).should.equal('2 years'); - timexconvert.convertTimexToString(new TimexProperty('P1Y')).should.equal('1 year'); - }); - it('months', () => { - timexconvert.convertTimexToString(new TimexProperty('P4M')).should.equal('4 months'); - timexconvert.convertTimexToString(new TimexProperty('P1M')).should.equal('1 month'); - timexconvert.convertTimexToString(new TimexProperty('P0M')).should.equal('0 months'); - }); - it('weeks', () => { - timexconvert.convertTimexToString(new TimexProperty('P6W')).should.equal('6 weeks'); - timexconvert.convertTimexToString(new TimexProperty('P9.5W')).should.equal('9.5 weeks'); - }); - it('days', () => { - timexconvert.convertTimexToString(new TimexProperty('P5D')).should.equal('5 days'); - timexconvert.convertTimexToString(new TimexProperty('P1D')).should.equal('1 day'); - }); - it('hours', () => { - timexconvert.convertTimexToString(new TimexProperty('PT5H')).should.equal('5 hours'); - timexconvert.convertTimexToString(new TimexProperty('PT1H')).should.equal('1 hour'); - }); - it('minutes', () => { - timexconvert.convertTimexToString(new TimexProperty('PT30M')).should.equal('30 minutes'); - timexconvert.convertTimexToString(new TimexProperty('PT1M')).should.equal('1 minute'); - }); - it('seconds', () => { - timexconvert.convertTimexToString(new TimexProperty('PT45S')).should.equal('45 seconds'); - }); - }); - describe('Set', () => { - it('every 2 days', () => { - timexconvert.convertTimexSetToString(new TimexSet('P2D')).should.equal('every 2 days'); - }); - it('every week', () => { - timexconvert.convertTimexSetToString(new TimexSet('P1W')).should.equal('every week'); - }); - it('every october', () => { - timexconvert.convertTimexSetToString(new TimexSet('XXXX-10')).should.equal('every October'); - }); - it('every sunday', () => { - timexconvert.convertTimexSetToString(new TimexSet('XXXX-WXX-7')).should.equal('every Sunday'); - }); - it('every day', () => { - timexconvert.convertTimexSetToString(new TimexSet('P1D')).should.equal('every day'); - }); - it('every year', () => { - timexconvert.convertTimexSetToString(new TimexSet('P1Y')).should.equal('every year'); - }); - it('every spring', () => { - timexconvert.convertTimexSetToString(new TimexSet('SP')).should.equal('every spring'); - }); - it('each winter', () => { - timexconvert.convertTimexSetToString(new TimexSet('WI')).should.equal('every winter'); - }); - it('every evening', () => { - timexconvert.convertTimexSetToString(new TimexSet('TEV')).should.equal('every evening'); - }); - }); - }); - }); -}); diff --git a/JavaScript/packages/datatypes-date-time/test/timexCreator.spec.js b/JavaScript/packages/datatypes-date-time/test/timexCreator.spec.js deleted file mode 100644 index ec0803c1f5..0000000000 --- a/JavaScript/packages/datatypes-date-time/test/timexCreator.spec.js +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -const chai = require('chai'); -const timexCreator = require('../src/timexCreator.js'); -const timexFormat = require('../src/timexFormat.js'); -const timexDateHelpers = require('../src/timexDateHelpers.js'); -const { TimexProperty } = require('../index.js'); - -const assert = chai.assert; -const expect = chai.expect; -chai.should(); - -describe('No Network', () => { - describe('Datatypes', () => { - describe('Timex creator', () => { - describe('timex creator', () => { - const today = new Date(2017, 9, 5); - it('today', () => { - const d = new Date(); - const expected = timexFormat.format({ year: d.getFullYear(), month: d.getMonth() + 1, dayOfMonth: d.getDate() }); - timexCreator.today().should.equal(expected); - }); - it('today(today)', () => { - timexCreator.today(today).should.equal('2017-10-05'); - }); - it('tomorrow', () => { - const d = new Date(); - d.setDate(d.getDate() + 1); - const expected = timexFormat.format({ year: d.getFullYear(), month: d.getMonth() + 1, dayOfMonth: d.getDate() }); - timexCreator.tomorrow().should.equal(expected); - }); - it('tomorrow(today)', () => { - timexCreator.tomorrow(today).should.equal('2017-10-06'); - }); - it('yesterday', () => { - const d = new Date(); - d.setDate(d.getDate() - 1); - const expected = timexFormat.format({ year: d.getFullYear(), month: d.getMonth() + 1, dayOfMonth: d.getDate() }); - timexCreator.yesterday().should.equal(expected); - }); - it('yesterday(today)', () => { - timexCreator.yesterday(today).should.equal('2017-10-04'); - }); - it('weekFromToday', () => { - const d = new Date(); - const expected = timexFormat.format({ year: d.getFullYear(), month: d.getMonth() + 1, dayOfMonth: d.getDate(), days: 7}); - timexCreator.weekFromToday().should.equal(expected); - }); - it('weekFromToday(today)', () => { - timexCreator.weekFromToday(today).should.equal('(2017-10-05,2017-10-12,P7D)'); - }); - it('weekBackFromToday', () => { - const d = new Date(); - d.setDate(d.getDate() - 7); - const expected = timexFormat.format({ year: d.getFullYear(), month: d.getMonth() + 1, dayOfMonth: d.getDate(), days: 7}); - timexCreator.weekBackFromToday().should.equal(expected); - }); - it('weekBackFromToday(today)', () => { - timexCreator.weekBackFromToday(today).should.equal('(2017-09-28,2017-10-05,P7D)'); - }); - it('nextWeek', () => { - const start = timexDateHelpers.dateOfNextDay(1, new Date()); - const expected = timexFormat.format(Object.assign(TimexProperty.fromDate(start), { days: 7 })); - timexCreator.nextWeek().should.equal(expected); - }); - it('nextWeek (today)', () => { - timexCreator.nextWeek(today).should.equal('(2017-10-09,2017-10-16,P7D)'); - }); - it('lastWeek', () => { - const start = timexDateHelpers.dateOfLastDay(1, new Date()); - start.setDate(start.getDate() - 7); - const expected = timexFormat.format(Object.assign(TimexProperty.fromDate(start), { days: 7 })); - timexCreator.lastWeek().should.equal(expected); - }); - it('lastWeek (today)', () => { - timexCreator.lastWeek(today).should.equal('(2017-09-25,2017-10-02,P7D)'); - }); - it('nextWeeksFromToday', () => { - const d = new Date(); - const expected = timexFormat.format({ year: d.getFullYear(), month: d.getMonth() + 1, dayOfMonth: d.getDate(), days: 14}); - timexCreator.nextWeeksFromToday(2).should.equal(expected); - }); - it('nextWeeksFromToday (today)', () => { - timexCreator.nextWeeksFromToday(2, today).should.equal('(2017-10-05,2017-10-19,P14D)'); - }); - }); - }); - }); -}); - diff --git a/JavaScript/packages/datatypes-date-time/test/timexDateHelpers.spec.js b/JavaScript/packages/datatypes-date-time/test/timexDateHelpers.spec.js deleted file mode 100644 index 9c69d91198..0000000000 --- a/JavaScript/packages/datatypes-date-time/test/timexDateHelpers.spec.js +++ /dev/null @@ -1,98 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -const chai = require('chai'); -const timexDateHelpers = require('../src/timexDateHelpers.js'); - -const assert = chai.assert; -const expect = chai.expect; -chai.should(); - -describe('No Network', () => { - describe('Datatypes', () => { - describe('Timex date helpers', () => { - it('tomorrow', () => { - timexDateHelpers.tomorrow(new Date(2016, 11, 31)).getTime().should.equal((new Date(2017, 0, 1)).getTime()); - timexDateHelpers.tomorrow(new Date(2017, 0, 1)).getTime().should.equal((new Date(2017, 0, 2)).getTime()); - timexDateHelpers.tomorrow(new Date(2017, 1, 28)).getTime().should.equal((new Date(2017, 2, 1)).getTime()); - timexDateHelpers.tomorrow(new Date(2016, 1, 28)).getTime().should.equal((new Date(2016, 1, 29)).getTime()); - }); - it('yesterday', () => { - timexDateHelpers.yesterday(new Date(2017, 0, 1)).getTime().should.equal((new Date(2016, 11, 31)).getTime()); - timexDateHelpers.yesterday(new Date(2017, 0, 2)).getTime().should.equal((new Date(2017, 0, 1)).getTime()); - timexDateHelpers.yesterday(new Date(2017, 2, 1)).getTime().should.equal((new Date(2017, 1, 28)).getTime()); - timexDateHelpers.yesterday(new Date(2016, 1, 29)).getTime().should.equal((new Date(2016, 1, 28)).getTime()); - }); - it('datePartEquals', () => { - timexDateHelpers.datePartEquals(new Date(2017, 4, 29), new Date(2017, 4, 29)).should.be.true; - timexDateHelpers.datePartEquals(new Date(2017, 4, 29, 19, 30, 0), new Date(2017, 4, 29)).should.be.true; - timexDateHelpers.datePartEquals(new Date(2017, 4, 29), new Date(2017, 10, 15)).should.be.false; - }); - it('isNextWeek', () => { - const today = new Date(2017, 8, 25); - timexDateHelpers.isNextWeek(new Date(2017, 9, 4), today).should.be.true; - timexDateHelpers.isNextWeek(new Date(2017, 8, 27), today).should.be.false; - timexDateHelpers.isNextWeek(today, today).should.be.false; - }); - it('isLastWeek', () => { - const today = new Date(2017, 8, 25); - timexDateHelpers.isLastWeek(new Date(2017, 8, 20), today).should.be.true; - timexDateHelpers.isLastWeek(new Date(2017, 8, 4), today).should.be.false; - timexDateHelpers.isLastWeek(today, today).should.be.false; - }); - it('weekOfyear', () => { - timexDateHelpers.weekOfYear(new Date(2017, 0, 1)).should.equal(1); - timexDateHelpers.weekOfYear(new Date(2017, 0, 2)).should.equal(2); - timexDateHelpers.weekOfYear(new Date(2017, 1, 23)).should.equal(9); - timexDateHelpers.weekOfYear(new Date(2017, 2, 15)).should.equal(12); - timexDateHelpers.weekOfYear(new Date(2017, 8, 25)).should.equal(40); - timexDateHelpers.weekOfYear(new Date(2017, 11, 31)).should.equal(53); - timexDateHelpers.weekOfYear(new Date(2018, 0, 1)).should.equal(1); - timexDateHelpers.weekOfYear(new Date(2018, 0, 2)).should.equal(1); - timexDateHelpers.weekOfYear(new Date(2018, 0, 7)).should.equal(1); - timexDateHelpers.weekOfYear(new Date(2018, 0, 8)).should.equal(2); - }); - it('invariance', () => { - const d = new Date(2017, 8, 25); - const before = d.getTime(); - timexDateHelpers.tomorrow(d); - timexDateHelpers.yesterday(d); - timexDateHelpers.datePartEquals(new Date(), d); - timexDateHelpers.datePartEquals(d, new Date()); - timexDateHelpers.isNextWeek(d, new Date()); - timexDateHelpers.isNextWeek(new Date(), d); - timexDateHelpers.isLastWeek(new Date(), d); - timexDateHelpers.weekOfYear(d); - const after = d.getTime(); - expect(after).to.equal(before); - }); - it('dateOfLastDay: Friday last week', () => { - const day = 5; - const date = new Date(2017, 8, 28); - timexDateHelpers.datePartEquals(timexDateHelpers.dateOfLastDay(day, date), new Date(2017, 8, 22)).should.be.true; - }); - it('dateOfNextDay: Wednesday next week', () => { - const day = 3; - const date = new Date(2017, 8, 28); - timexDateHelpers.datePartEquals(timexDateHelpers.dateOfNextDay(day, date), new Date(2017, 9, 4)).should.be.true; - }); - it('dateOfNextDay: today', () => { - const day = 4; - const date = new Date(2017, 8, 28); - timexDateHelpers.datePartEquals(timexDateHelpers.dateOfNextDay(day, date), date).should.be.false; - }); - it('datesMatchingDay', () => { - const day = 4; - const start = new Date(2017, 2, 1); - const end = new Date(2017, 3, 1); - const result = timexDateHelpers.datesMatchingDay(day, start, end); - result.should.be.an('array').of.length(5); - timexDateHelpers.datePartEquals(result[0], new Date(2017, 2, 2)).should.be.true; - timexDateHelpers.datePartEquals(result[1], new Date(2017, 2, 9)).should.be.true; - timexDateHelpers.datePartEquals(result[2], new Date(2017, 2, 16)).should.be.true; - timexDateHelpers.datePartEquals(result[3], new Date(2017, 2, 23)).should.be.true; - timexDateHelpers.datePartEquals(result[4], new Date(2017, 2, 30)).should.be.true; - }); - }); - }); -}); diff --git a/JavaScript/packages/datatypes-date-time/test/timexFormat.spec.js b/JavaScript/packages/datatypes-date-time/test/timexFormat.spec.js deleted file mode 100644 index 16cb78b651..0000000000 --- a/JavaScript/packages/datatypes-date-time/test/timexFormat.spec.js +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -const chai = require('chai'); -const timexFormat = require('../src/timexFormat.js'); -const { TimexProperty } = require('../index.js'); - -const assert = chai.assert; -const expect = chai.expect; -chai.should(); - -describe('No Network', () => { - describe('Datatypes', () => { - describe('Timex format', () => { - describe('timexFormat helper function', () => { - it('date', () => { - timexFormat.format({ year: 2017, month: 9, dayOfMonth: 27 }).should.equal('2017-09-27'); - timexFormat.format({ dayOfWeek: 3 }).should.equal('XXXX-WXX-3'); - timexFormat.format({ month: 12, dayOfMonth: 5 }).should.equal('XXXX-12-05'); - }); - it('time', () => { - timexFormat.format({ hour: 17, minute: 30, second: 45 }).should.equal('T17:30:45'); - timexFormat.format({ hour: 5, minute: 6, second: 7 }).should.equal('T05:06:07'); - timexFormat.format({ hour: 17, minute: 30, second: 0 }).should.equal('T17:30'); - timexFormat.format({ hour: 23, minute: 0, second: 0 }).should.equal('T23'); - }); - it('duration', () => { - timexFormat.format({ years: 50 }).should.equal('P50Y'); - timexFormat.format({ months: 6 }).should.equal('P6M'); - timexFormat.format({ weeks: 3 }).should.equal('P3W'); - timexFormat.format({ days: 5 }).should.equal('P5D'); - timexFormat.format({ hours: 16 }).should.equal('PT16H'); - timexFormat.format({ minutes: 32 }).should.equal('PT32M'); - timexFormat.format({ seconds: 20 }).should.equal('PT20S'); - }); - it('present', () => { - timexFormat.format({ now: true }).should.equal('PRESENT_REF'); - }); - it('datetime', () => { - timexFormat.format({ dayOfWeek: 3, hour: 4, minute: 0, second: 0 }).should.equal('XXXX-WXX-3T04'); - timexFormat.format({ year: 2017, month: 9, dayOfMonth: 27, hour: 11, minute: 41, second: 30 }).should.equal('2017-09-27T11:41:30'); - }); - it('daterange', () => { - timexFormat.format({ year: 2017 }).should.equal('2017'); - timexFormat.format({ season: 'SU' }).should.equal('SU'); - timexFormat.format({ year: 2017, season: 'WI' }).should.equal('2017-WI'); - timexFormat.format({ year: 2017, month: 9 }).should.equal('2017-09'); - timexFormat.format({ year: 2017, weekOfYear: 37 }).should.equal('2017-W37'); - timexFormat.format({ year: 2017, weekOfYear: 37, weekend: true }).should.equal('2017-W37-WE'); - timexFormat.format({ month: 5 }).should.equal('XXXX-05'); - }); - it('timerange', () => { - timexFormat.format({ partOfDay: 'EV' }).should.equal('TEV'); - }); - it('datetimerange', () => { - timexFormat.format({ year: 2017, month: 9, dayOfMonth: 27, partOfDay: 'EV' }).should.equal('2017-09-27TEV'); - }); - }); - }); - }); -}); diff --git a/JavaScript/packages/datatypes-date-time/test/timexHelpers.spec.js b/JavaScript/packages/datatypes-date-time/test/timexHelpers.spec.js deleted file mode 100644 index 68a76513db..0000000000 --- a/JavaScript/packages/datatypes-date-time/test/timexHelpers.spec.js +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -const chai = require('chai'); -const timexHelpers = require('../src/timexHelpers.js'); -const { Time, TimexProperty } = require('../index.js'); - -const assert = chai.assert; -const expect = chai.expect; -chai.should(); - -describe('No Network', () => { - describe('Datatypes', () => { - describe('Timex helpers', () => { - describe('Timex expand to range of start and end Timex', () => { - it('expandDateTimeRange (short range)', () => { - const timex = new TimexProperty('(2017-09-27,2017-09-29,P2D)'); - const range = timexHelpers.expandDateTimeRange(timex); - (new TimexProperty(range.start)).timex.should.equal('2017-09-27'); - (new TimexProperty(range.end)).timex.should.equal('2017-09-29'); - }); - it('expandDateTimeRange (long range)', () => { - const timex = new TimexProperty('(2006-01-01,2008-06-01,P882D)'); - const range = timexHelpers.expandDateTimeRange(timex); - (new TimexProperty(range.start)).timex.should.equal('2006-01-01'); - (new TimexProperty(range.end)).timex.should.equal('2008-06-01'); - }); - it('expandDateTimeRange (including time)', () => { - const timex = new TimexProperty('(2017-10-10T16:02:04,2017-10-10T16:07:04,PT5M)'); - const range = timexHelpers.expandDateTimeRange(timex); - (new TimexProperty(range.start)).timex.should.equal('2017-10-10T16:02:04'); - (new TimexProperty(range.end)).timex.should.equal('2017-10-10T16:07:04'); - }); - it('expandDateTimeRange (month)', () => { - const timex = new TimexProperty('2017-05'); - const range = timexHelpers.expandDateTimeRange(timex); - (new TimexProperty(range.start)).timex.should.equal('2017-05-01'); - (new TimexProperty(range.end)).timex.should.equal('2017-06-01'); - }); - it('expandDateTimeRange (year)', () => { - const timex = new TimexProperty('1999'); - const range = timexHelpers.expandDateTimeRange(timex); - (new TimexProperty(range.start)).timex.should.equal('1999-01-01'); - (new TimexProperty(range.end)).timex.should.equal('2000-01-01'); - }); - it('expandTimeRange', () => { - const timex = new TimexProperty('(T14,T16,PT2H)'); - const range = timexHelpers.expandTimeRange(timex); - (new TimexProperty(range.start)).timex.should.equal('T14'); - (new TimexProperty(range.end)).timex.should.equal('T16'); - }); - }); - describe('Timex expand to range of Date or Time objects', () => { - it('dateRangeFromTimex', () => { - const timex = new TimexProperty('(2017-09-27,2017-09-29,P2D)'); - const range = timexHelpers.dateRangeFromTimex(timex); - range.start.getTime().should.equal(new Date(2017,8,27).getTime()); - range.end.getTime().should.equal(new Date(2017,8,29).getTime()); - }); - it('timeRangeFromTimex', () => { - const timex = new TimexProperty('(T14,T16,PT2H)'); - const range = timexHelpers.timeRangeFromTimex(timex); - range.start.getTime().should.equal(new Time(14, 0, 0).getTime()); - range.end.getTime().should.equal(new Time(16, 0, 0).getTime()); - }); - }); - describe('Timex convert to Date or Time objects', () => { - it('dateFromTimex', () => { - const timex = new TimexProperty('2017-09-27'); - const date = timexHelpers.dateFromTimex(timex); - date.getTime().should.equal(new Date(2017,8,27).getTime()); - }); - it('timeFromTimex', () => { - const timex = new TimexProperty('T00:05:00'); - const time = timexHelpers.timeFromTimex(timex); - time.getTime().should.equal(new Time(0, 5, 0).getTime()); - }); - }); - }); - }); -}); diff --git a/JavaScript/packages/datatypes-date-time/test/timexIntegrated.spec.js b/JavaScript/packages/datatypes-date-time/test/timexIntegrated.spec.js deleted file mode 100644 index 7fc3c9dc1d..0000000000 --- a/JavaScript/packages/datatypes-date-time/test/timexIntegrated.spec.js +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -const chai = require('chai'); - -const { TimexProperty, resolver, creator } = require('../index.js'); - -const assert = chai.assert; -const expect = chai.expect; -chai.should(); - -describe('No Network', () => { - describe('Datatypes', () => { - describe('Timex integrate resolution with constants and conversion', () => { - describe('with constants', () => { - const today = new Date(2017, 9, 5); - it('day of week constrained by next week in the evening', () => { - const constraints = [ creator.weekFromToday(today), creator.evening ]; - const resolutions = resolver.evaluate(['XXXX-WXX-3T04', 'XXXX-WXX-3T16'], constraints); - resolutions.map(t => t.timex).should.be.an('array').lengthOf(1).members(['2017-10-11T16']); - const text = resolutions[0].toNaturalLanguage(today); - text.should.equal('next Wednesday 4PM'); - }); - }); - }); - describe('Timex integrate resolution with incremental updates', () => { - describe('date + year (daterange) + time (time)', () => { - const today = new Date(2017, 9, 5); - it('day of week constrained by next year and adding a specific time', () => { - const constraints = [ new TimexProperty('T17:00:00'), new TimexProperty('2018') ]; - const resolutions = resolver.evaluate(['XXXX-03-15'], constraints); - resolutions.map(t => t.timex).should.be.an('array').lengthOf(1).members(['2018-03-15T17']); - const text = resolutions[0].toNaturalLanguage(today); - text.should.equal('15th March 2018 5PM'); - }); - }); - }); - }); -}); diff --git a/JavaScript/packages/datatypes-date-time/test/timexLuis.spec.js b/JavaScript/packages/datatypes-date-time/test/timexLuis.spec.js deleted file mode 100644 index 87292e06ad..0000000000 --- a/JavaScript/packages/datatypes-date-time/test/timexLuis.spec.js +++ /dev/null @@ -1,144 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -const chai = require('chai'); -const chaiAsPromised = require('chai-as-promised'); - -const https = require('https'); -const querystring = require('querystring'); - -const { TimexProperty, resolver, creator } = require('../index.js'); - -const assert = chai.assert; -const expect = chai.expect; - -chai.use(chaiAsPromised); -chai.should(); - -const callLUIS = function (utterance) { - return new Promise(function(resolve, reject) { - - const currentDate = new Date(); - const timezoneOffset = currentDate.getTimezoneOffset() / 60; - - const args = { - 'subscription-key': 'SUBSCRIPTION-KEY', - verbose: true, - timezoneOffset: timezoneOffset, - q: utterance - }; - - // this is a LUIS model that recognizes a single datetimeV2 entity - const appId = 'APPLICATION-KEY'; - let url = 'https://westus.api.cognitive.microsoft.com/luis/v2.0/apps/'; - url += appId; - url += '?'; - url += querystring.stringify(args); - - const removeDuplicates = function (array) { - var seen = new Set(); - return array.filter(item => { return seen.has(item) ? false : seen.add(item); }); - }; - - https.get(url, (res) => { - if (res.statusCode !== 200) { - reject(`http status code ${res.statusCode}`); - } - else { - res.setEncoding('utf8'); - let rawData = ''; - res.on('data', (chunk) => { rawData += chunk; }); - res.on('end', () => { - try { - const parsedData = JSON.parse(rawData); - // we only care about the distinct TIMEX fields in the resolution - // ...from them we can recreate everything else - const result = []; - for (const entity of parsedData.entities) { - result.push({ - entity: entity.entity, - type: entity.type, - timex: removeDuplicates(entity.resolution.values.map((v) => v.timex)) - }); - } - resolve(result); - } catch (e) { - reject(e.message); - } - }); - } - }); - }); -}; - -describe('With LUIS', function () { - this.timeout(10000); - afterEach(function (done) { setTimeout(done, 300); }); - describe('Datatypes', function () { - describe.skip('Timex with LUIS', function () { - // note remember to return the Promise or alternatively use chai's .notify(done) - it('Calling LUIS and getting back a Timex (verify against next week)', function () { - const today = new Date(); - // first ask LUIS to understand this... - return callLUIS('Wednesday 4 OClock') - .then(function(result) { - const entity = result[0]; - // secondly that was ambiguous (in both date and time aspects) so we will resolve further... - // - here we are using a single date constraint and a single time constraint - const constraints = [ creator.nextWeek(today), creator.evening ]; - const resolutions = resolver.evaluate(entity.timex, constraints); - // in this particular case we expected a single solution with these constraints - resolutions.should.be.an('array').lengthOf(1); - // now we have a resolution we can pretty-print it to natural language - const text = resolutions[0].toNaturalLanguage(today); - text.should.equal('next Wednesday 4PM'); - // and why not have LUIS take a crack at understand that... - return callLUIS(text); - }) - .then(function(result) { - // it should just return a TIMEX version of that concrete solution... - const entity = result[0]; - const timex = new TimexProperty(entity.timex[0]); - if (timex.types.has('datetime')) { - // which we can convert back into natural language again... - const text = timex.toNaturalLanguage(today); - return (text.toUpperCase() === entity.entity.toUpperCase()); - } - return Promise.resolve(false); - }) - .should.eventually.equal(true); - }); - it('Calling LUIS and getting back a Timex (verify against this week)', function () { - const today = new Date(); - // first ask LUIS to understand this... - return callLUIS('Wednesday 4 OClock') - .then(function(result) { - const entity = result[0]; - // secondly that was ambiguous (in both date and time aspects) so we will resolve further... - // - here we are using a single date constraint and a single time constraint - const constraints = [ creator.thisWeek(today), creator.evening ]; - const resolutions = resolver.evaluate(entity.timex, constraints); - // in this particular case we expected a single solution with these constraints - resolutions.should.be.an('array').lengthOf(1); - // now we have a resolution we can pretty-print it to natural language - const text = resolutions[0].toNaturalLanguage(today); - switch (today.getDay()) { - case 2: - text.should.equal('tomorrow 4PM'); - break; - case 3: - text.should.equal('today 4PM'); - break; - case 4: - text.should.equal('yesterday 4PM'); - break; - default: - text.should.equal('this Wednesday 4PM'); - break; - } - }) - .should.eventually.be.fulfilled; - }); - }); - }); -}); diff --git a/JavaScript/packages/datatypes-date-time/test/timexParsing.spec.js b/JavaScript/packages/datatypes-date-time/test/timexParsing.spec.js deleted file mode 100644 index b3b6070bd9..0000000000 --- a/JavaScript/packages/datatypes-date-time/test/timexParsing.spec.js +++ /dev/null @@ -1,968 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -const chai = require('chai'); - -const { TimexProperty, TimexSet } = require('../index.js'); - -const assert = chai.assert; -const expect = chai.expect; -chai.should(); - -describe('No Network', () => { - describe('Datatypes', () => { - describe('Timex parsing', () => { - describe('date', () => { - it('complete date', () => { - const timex = new TimexProperty('2017-05-29'); - timex.should.have.property('types').that.is.a('Set').that.has.keys('definite', 'date'); - timex.should.have.property('year', 2017); - timex.should.have.property('month', 5); - timex.should.have.property('dayOfMonth', 29); - timex.should.not.have.property('dayOfWeek'); - timex.should.not.have.property('weekOfYear'); - timex.should.not.have.property('weekOfMonth'); - timex.should.not.have.property('season'); - timex.should.not.have.property('hour'); - timex.should.not.have.property('minute'); - timex.should.not.have.property('second'); - timex.should.not.have.property('weekend'); - timex.should.not.have.property('partOfDay'); - timex.should.not.have.property('years'); - timex.should.not.have.property('months'); - timex.should.not.have.property('weeks'); - timex.should.not.have.property('days'); - timex.should.not.have.property('hours'); - timex.should.not.have.property('minutes'); - timex.should.not.have.property('seconds'); - timex.should.not.have.property('now'); - }); - it('month and dayOfMonth', () => { - const timex = new TimexProperty('XXXX-12-05'); - timex.should.have.property('types').that.is.a('Set').that.has.keys('date'); - timex.should.not.have.property('year'); - timex.should.have.property('month', 12); - timex.should.have.property('dayOfMonth', 5); - timex.should.not.have.property('dayOfWeek'); - timex.should.not.have.property('weekOfYear'); - timex.should.not.have.property('weekOfMonth'); - timex.should.not.have.property('season'); - timex.should.not.have.property('hour'); - timex.should.not.have.property('minute'); - timex.should.not.have.property('second'); - timex.should.not.have.property('weekend'); - timex.should.not.have.property('partOfDay'); - timex.should.not.have.property('years'); - timex.should.not.have.property('months'); - timex.should.not.have.property('weeks'); - timex.should.not.have.property('days'); - timex.should.not.have.property('hours'); - timex.should.not.have.property('minutes'); - timex.should.not.have.property('seconds'); - timex.should.not.have.property('now'); - }); - it('dayOfWeek', () => { - const timex = new TimexProperty('XXXX-WXX-3'); - timex.should.have.property('types').that.is.a('Set').that.has.keys('date'); - timex.should.not.have.property('year'); - timex.should.not.have.property('month'); - timex.should.not.have.property('dayOfMonth'); - timex.should.have.property('dayOfWeek', 3); - timex.should.not.have.property('weekOfYear'); - timex.should.not.have.property('weekOfMonth'); - timex.should.not.have.property('season'); - timex.should.not.have.property('hour'); - timex.should.not.have.property('minute'); - timex.should.not.have.property('second'); - timex.should.not.have.property('weekend'); - timex.should.not.have.property('partOfDay'); - timex.should.not.have.property('years'); - timex.should.not.have.property('months'); - timex.should.not.have.property('weeks'); - timex.should.not.have.property('days'); - timex.should.not.have.property('hours'); - timex.should.not.have.property('minutes'); - timex.should.not.have.property('seconds'); - timex.should.not.have.property('now'); - }); - }); - describe('time', () => { - it('hours, minutes and seconds', () => { - const timex = new TimexProperty('T17:30:05'); - timex.should.have.property('types').that.is.a('Set').that.has.keys('time'); - timex.should.not.have.property('year'); - timex.should.not.have.property('month'); - timex.should.not.have.property('dayOfMonth'); - timex.should.not.have.property('dayOfWeek'); - timex.should.not.have.property('weekOfYear'); - timex.should.not.have.property('weekOfMonth'); - timex.should.not.have.property('season'); - timex.should.have.property('hour', 17); - timex.should.have.property('minute', 30); - timex.should.have.property('second', 5); - timex.should.not.have.property('weekend'); - timex.should.not.have.property('partOfDay'); - timex.should.not.have.property('years'); - timex.should.not.have.property('months'); - timex.should.not.have.property('weeks'); - timex.should.not.have.property('days'); - timex.should.not.have.property('hours'); - timex.should.not.have.property('minutes'); - timex.should.not.have.property('seconds'); - timex.should.not.have.property('now'); - }); - it('hours and minutes', () => { - const timex = new TimexProperty('T17:30'); - timex.should.have.property('types').that.is.a('Set').that.has.keys('time'); - timex.should.not.have.property('year'); - timex.should.not.have.property('month'); - timex.should.not.have.property('dayOfMonth'); - timex.should.not.have.property('dayOfWeek'); - timex.should.not.have.property('weekOfYear'); - timex.should.not.have.property('weekOfMonth'); - timex.should.not.have.property('season'); - timex.should.have.property('hour', 17); - timex.should.have.property('minute', 30); - timex.should.have.property('second', 0); - timex.should.not.have.property('weekend'); - timex.should.not.have.property('partOfDay'); - timex.should.not.have.property('years'); - timex.should.not.have.property('months'); - timex.should.not.have.property('weeks'); - timex.should.not.have.property('days'); - timex.should.not.have.property('hours'); - timex.should.not.have.property('minutes'); - timex.should.not.have.property('seconds'); - timex.should.not.have.property('now'); - }); - it('hours', () => { - const timex = new TimexProperty('T17'); - timex.should.have.property('types').that.is.a('Set').that.has.keys('time'); - timex.should.not.have.property('year'); - timex.should.not.have.property('month'); - timex.should.not.have.property('dayOfMonth'); - timex.should.not.have.property('dayOfWeek'); - timex.should.not.have.property('weekOfYear'); - timex.should.not.have.property('weekOfMonth'); - timex.should.not.have.property('season'); - timex.should.have.property('hour', 17); - timex.should.have.property('minute', 0); - timex.should.have.property('second', 0); - timex.should.not.have.property('weekend'); - timex.should.not.have.property('partOfDay'); - timex.should.not.have.property('years'); - timex.should.not.have.property('months'); - timex.should.not.have.property('weeks'); - timex.should.not.have.property('days'); - timex.should.not.have.property('hours'); - timex.should.not.have.property('minutes'); - timex.should.not.have.property('seconds'); - timex.should.not.have.property('now'); - }); - }); - describe('datetime', () => { - it('now', () => { - const timex = new TimexProperty('PRESENT_REF'); - timex.should.have.property('types').that.is.a('Set').that.has.keys('present', 'datetime', 'date', 'time'); - timex.should.not.have.property('year'); - timex.should.not.have.property('month'); - timex.should.not.have.property('dayOfMonth'); - timex.should.not.have.property('dayOfWeek'); - timex.should.not.have.property('weekOfYear'); - timex.should.not.have.property('weekOfMonth'); - timex.should.not.have.property('season'); - timex.should.not.have.property('hour'); - timex.should.not.have.property('minute'); - timex.should.not.have.property('second'); - timex.should.not.have.property('weekend'); - timex.should.not.have.property('partOfDay'); - timex.should.not.have.property('years'); - timex.should.not.have.property('months'); - timex.should.not.have.property('weeks'); - timex.should.not.have.property('days'); - timex.should.not.have.property('hours'); - timex.should.not.have.property('minutes'); - timex.should.not.have.property('seconds'); - timex.should.have.property('now', true); - }); - it('full datetime', () => { - const timex = new TimexProperty('1984-01-03T18:30:45'); - timex.should.have.property('types').that.is.a('Set').that.has.keys('definite', 'datetime', 'date', 'time'); - timex.should.have.property('year', 1984); - timex.should.have.property('month', 1); - timex.should.have.property('dayOfMonth', 3); - timex.should.not.have.property('dayOfWeek'); - timex.should.not.have.property('weekOfYear'); - timex.should.not.have.property('weekOfMonth'); - timex.should.not.have.property('season'); - timex.should.have.property('hour', 18); - timex.should.have.property('minute', 30); - timex.should.have.property('second', 45); - timex.should.not.have.property('weekend'); - timex.should.not.have.property('partOfDay'); - timex.should.not.have.property('years'); - timex.should.not.have.property('months'); - timex.should.not.have.property('weeks'); - timex.should.not.have.property('days'); - timex.should.not.have.property('hours'); - timex.should.not.have.property('minutes'); - timex.should.not.have.property('seconds'); - timex.should.not.have.property('now'); - }); - it('paricular time on particular day of week (e.g. "Wednesday 4pm")', () => { - const timex = new TimexProperty('XXXX-WXX-3T16'); - timex.should.have.property('types').that.is.a('Set').that.has.keys('datetime', 'date', 'time'); - timex.should.not.have.property('year'); - timex.should.not.have.property('month'); - timex.should.not.have.property('dayOfMonth'); - timex.should.have.property('dayOfWeek', 3); - timex.should.not.have.property('weekOfYear'); - timex.should.not.have.property('weekOfMonth'); - timex.should.not.have.property('season'); - timex.should.have.property('hour', 16); - timex.should.have.property('minute', 0); - timex.should.have.property('second', 0); - timex.should.not.have.property('weekend'); - timex.should.not.have.property('partOfDay'); - timex.should.not.have.property('years'); - timex.should.not.have.property('months'); - timex.should.not.have.property('weeks'); - timex.should.not.have.property('days'); - timex.should.not.have.property('hours'); - timex.should.not.have.property('minutes'); - timex.should.not.have.property('seconds'); - timex.should.not.have.property('now'); - }); - }); - describe('daterange', () => { - it('year', () => { - const timex = new TimexProperty('2016'); - timex.should.have.property('types').that.is.a('Set').that.has.keys('daterange'); - timex.should.have.property('year', 2016); - timex.should.not.have.property('month'); - timex.should.not.have.property('dayOfMonth'); - timex.should.not.have.property('dayOfWeek'); - timex.should.not.have.property('weekOfYear'); - timex.should.not.have.property('weekOfMonth'); - timex.should.not.have.property('season'); - timex.should.not.have.property('hour'); - timex.should.not.have.property('minute'); - timex.should.not.have.property('second'); - timex.should.not.have.property('weekend'); - timex.should.not.have.property('partOfDay'); - timex.should.not.have.property('years'); - timex.should.not.have.property('months'); - timex.should.not.have.property('weeks'); - timex.should.not.have.property('days'); - timex.should.not.have.property('hours'); - timex.should.not.have.property('minutes'); - timex.should.not.have.property('seconds'); - timex.should.not.have.property('now'); - }); - it('year season (e.g. "summer of 1999")', () => { - const timex = new TimexProperty('1999-SU'); - timex.should.have.property('types').that.is.a('Set').that.has.keys('daterange'); - timex.should.have.property('year', 1999); - timex.should.not.have.property('month'); - timex.should.not.have.property('dayOfMonth'); - timex.should.not.have.property('dayOfWeek'); - timex.should.not.have.property('weekOfYear'); - timex.should.not.have.property('weekOfMonth'); - timex.should.have.property('season', 'SU'); - timex.should.not.have.property('hour'); - timex.should.not.have.property('minute'); - timex.should.not.have.property('second'); - timex.should.not.have.property('weekend'); - timex.should.not.have.property('partOfDay'); - timex.should.not.have.property('years'); - timex.should.not.have.property('months'); - timex.should.not.have.property('weeks'); - timex.should.not.have.property('days'); - timex.should.not.have.property('hours'); - timex.should.not.have.property('minutes'); - timex.should.not.have.property('seconds'); - timex.should.not.have.property('now'); - }); - it('year and week', () => { - const timex = new TimexProperty('2017-W37'); - timex.should.have.property('types').that.is.a('Set').that.has.keys('daterange'); - timex.should.have.property('year', 2017); - timex.should.not.have.property('month'); - timex.should.not.have.property('dayOfMonth'); - timex.should.not.have.property('dayOfWeek'); - timex.should.have.property('weekOfYear', 37); - timex.should.not.have.property('weekOfMonth'); - timex.should.not.have.property('season'); - timex.should.not.have.property('hour'); - timex.should.not.have.property('minute'); - timex.should.not.have.property('second'); - timex.should.not.have.property('weekend'); - timex.should.not.have.property('partOfDay'); - timex.should.not.have.property('years'); - timex.should.not.have.property('months'); - timex.should.not.have.property('weeks'); - timex.should.not.have.property('days'); - timex.should.not.have.property('hours'); - timex.should.not.have.property('minutes'); - timex.should.not.have.property('seconds'); - timex.should.not.have.property('now'); - }); - it('season (e.g. "summer")', () => { - const timex = new TimexProperty('SU'); - timex.should.have.property('types').that.is.a('Set').that.has.keys('daterange'); - timex.should.not.have.property('year'); - timex.should.not.have.property('month'); - timex.should.not.have.property('dayOfMonth'); - timex.should.not.have.property('dayOfWeek'); - timex.should.not.have.property('weekOfYear'); - timex.should.not.have.property('weekOfMonth'); - timex.should.have.property('season', 'SU'); - timex.should.not.have.property('hour'); - timex.should.not.have.property('minute'); - timex.should.not.have.property('second'); - timex.should.not.have.property('weekend'); - timex.should.not.have.property('partOfDay'); - timex.should.not.have.property('years'); - timex.should.not.have.property('months'); - timex.should.not.have.property('weeks'); - timex.should.not.have.property('days'); - timex.should.not.have.property('hours'); - timex.should.not.have.property('minutes'); - timex.should.not.have.property('seconds'); - timex.should.not.have.property('now'); - }); - it('season (e.g. "winter")', () => { - const timex = new TimexProperty('WI'); - timex.should.have.property('types').that.is.a('Set').that.has.keys('daterange'); - timex.should.not.have.property('year'); - timex.should.not.have.property('month'); - timex.should.not.have.property('dayOfMonth'); - timex.should.not.have.property('dayOfWeek'); - timex.should.not.have.property('weekOfYear'); - timex.should.not.have.property('weekOfMonth'); - timex.should.have.property('season', 'WI'); - timex.should.not.have.property('hour'); - timex.should.not.have.property('minute'); - timex.should.not.have.property('second'); - timex.should.not.have.property('weekend'); - timex.should.not.have.property('partOfDay'); - timex.should.not.have.property('years'); - timex.should.not.have.property('months'); - timex.should.not.have.property('weeks'); - timex.should.not.have.property('days'); - timex.should.not.have.property('hours'); - timex.should.not.have.property('minutes'); - timex.should.not.have.property('seconds'); - timex.should.not.have.property('now'); - }); - it('year and weekend (e.g. "this weekend" at least today:-))', () => { - const timex = new TimexProperty('2017-W37-WE'); - timex.should.have.property('types').that.is.a('Set').that.has.keys('daterange'); - timex.should.have.property('year', 2017); - timex.should.not.have.property('month'); - timex.should.not.have.property('dayOfMonth'); - timex.should.not.have.property('dayOfWeek'); - timex.should.have.property('weekOfYear', 37); - timex.should.not.have.property('weekOfMonth'); - timex.should.not.have.property('season'); - timex.should.not.have.property('hour'); - timex.should.not.have.property('minute'); - timex.should.not.have.property('second'); - timex.should.have.property('weekend', true); - timex.should.not.have.property('partOfDay'); - timex.should.not.have.property('years'); - timex.should.not.have.property('months'); - timex.should.not.have.property('weeks'); - timex.should.not.have.property('days'); - timex.should.not.have.property('hours'); - timex.should.not.have.property('minutes'); - timex.should.not.have.property('seconds'); - timex.should.not.have.property('now'); - }); - it('month (e.g. "may")', () => { - const timex = new TimexProperty('XXXX-05'); - timex.should.have.property('types').that.is.a('Set').that.has.keys('daterange'); - timex.should.not.have.property('year'); - timex.should.have.property('month', 5); - timex.should.not.have.property('dayOfMonth'); - timex.should.not.have.property('dayOfWeek'); - timex.should.not.have.property('weekOfYear'); - timex.should.not.have.property('weekOfMonth'); - timex.should.not.have.property('season'); - timex.should.not.have.property('hour'); - timex.should.not.have.property('minute'); - timex.should.not.have.property('second'); - timex.should.not.have.property('weekend'); - timex.should.not.have.property('partOfDay'); - timex.should.not.have.property('years'); - timex.should.not.have.property('months'); - timex.should.not.have.property('weeks'); - timex.should.not.have.property('days'); - timex.should.not.have.property('hours'); - timex.should.not.have.property('minutes'); - timex.should.not.have.property('seconds'); - timex.should.not.have.property('now'); - }); - it('month (e.g. "July 2020")', () => { - const timex = new TimexProperty('2020-07'); - timex.should.have.property('types').that.is.a('Set').that.has.keys('daterange'); - timex.should.have.property('year', 2020); - timex.should.have.property('month', 7); - timex.should.not.have.property('dayOfMonth'); - timex.should.not.have.property('dayOfWeek'); - timex.should.not.have.property('weekOfYear'); - timex.should.not.have.property('weekOfMonth'); - timex.should.not.have.property('season'); - timex.should.not.have.property('hour'); - timex.should.not.have.property('minute'); - timex.should.not.have.property('second'); - timex.should.not.have.property('weekend'); - timex.should.not.have.property('partOfDay'); - timex.should.not.have.property('years'); - timex.should.not.have.property('months'); - timex.should.not.have.property('weeks'); - timex.should.not.have.property('days'); - timex.should.not.have.property('hours'); - timex.should.not.have.property('minutes'); - timex.should.not.have.property('seconds'); - timex.should.not.have.property('now'); - }); - it('week of month ("first week of january")', () => { - const timex = new TimexProperty('XXXX-01-W01'); - timex.should.have.property('types').that.is.a('Set').that.has.keys('daterange'); - timex.should.not.have.property('year'); - timex.should.have.property('month', 1); - timex.should.not.have.property('dayOfMonth'); - timex.should.not.have.property('dayOfWeek'); - timex.should.not.have.property('weekOfYear'); - timex.should.have.property('weekOfMonth', 1); - timex.should.not.have.property('season'); - timex.should.not.have.property('hour'); - timex.should.not.have.property('minute'); - timex.should.not.have.property('second'); - timex.should.not.have.property('weekend'); - timex.should.not.have.property('partOfDay'); - timex.should.not.have.property('years'); - timex.should.not.have.property('months'); - timex.should.not.have.property('weeks'); - timex.should.not.have.property('days'); - timex.should.not.have.property('hours'); - timex.should.not.have.property('minutes'); - timex.should.not.have.property('seconds'); - timex.should.not.have.property('now'); - }); - it('wednesday to saturday', () => { - const timex = new TimexProperty('(XXXX-WXX-3,XXXX-WXX-6,P3D)'); - timex.should.have.property('types').that.is.a('Set').that.has.keys('date', 'duration', 'daterange'); - timex.should.not.have.property('year'); - timex.should.not.have.property('month'); - timex.should.not.have.property('dayOfMonth'); - timex.should.have.property('dayOfWeek', 3); - timex.should.not.have.property('weekOfYear'); - timex.should.not.have.property('weekOfMonth'); - timex.should.not.have.property('season'); - timex.should.not.have.property('hour'); - timex.should.not.have.property('minute'); - timex.should.not.have.property('second'); - timex.should.not.have.property('weekend'); - timex.should.not.have.property('partOfDay'); - timex.should.not.have.property('years'); - timex.should.not.have.property('months'); - timex.should.not.have.property('weeks'); - timex.should.have.property('days', 3); - timex.should.not.have.property('hours'); - timex.should.not.have.property('minutes'); - timex.should.not.have.property('seconds'); - timex.should.not.have.property('now'); - }); - it('1 january to 5 august', () => { - const timex = new TimexProperty('(XXXX-01-01,XXXX-08-05,P216D)'); - timex.should.have.property('types').that.is.a('Set').that.has.keys('date', 'duration', 'daterange'); - timex.should.not.have.property('year'); - timex.should.have.property('month', 1); - timex.should.have.property('dayOfMonth', 1); - timex.should.not.have.property('dayOfWeek'); - timex.should.not.have.property('weekOfYear'); - timex.should.not.have.property('weekOfMonth'); - timex.should.not.have.property('season'); - timex.should.not.have.property('hour'); - timex.should.not.have.property('minute'); - timex.should.not.have.property('second'); - timex.should.not.have.property('weekend'); - timex.should.not.have.property('partOfDay'); - timex.should.not.have.property('years'); - timex.should.not.have.property('months'); - timex.should.not.have.property('weeks'); - timex.should.have.property('days', 216); - timex.should.not.have.property('hours'); - timex.should.not.have.property('minutes'); - timex.should.not.have.property('seconds'); - timex.should.not.have.property('now'); - }); - it('1 january 2015 to 5 august 2015', () => { - const timex = new TimexProperty('(2015-01-01,2015-08-05,P216D)'); - timex.should.have.property('types').that.is.a('Set').that.has.keys('definite', 'date', 'duration', 'daterange'); - timex.should.have.property('year', 2015); - timex.should.have.property('month', 1); - timex.should.have.property('dayOfMonth', 1); - timex.should.not.have.property('dayOfWeek'); - timex.should.not.have.property('weekOfYear'); - timex.should.not.have.property('weekOfMonth'); - timex.should.not.have.property('season'); - timex.should.not.have.property('hour'); - timex.should.not.have.property('minute'); - timex.should.not.have.property('second'); - timex.should.not.have.property('weekend'); - timex.should.not.have.property('partOfDay'); - timex.should.not.have.property('years'); - timex.should.not.have.property('months'); - timex.should.not.have.property('weeks'); - timex.should.have.property('days', 216); - timex.should.not.have.property('hours'); - timex.should.not.have.property('minutes'); - timex.should.not.have.property('seconds'); - timex.should.not.have.property('now'); - }); - }); - describe('TimeRange', () => { - it('daytime', () => { - const timex = new TimexProperty('TDT'); - timex.should.have.property('types').that.is.a('Set').that.has.keys('timerange'); - timex.should.not.have.property('year'); - timex.should.not.have.property('month'); - timex.should.not.have.property('dayOfMonth'); - timex.should.not.have.property('dayOfWeek'); - timex.should.not.have.property('weekOfYear'); - timex.should.not.have.property('weekOfMonth'); - timex.should.not.have.property('season'); - timex.should.not.have.property('hour'); - timex.should.not.have.property('minute'); - timex.should.not.have.property('second'); - timex.should.not.have.property('weekend'); - timex.should.have.property('partOfDay', 'DT'); - timex.should.not.have.property('years'); - timex.should.not.have.property('months'); - timex.should.not.have.property('weeks'); - timex.should.not.have.property('days'); - timex.should.not.have.property('hours'); - timex.should.not.have.property('minutes'); - timex.should.not.have.property('seconds'); - timex.should.not.have.property('now'); - }); - it('night', () => { - const timex = new TimexProperty('TNI'); - timex.should.have.property('types').that.is.a('Set').that.has.keys('timerange'); - timex.should.not.have.property('year'); - timex.should.not.have.property('month'); - timex.should.not.have.property('dayOfMonth'); - timex.should.not.have.property('dayOfWeek'); - timex.should.not.have.property('weekOfYear'); - timex.should.not.have.property('weekOfMonth'); - timex.should.not.have.property('season'); - timex.should.not.have.property('hour'); - timex.should.not.have.property('minute'); - timex.should.not.have.property('second'); - timex.should.not.have.property('weekend'); - timex.should.have.property('partOfDay', 'NI'); - timex.should.not.have.property('years'); - timex.should.not.have.property('months'); - timex.should.not.have.property('weeks'); - timex.should.not.have.property('days'); - timex.should.not.have.property('hours'); - timex.should.not.have.property('minutes'); - timex.should.not.have.property('seconds'); - timex.should.not.have.property('now'); - }); - it('morning', () => { - const timex = new TimexProperty('TMO'); - timex.should.have.property('types').that.is.a('Set').that.has.keys('timerange'); - timex.should.not.have.property('year'); - timex.should.not.have.property('month'); - timex.should.not.have.property('dayOfMonth'); - timex.should.not.have.property('dayOfWeek'); - timex.should.not.have.property('weekOfYear'); - timex.should.not.have.property('weekOfMonth'); - timex.should.not.have.property('season'); - timex.should.not.have.property('hour'); - timex.should.not.have.property('minute'); - timex.should.not.have.property('second'); - timex.should.not.have.property('weekend'); - timex.should.have.property('partOfDay', 'MO'); - timex.should.not.have.property('years'); - timex.should.not.have.property('months'); - timex.should.not.have.property('weeks'); - timex.should.not.have.property('days'); - timex.should.not.have.property('hours'); - timex.should.not.have.property('minutes'); - timex.should.not.have.property('seconds'); - timex.should.not.have.property('now'); - }); - it('afternoon', () => { - const timex = new TimexProperty('TAF'); - timex.should.have.property('types').that.is.a('Set').that.has.keys('timerange'); - timex.should.not.have.property('year'); - timex.should.not.have.property('month'); - timex.should.not.have.property('dayOfMonth'); - timex.should.not.have.property('dayOfWeek'); - timex.should.not.have.property('weekOfYear'); - timex.should.not.have.property('weekOfMonth'); - timex.should.not.have.property('season'); - timex.should.not.have.property('hour'); - timex.should.not.have.property('minute'); - timex.should.not.have.property('second'); - timex.should.not.have.property('weekend'); - timex.should.have.property('partOfDay', 'AF'); - timex.should.not.have.property('years'); - timex.should.not.have.property('months'); - timex.should.not.have.property('weeks'); - timex.should.not.have.property('days'); - timex.should.not.have.property('hours'); - timex.should.not.have.property('minutes'); - timex.should.not.have.property('seconds'); - timex.should.not.have.property('now'); - }); - it('evening', () => { - const timex = new TimexProperty('TEV'); - timex.should.have.property('types').that.is.a('Set').that.has.keys('timerange'); - timex.should.not.have.property('year'); - timex.should.not.have.property('month'); - timex.should.not.have.property('dayOfMonth'); - timex.should.not.have.property('dayOfWeek'); - timex.should.not.have.property('weekOfYear'); - timex.should.not.have.property('weekOfMonth'); - timex.should.not.have.property('season'); - timex.should.not.have.property('hour'); - timex.should.not.have.property('minute'); - timex.should.not.have.property('second'); - timex.should.not.have.property('weekend'); - timex.should.have.property('partOfDay', 'EV'); - timex.should.not.have.property('years'); - timex.should.not.have.property('months'); - timex.should.not.have.property('weeks'); - timex.should.not.have.property('days'); - timex.should.not.have.property('hours'); - timex.should.not.have.property('minutes'); - timex.should.not.have.property('seconds'); - timex.should.not.have.property('now'); - }); - it('4:30pm to 4:45pm', () => { - // BUG Luis actually incorrectly returns "(T16:30,T16:45,PT0H)" - const timex = new TimexProperty('(T16:30,T16:45,PT15M)'); - timex.should.have.property('types').that.is.a('Set').that.has.keys('time', 'duration', 'timerange'); - timex.should.not.have.property('year'); - timex.should.not.have.property('month'); - timex.should.not.have.property('dayOfMonth'); - timex.should.not.have.property('dayOfWeek'); - timex.should.not.have.property('weekOfYear'); - timex.should.not.have.property('weekOfMonth'); - timex.should.not.have.property('season'); - timex.should.have.property('hour', 16); - timex.should.have.property('minute', 30); - timex.should.have.property('second', 0); - timex.should.not.have.property('weekend'); - timex.should.not.have.property('partOfDay'); - timex.should.not.have.property('years'); - timex.should.not.have.property('months'); - timex.should.not.have.property('weeks'); - timex.should.not.have.property('days'); - timex.should.not.have.property('hours'); - timex.should.have.property('minutes', 15); - timex.should.not.have.property('seconds'); - timex.should.not.have.property('now'); - }); - }); - describe('DateTimeRange', () => { - it('friday evening', () => { - const timex = new TimexProperty('XXXX-WXX-5TEV'); - timex.should.have.property('types').that.is.a('Set').that.has.keys('date', 'timerange', 'datetimerange'); - timex.should.not.have.property('year'); - timex.should.not.have.property('month'); - timex.should.not.have.property('dayOfMonth'); - timex.should.have.property('dayOfWeek', 5); - timex.should.not.have.property('weekOfYear'); - timex.should.not.have.property('weekOfMonth'); - timex.should.not.have.property('season'); - timex.should.not.have.property('hour'); - timex.should.not.have.property('minute'); - timex.should.not.have.property('second'); - timex.should.not.have.property('weekend'); - timex.should.have.property('partOfDay', 'EV'); - timex.should.not.have.property('years'); - timex.should.not.have.property('months'); - timex.should.not.have.property('weeks'); - timex.should.not.have.property('days'); - timex.should.not.have.property('hours'); - timex.should.not.have.property('minutes'); - timex.should.not.have.property('seconds'); - timex.should.not.have.property('now'); - }); - it('last night', () => { - const timex = new TimexProperty('2017-09-07TNI'); - timex.should.have.property('types').that.is.a('Set').that.has.keys('definite', 'date', 'timerange', 'datetimerange'); - timex.should.have.property('year', 2017); - timex.should.have.property('month', 9); - timex.should.have.property('dayOfMonth', 7); - timex.should.not.have.property('dayOfWeek'); - timex.should.not.have.property('weekOfYear'); - timex.should.not.have.property('weekOfMonth'); - timex.should.not.have.property('season'); - timex.should.not.have.property('hour'); - timex.should.not.have.property('minute'); - timex.should.not.have.property('second'); - timex.should.not.have.property('weekend'); - timex.should.have.property('partOfDay', 'NI'); - timex.should.not.have.property('years'); - timex.should.not.have.property('months'); - timex.should.not.have.property('weeks'); - timex.should.not.have.property('days'); - timex.should.not.have.property('hours'); - timex.should.not.have.property('minutes'); - timex.should.not.have.property('seconds'); - timex.should.not.have.property('now'); - }); - it('last 5 minutes', () => { - const timex = new TimexProperty('(2017-09-08T21:19:29,2017-09-08T21:24:29,PT5M)'); - timex.should.have.property('types').that.is.a('Set').that.has.keys('date', 'time', 'datetime', 'duration', 'datetimerange', 'daterange', 'definite', 'timerange'); - timex.should.have.property('year', 2017); - timex.should.have.property('month', 9); - timex.should.have.property('dayOfMonth', 8); - timex.should.not.have.property('dayOfWeek'); - timex.should.not.have.property('weekOfYear'); - timex.should.not.have.property('weekOfMonth'); - timex.should.not.have.property('season'); - timex.should.have.property('hour', 21); - timex.should.have.property('minute', 19); - timex.should.have.property('second', 29); - timex.should.not.have.property('weekend'); - timex.should.not.have.property('partOfDay'); - timex.should.not.have.property('years'); - timex.should.not.have.property('months'); - timex.should.not.have.property('weeks'); - timex.should.not.have.property('days'); - timex.should.not.have.property('hours'); - timex.should.have.property('minutes', 5); - timex.should.not.have.property('seconds'); - timex.should.not.have.property('now'); - }); - it('4pm wednesday to 3pm saturday', () => { - const timex = new TimexProperty('(XXXX-WXX-3T16,XXXX-WXX-6T15,PT71H)'); - timex.should.have.property('types').that.is.a('Set').that.has.keys('date', 'time', 'datetime', 'daterange', 'timerange', 'datetimerange', 'duration'); - timex.should.not.have.property('year'); - timex.should.not.have.property('month'); - timex.should.not.have.property('dayOfMonth'); - timex.should.have.property('dayOfWeek', 3); - timex.should.not.have.property('weekOfYear'); - timex.should.not.have.property('weekOfMonth'); - timex.should.not.have.property('season'); - timex.should.have.property('hour', 16); - timex.should.have.property('minute', 0); - timex.should.have.property('second', 0); - timex.should.not.have.property('weekend'); - timex.should.not.have.property('partOfDay'); - timex.should.not.have.property('years'); - timex.should.not.have.property('months'); - timex.should.not.have.property('weeks'); - timex.should.not.have.property('days'); - timex.should.have.property('hours', 71); - timex.should.not.have.property('minutes'); - timex.should.not.have.property('seconds'); - timex.should.not.have.property('now'); - }); - }); - describe('Duration', () => { - it('years', () => { - const timex = new TimexProperty('P2Y'); - timex.should.have.property('types').that.is.a('Set').that.has.keys('duration'); - timex.should.not.have.property('year'); - timex.should.not.have.property('month'); - timex.should.not.have.property('dayOfMonth'); - timex.should.not.have.property('dayOfWeek'); - timex.should.not.have.property('weekOfYear'); - timex.should.not.have.property('weekOfMonth'); - timex.should.not.have.property('season'); - timex.should.not.have.property('hour'); - timex.should.not.have.property('minute'); - timex.should.not.have.property('second'); - timex.should.not.have.property('weekend'); - timex.should.not.have.property('partOfDay'); - timex.should.have.property('years', 2); - timex.should.not.have.property('months'); - timex.should.not.have.property('weeks'); - timex.should.not.have.property('days'); - timex.should.not.have.property('hours'); - timex.should.not.have.property('minutes'); - timex.should.not.have.property('seconds'); - timex.should.not.have.property('now'); - }); - it('months', () => { - const timex = new TimexProperty('P4M'); - timex.should.have.property('types').that.is.a('Set').that.has.keys('duration'); - timex.should.not.have.property('year'); - timex.should.not.have.property('month'); - timex.should.not.have.property('dayOfMonth'); - timex.should.not.have.property('dayOfWeek'); - timex.should.not.have.property('weekOfYear'); - timex.should.not.have.property('weekOfMonth'); - timex.should.not.have.property('season'); - timex.should.not.have.property('hour'); - timex.should.not.have.property('minute'); - timex.should.not.have.property('second'); - timex.should.not.have.property('weekend'); - timex.should.not.have.property('partOfDay'); - timex.should.not.have.property('years'); - timex.should.have.property('months', 4); - timex.should.not.have.property('weeks'); - timex.should.not.have.property('days'); - timex.should.not.have.property('hours'); - timex.should.not.have.property('minutes'); - timex.should.not.have.property('seconds'); - timex.should.not.have.property('now'); - }); - it('weeks', () => { - const timex = new TimexProperty('P6W'); - timex.should.have.property('types').that.is.a('Set').that.has.keys('duration'); - timex.should.not.have.property('year'); - timex.should.not.have.property('month'); - timex.should.not.have.property('dayOfMonth'); - timex.should.not.have.property('dayOfWeek'); - timex.should.not.have.property('weekOfYear'); - timex.should.not.have.property('weekOfMonth'); - timex.should.not.have.property('season'); - timex.should.not.have.property('hour'); - timex.should.not.have.property('minute'); - timex.should.not.have.property('second'); - timex.should.not.have.property('weekend'); - timex.should.not.have.property('partOfDay'); - timex.should.not.have.property('years'); - timex.should.not.have.property('months'); - timex.should.have.property('weeks', 6); - timex.should.not.have.property('days'); - timex.should.not.have.property('hours'); - timex.should.not.have.property('minutes'); - timex.should.not.have.property('seconds'); - timex.should.not.have.property('now'); - }); - it('weeks (floating point)', () => { - const timex = new TimexProperty('P2.5W'); - timex.should.have.property('types').that.is.a('Set').that.has.keys('duration'); - timex.should.not.have.property('year'); - timex.should.not.have.property('month'); - timex.should.not.have.property('dayOfMonth'); - timex.should.not.have.property('dayOfWeek'); - timex.should.not.have.property('weekOfYear'); - timex.should.not.have.property('weekOfMonth'); - timex.should.not.have.property('season'); - timex.should.not.have.property('hour'); - timex.should.not.have.property('minute'); - timex.should.not.have.property('second'); - timex.should.not.have.property('weekend'); - timex.should.not.have.property('partOfDay'); - timex.should.not.have.property('years'); - timex.should.not.have.property('months'); - timex.should.have.property('weeks', 2.5); - timex.should.not.have.property('days'); - timex.should.not.have.property('hours'); - timex.should.not.have.property('minutes'); - timex.should.not.have.property('seconds'); - timex.should.not.have.property('now'); - }); - it('days', () => { - const timex = new TimexProperty('P1D'); - timex.should.have.property('types').that.is.a('Set').that.has.keys('duration'); - timex.should.not.have.property('year'); - timex.should.not.have.property('month'); - timex.should.not.have.property('dayOfMonth'); - timex.should.not.have.property('dayOfWeek'); - timex.should.not.have.property('weekOfYear'); - timex.should.not.have.property('weekOfMonth'); - timex.should.not.have.property('season'); - timex.should.not.have.property('hour'); - timex.should.not.have.property('minute'); - timex.should.not.have.property('second'); - timex.should.not.have.property('weekend'); - timex.should.not.have.property('partOfDay'); - timex.should.not.have.property('years'); - timex.should.not.have.property('months'); - timex.should.not.have.property('weeks'); - timex.should.have.property('days', 1); - timex.should.not.have.property('hours'); - timex.should.not.have.property('minutes'); - timex.should.not.have.property('seconds'); - timex.should.not.have.property('now'); - }); - it('hours', () => { - const timex = new TimexProperty('PT5H'); - timex.should.have.property('types').that.is.a('Set').that.has.keys('duration'); - timex.should.not.have.property('year'); - timex.should.not.have.property('month'); - timex.should.not.have.property('dayOfMonth'); - timex.should.not.have.property('dayOfWeek'); - timex.should.not.have.property('weekOfYear'); - timex.should.not.have.property('weekOfMonth'); - timex.should.not.have.property('season'); - timex.should.not.have.property('hour'); - timex.should.not.have.property('minute'); - timex.should.not.have.property('second'); - timex.should.not.have.property('weekend'); - timex.should.not.have.property('partOfDay'); - timex.should.not.have.property('years'); - timex.should.not.have.property('months'); - timex.should.not.have.property('weeks'); - timex.should.not.have.property('days'); - timex.should.have.property('hours', 5); - timex.should.not.have.property('minutes'); - timex.should.not.have.property('seconds'); - timex.should.not.have.property('now'); - }); - it('minutes', () => { - const timex = new TimexProperty('PT30M'); - timex.should.have.property('types').that.is.a('Set').that.has.keys('duration'); - timex.should.not.have.property('year'); - timex.should.not.have.property('month'); - timex.should.not.have.property('dayOfMonth'); - timex.should.not.have.property('dayOfWeek'); - timex.should.not.have.property('weekOfYear'); - timex.should.not.have.property('weekOfMonth'); - timex.should.not.have.property('season'); - timex.should.not.have.property('hour'); - timex.should.not.have.property('minute'); - timex.should.not.have.property('second'); - timex.should.not.have.property('weekend'); - timex.should.not.have.property('partOfDay'); - timex.should.not.have.property('years'); - timex.should.not.have.property('months'); - timex.should.not.have.property('weeks'); - timex.should.not.have.property('days'); - timex.should.not.have.property('hours'); - timex.should.have.property('minutes', 30); - timex.should.not.have.property('seconds'); - timex.should.not.have.property('now'); - }); - it('seconds', () => { - const timex = new TimexProperty('PT45S'); - timex.should.have.property('types').that.is.a('Set').that.has.keys('duration'); - timex.should.not.have.property('year'); - timex.should.not.have.property('month'); - timex.should.not.have.property('dayOfMonth'); - timex.should.not.have.property('dayOfWeek'); - timex.should.not.have.property('weekOfYear'); - timex.should.not.have.property('weekOfMonth'); - timex.should.not.have.property('season'); - timex.should.not.have.property('hour'); - timex.should.not.have.property('minute'); - timex.should.not.have.property('second'); - timex.should.not.have.property('weekend'); - timex.should.not.have.property('partOfDay'); - timex.should.not.have.property('years'); - timex.should.not.have.property('months'); - timex.should.not.have.property('weeks'); - timex.should.not.have.property('days'); - timex.should.not.have.property('hours'); - timex.should.not.have.property('minutes'); - timex.should.have.property('seconds', 45); - timex.should.not.have.property('now'); - }); - }); - }); - }); -}); diff --git a/JavaScript/packages/datatypes-date-time/test/timexProperty.spec.js b/JavaScript/packages/datatypes-date-time/test/timexProperty.spec.js deleted file mode 100644 index dada900eee..0000000000 --- a/JavaScript/packages/datatypes-date-time/test/timexProperty.spec.js +++ /dev/null @@ -1,124 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -const chai = require('chai'); -const { Time, TimexProperty } = require('../index.js'); - -const assert = chai.assert; -const expect = chai.expect; -chai.should(); - -describe('No Network', () => { - describe('Datatypes', () => { - describe('Timex', () => { - describe('making from JavaScript Date', () => { - it('fromDate', () => { - TimexProperty.fromDate(new Date(2017, 11, 5)).timex.should.equal('2017-12-05'); - }); - it('fromDateTime', () => { - TimexProperty.fromDateTime(new Date(2017, 11, 5, 23, 57, 35)).timex.should.equal('2017-12-05T23:57:35'); - }); - }); - describe('making from Time class', () => { - it('fromTime', () => { - TimexProperty.fromTime(new Time(23, 59, 30)).timex.should.equal('T23:59:30'); - }); - }); - describe('roundtrip', () => { - const roundtrip = function (timex) { (new TimexProperty(timex)).timex.should.equal(timex); }; - describe('date', () => { - it('various examples', () => { - roundtrip('2017-09-27'); - roundtrip('XXXX-WXX-3'); - roundtrip('XXXX-12-05'); - }); - }); - describe('time', () => { - it('various examples', () => { - roundtrip('T17:30:45'); - roundtrip('T05:06:07'); - roundtrip('T17:30'); - roundtrip('T23'); - }); - }); - describe('duration', () => { - it('various examples', () => { - roundtrip('P50Y'); - roundtrip('P6M'); - roundtrip('P3W'); - roundtrip('P5D'); - roundtrip('PT16H'); - roundtrip('PT32M'); - roundtrip('PT20S'); - }); - }); - describe('now', () => { - it('now', () => { - roundtrip('PRESENT_REF'); - }); - }); - describe('datetime', () => { - it('various examples', () => { - roundtrip('XXXX-WXX-3T04'); - roundtrip('2017-09-27T11:41:30'); - }); - }); - describe('daterange', () => { - it('various examples', () => { - roundtrip('2017'); - roundtrip('SU'); - roundtrip('2017-WI'); - roundtrip('2017-09'); - roundtrip('2017-W37'); - roundtrip('2017-W37-WE'); - roundtrip('XXXX-05'); - }); - }); - describe('daterange specified with (start,end,duration)', () => { - it ('various examples', () => { - roundtrip('(XXXX-WXX-3,XXXX-WXX-6,P3D)'); - roundtrip('(XXXX-01-01,XXXX-08-05,P216D)'); - roundtrip('(2017-01-01,2017-08-05,P216D)'); - }); - }); - describe('daterange specified with (start,end,duration) (leap year)', () => { - it ('various examples', () => { - roundtrip('(2016-01-01,2016-08-05,P217D)'); - }); - }); - describe('timerange', () => { - it('various examples', () => { - roundtrip('TEV'); - }); - }); - describe('timerange specified with (start,end,duration)', () => { - it ('various examples', () => { - roundtrip('(T16,T19,PT3H)'); - }); - }); - describe('datetimerange', () => { - it('various examples', () => { - roundtrip('2017-09-27TEV'); - }); - }); - describe('datetimerange specified with (start,end,duration)', () => { - it ('various examples', () => { - roundtrip('(2017-09-08T21:19:29,2017-09-08T21:24:29,PT5M)'); - roundtrip('(XXXX-WXX-3T16,XXXX-WXX-6T15,PT71H)'); - }); - }); - }); - describe('toString', () => { - it ('veryify call is delegated', () => { - (new TimexProperty('XXXX-05-05')).toString().should.equal('5th May'); - }); - }); - describe('toNaturalLanguage', () => { - it ('veryify call is delegated', () => { - const today = new Date(2017, 9, 16); - (new TimexProperty('2017-10-17')).toNaturalLanguage(today).should.equal('tomorrow'); - }); - }); - }); - }); -}); diff --git a/JavaScript/packages/datatypes-date-time/test/timexRangeResolver.spec.js b/JavaScript/packages/datatypes-date-time/test/timexRangeResolver.spec.js deleted file mode 100644 index 4af9c1ed98..0000000000 --- a/JavaScript/packages/datatypes-date-time/test/timexRangeResolver.spec.js +++ /dev/null @@ -1,223 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -const chai = require('chai'); -const { TimexProperty, creator, resolver } = require('../index.js'); - -const assert = chai.assert; -const expect = chai.expect; -chai.should(); - -describe('No Network', () => { - describe('Datatypes', () => { - describe('Timex resolution with range constraints', () => { - describe('daterange', () => { - it('definite', () => { - const constraints = [ { year: 2017, month: 9, dayOfMonth: 27, days: 2 } ]; - resolver.evaluate(['2017-09-28'], constraints).map(t => t.timex).should.have.members(['2017-09-28']); - }); - it('definite - constrainst expressed as timex', () => { - const constraints = [ '(2017-09-27,2017-09-29,P2D)' ]; - resolver.evaluate(['2017-09-28'], constraints).map(t => t.timex).should.have.members(['2017-09-28']); - }); - it('month and date', () => { - const constraints = [ { year: 2006, month: 1, dayOfMonth: 1, years: 2 } ]; - resolver.evaluate(['XXXX-05-29'], constraints).map(t => t.timex).should.have.members(['2006-05-29','2007-05-29']); - }); - it('month and date conditional on month/date', () => { - const constraints = [ '(2006-01-01,2008-06-01,P882D)' ]; - resolver.evaluate(['XXXX-05-29'], constraints).map(t => t.timex).should.have.members(['2006-05-29','2007-05-29','2008-05-29']); - }); - it('Saturdays in September', () => { - const constraints = [ '2017-09' ]; - resolver.evaluate(['XXXX-WXX-6'], constraints).map(t => t.timex).should.have.members(['2017-09-02','2017-09-09','2017-09-16','2017-09-23','2017-09-30']); - }); - it('Saturdays in September (expressed as range)', () => { - const constraints = [ '(2017-09-01,2017-10-01,P30D)' ]; - resolver.evaluate(['XXXX-WXX-6'], constraints).map(t => t.timex).should.have.members(['2017-09-02','2017-09-09','2017-09-16','2017-09-23','2017-09-30']); - }); - it('year', () => { - const constraints = [ '2018' ]; - resolver.evaluate(['XXXX-05-29'], constraints).map(t => t.timex).should.have.members(['2018-05-29']); - }); - it('year (expressed as range)', () => { - const constraints = [ '(2018-01-01,2019-01-01,P365D)' ]; - resolver.evaluate(['XXXX-05-29'], constraints).map(t => t.timex).should.have.members(['2018-05-29']); - }); - it('multiple constraints', () => { - const constraints = [ '(2017-09-01,2017-09-08,P7D)', '(2017-10-01,2017-10-08,P7D)' ]; - resolver.evaluate(['XXXX-WXX-3'], constraints).map(t => t.timex).should.have.members(['2017-09-06','2017-10-04']); - }); - it('multiple candidates with multiple constraints', () => { - const constraints = [ '(2017-09-01,2017-09-08,P7D)', '(2017-10-01,2017-10-08,P7D)' ]; - resolver.evaluate(['XXXX-WXX-2', 'XXXX-WXX-4'], constraints).map(t => t.timex).should.have.members(['2017-09-05','2017-09-07','2017-10-03','2017-10-05']); - }); - it('multiple overlapping constraints', () => { - const constraints = [ '(2017-09-03,2017-09-07,P4D)', '(2017-09-01,2017-09-08,P7D)', '(2017-09-01,2017-09-16,P15D)' ]; - resolver.evaluate(['XXXX-WXX-3'], constraints).map(t => t.timex).should.have.members(['2017-09-06']); - }); - }); - describe('timerange', () => { - it('time within range', () => { - const constraints = [ { hour: 14, hours: 4 } ]; - resolver.evaluate(['T16'], constraints).map(t => t.timex).should.have.members(['T16']); - }); - it('multiple times within range', () => { - const constraints = [ { hour: 14, hours: 4 } ]; - resolver.evaluate(['T12', 'T16', 'T16:30', 'T17', 'T18'], constraints).map(t => t.timex).should.have.members(['T16', 'T16:30', 'T17']); - }); - it('time with overlapping ranges', () => { - const constraints = [ { hour: 16, hours: 4 } ]; - resolver.evaluate(['T19'], constraints).map(t => t.timex).should.have.members(['T19']); - constraints.push({ hour: 14, hours: 4 }); - resolver.evaluate(['T19'], constraints).should.be.an('array').lengthOf(0); - resolver.evaluate(['T17'], constraints).map(t => t.timex).should.have.members(['T17']); - }); - it('multiple times with overlapping ranges', () => { - const constraints = [ { hour: 16, hours: 4 } ]; - resolver.evaluate(['T19', 'T19:30'], constraints).map(t => t.timex).should.have.members(['T19', 'T19:30']); - constraints.push({ hour: 14, hours: 4 }); - resolver.evaluate(['T19', 'T19:30'], constraints).map(t => t.timex).should.be.an('array').lengthOf(0); - resolver.evaluate(['T17', 'T17:30', 'T19:30'], constraints).map(t => t.timex).should.have.members(['T17', 'T17:30']); - }); - it('filter duplicates', () => { - const constraints = [ { hour: 14, hours: 4 } ]; - resolver.evaluate(['T16', 'T16', 'T16'], constraints).map(t => t.timex).should.have.lengthOf(1).members(['T16']); - }); - }); - describe('carry through time', () => { - it('definite', () => { - const constraints = [ { year: 2017, month: 9, dayOfMonth: 27, days: 2 } ]; - resolver.evaluate(['2017-09-28T18:30:01'], constraints).map(t => t.timex).should.have.members(['2017-09-28T18:30:01']); - }); - it('definite - constrainst expressed as timex', () => { - const constraints = [ '(2017-09-27,2017-09-29,P2D)' ]; - resolver.evaluate(['2017-09-28T18:30:01'], constraints).map(t => t.timex).should.have.members(['2017-09-28T18:30:01']); - }); - it('month and date', () => { - const constraints = [ { year: 2006, month: 1, dayOfMonth: 1, years: 2 } ]; - resolver.evaluate(['XXXX-05-29T19:30'], constraints).map(t => t.timex).should.have.members(['2006-05-29T19:30','2007-05-29T19:30']); - }); - it('month and date conditional on month/date', () => { - const constraints = [ '(2006-01-01,2008-06-01,P882D)' ]; - resolver.evaluate(['XXXX-05-29T19:30'], constraints).map(t => t.timex).should.have.members(['2006-05-29T19:30','2007-05-29T19:30','2008-05-29T19:30']); - }); - it('Saturdays in September', () => { - const constraints = [ '(2017-09-01,2017-10-01,P30D)' ]; - resolver.evaluate(['XXXX-WXX-6T01:00:00'], constraints).map(t => t.timex).should.have.members(['2017-09-02T01','2017-09-09T01','2017-09-16T01','2017-09-23T01','2017-09-30T01']); - }); - it('multiple constraints', () => { - const constraints = [ '(2017-09-01,2017-09-08,P7D)', '(2017-10-01,2017-10-08,P7D)' ]; - resolver.evaluate(['XXXX-WXX-3T01:02'], constraints).map(t => t.timex).should.have.members(['2017-09-06T01:02','2017-10-04T01:02']); - }); - }); - describe('combined daterange and timerange', () => { - it('day of week constrained by next week and any time', () => { - const constraints = [ - { year: 2017, month: 10, dayOfMonth: 5, days: 7 }, - { hour: 0, minute: 0, second: 0, hours: 24 } - ]; - resolver.evaluate(['XXXX-WXX-3T04', 'XXXX-WXX-3T16'], constraints).map(t => t.timex).should.have.members(['2017-10-11T04', '2017-10-11T16']); - }); - it('day of week constrained by next week and business hours', () => { - const constraints = [ - { year: 2017, month: 10, dayOfMonth: 5, days: 7 }, - { hour: 12, minute: 0, second: 0, hours: 8 } - ]; - resolver.evaluate(['XXXX-WXX-3T04', 'XXXX-WXX-3T16'], constraints).map(t => t.timex).should.have.members(['2017-10-11T16']); - }); - }); - describe('adding times', () => { - it('add specific time to date', () => { - const constraints = [ - new TimexProperty('2017'), - new TimexProperty('T19:30:00') - ]; - resolver.evaluate(['XXXX-05-29'], constraints).map(t => t.timex).should.have.members(['2017-05-29T19:30']); - }); - it('add specific times to date', () => { - const constraints = [ - new TimexProperty('2017'), - new TimexProperty('T19:30:00'), - new TimexProperty('T20:01:01'), - ]; - resolver.evaluate(['XXXX-05-29'], constraints).map(t => t.timex).should.have.members(['2017-05-29T19:30', '2017-05-29T20:01:01']); - }); - }); - describe('duration', () => { - it('duration evaluated with a specific datetime results in that datetime plus the duration', () => { - const constraints = [ - new TimexProperty('2017-12-05T19:30:00') - ]; - resolver.evaluate(['PT5M'], constraints).map(t => t.timex).should.have.members(['2017-12-05T19:35']); - }); - it('duration evaluated with a specific time results in that time plus the duration', () => { - const constraints = [ - new TimexProperty('T19:30:00') - ]; - resolver.evaluate(['PT5M'], constraints).map(t => t.timex).should.have.members(['T19:35']); - }); - it('duration evaluated with no constraints currently results in no solutions', () => { - const constraints = [ - ]; - resolver.evaluate(['PT5M'], constraints).map(t => t.timex).should.have.length(0); - }); - it('duration evaluated with no datetime or time constraints currently results in no solutions', () => { - const constraints = [ - { year: 2017, month: 10, dayOfMonth: 5, days: 7 } - ]; - resolver.evaluate(['PT5M'], constraints).map(t => t.timex).should.have.length(0); - }); - }); - describe('candidate includes a timerange', () => { - it('basic resolve day against daterange', () => { - const constraints = [ - new TimexProperty('(2018-06-04,2018-06-11,P7D)'), - new TimexProperty('(2018-06-11,2018-06-18,P7D)'), - creator.evening - ]; - resolver.evaluate(['XXXX-WXX-7'], constraints).map(t => t.timex).should.have.members(['2018-06-10T16', '2018-06-17T16']); - }); - it('no time constraint', () => { - const constraints = [ - new TimexProperty('(2018-06-04,2018-06-11,P7D)'), - new TimexProperty('(2018-06-11,2018-06-18,P7D)') - ]; - resolver.evaluate(['XXXX-WXX-7TEV'], constraints).map(t => t.timex).should.have.members(['2018-06-10TEV', '2018-06-17TEV']); - }); - it('overlapping constraint 1', () => { - const constraints = [ - new TimexProperty('(2018-06-04,2018-06-11,P7D)'), - new TimexProperty('(2018-06-11,2018-06-18,P7D)'), - new TimexProperty('(T18,T22,PT4H)') - ]; - resolver.evaluate(['XXXX-WXX-7TEV'], constraints).map(t => t.timex).should.have.members(['2018-06-10T18', '2018-06-17T18']); - }); - it('overlapping constraint 2', () => { - const constraints = [ - new TimexProperty('(2018-06-04,2018-06-11,P7D)'), - new TimexProperty('(2018-06-11,2018-06-18,P7D)'), - new TimexProperty('(T15,T19,PT4H)') - ]; - resolver.evaluate(['XXXX-WXX-7TEV'], constraints).map(t => t.timex).should.have.members(['2018-06-10T16', '2018-06-17T16']); - }); - it('non overlapping constraint', () => { - const constraints = [ - new TimexProperty('(2018-06-04,2018-06-11,P7D)'), - new TimexProperty('(2018-06-11,2018-06-18,P7D)'), - creator.morning - ]; - resolver.evaluate(['XXXX-WXX-7TEV'], constraints).map(t => t.timex).should.have.length(0); - }); - it('sunday evening as the candidate and the constraint', () => { - const constraints = [ - new TimexProperty('(2018-06-04,2018-06-11,P7D)'), - new TimexProperty('(2018-06-11,2018-06-18,P7D)'), - creator.evening - ]; - resolver.evaluate(['XXXX-WXX-7TEV'], constraints).map(t => t.timex).should.have.members(['2018-06-10T16', '2018-06-17T16']); - }); - }); - }); - }); -}); diff --git a/JavaScript/packages/datatypes-date-time/test/timexRelativeConvert.spec.js b/JavaScript/packages/datatypes-date-time/test/timexRelativeConvert.spec.js deleted file mode 100644 index 7b2c9b81c4..0000000000 --- a/JavaScript/packages/datatypes-date-time/test/timexRelativeConvert.spec.js +++ /dev/null @@ -1,244 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -const chai = require('chai'); - -const { TimexProperty, TimexSet } = require('../index.js'); -const timexRelativeConvert = require('../src/timexRelativeConvert.js'); - -const assert = chai.assert; -const expect = chai.expect; -chai.should(); - -describe('No Network', () => { - describe('Datatypes', () => { - describe('Timex relative convert to string', () => { - describe('date', () => { - describe('one day or less separation', () => { - it('today', () => { - const timex = new TimexProperty('2017-09-25'); - const today = new Date(2017, 8, 25); - timexRelativeConvert.convertTimexToStringRelative(timex, today).should.equal('today'); - }); - it('tomorrow', () => { - const timex = new TimexProperty('2017-09-23'); - const today = new Date(2017, 8, 22); - timexRelativeConvert.convertTimexToStringRelative(timex, today).should.equal('tomorrow'); - }); - it('tomorrow cross year/month boundary', () => { - const timex = new TimexProperty('2018-01-01'); - const today = new Date(2017, 11, 31); - timexRelativeConvert.convertTimexToStringRelative(timex, today).should.equal('tomorrow'); - }); - it('yesterday', () => { - const timex = new TimexProperty('2017-09-21'); - const today = new Date(2017, 8, 22); - timexRelativeConvert.convertTimexToStringRelative(timex, today).should.equal('yesterday'); - }); - it('yesterday cross year/month boundary', () => { - const timex = new TimexProperty('2017-12-31'); - const today = new Date(2018, 0, 1); - timexRelativeConvert.convertTimexToStringRelative(timex, today).should.equal('yesterday'); - }); - }); - describe('one week separation', () => { - it('this week', () => { - const timex = new TimexProperty('2017-10-18'); - const today = new Date(2017, 9, 16); - timexRelativeConvert.convertTimexToStringRelative(timex, today).should.equal('this Wednesday'); - }); - it('this week cross year/month boundary', () => { - const timex = new TimexProperty('2017-11-03'); - const today = new Date(2017, 9, 31); - timexRelativeConvert.convertTimexToStringRelative(timex, today).should.equal('this Friday'); - }); - it('next week', () => { - const timex = new TimexProperty('2017-09-27'); - const today = new Date(2017, 8, 22); - timexRelativeConvert.convertTimexToStringRelative(timex, today).should.equal('next Wednesday'); - }); - it('next week cross year/month boundary', () => { - const timex = new TimexProperty('2018-01-05'); - const today = new Date(2017, 11, 28); - timexRelativeConvert.convertTimexToStringRelative(timex, today).should.equal('next Friday'); - }); - it('last week', () => { - const timex = new TimexProperty('2017-09-14'); - const today = new Date(2017, 8, 22); - timexRelativeConvert.convertTimexToStringRelative(timex, today).should.equal('last Thursday'); - }); - it('last week cross year/month boundary', () => { - const timex = new TimexProperty('2017-12-25'); - const today = new Date(2018, 0, 4); - timexRelativeConvert.convertTimexToStringRelative(timex, today).should.equal('last Monday'); - }); - }); - }); - describe('more than one week separation', () => { - it('this week', () => { - const timex = new TimexProperty('2017-10-25'); - const today = new Date(2017, 9, 9); - timexRelativeConvert.convertTimexToStringRelative(timex, today).should.equal('25th October 2017'); - }); - it('next week', () => { - const timex = new TimexProperty('2017-10-04'); - const today = new Date(2017, 8, 22); - timexRelativeConvert.convertTimexToStringRelative(timex, today).should.equal('4th October 2017'); - }); - it('last week', () => { - const timex = new TimexProperty('2017-09-07'); - const today = new Date(2017, 8, 22); - timexRelativeConvert.convertTimexToStringRelative(timex, today).should.equal('7th September 2017'); - }); - }); - describe('datetime', () => { - it('today', () => { - const timex = new TimexProperty('2017-09-25T16:00:00'); - const today = new Date(2017, 8, 25); - timexRelativeConvert.convertTimexToStringRelative(timex, today).should.equal('today 4PM'); - }); - it('tomorrow', () => { - const timex = new TimexProperty('2017-09-23T16:00:00'); - const today = new Date(2017, 8, 22); - timexRelativeConvert.convertTimexToStringRelative(timex, today).should.equal('tomorrow 4PM'); - }); - it('yesterday', () => { - const timex = new TimexProperty('2017-09-21T16:00:00'); - const today = new Date(2017, 8, 22); - timexRelativeConvert.convertTimexToStringRelative(timex, today).should.equal('yesterday 4PM'); - }); - }); - describe('daterange', () => { - describe('week', () => { - it('this week', () => { - const timex = new TimexProperty('2017-W40'); - const today = new Date(2017, 8, 25); - timexRelativeConvert.convertTimexToStringRelative(timex, today).should.equal('this week'); - }); - it('next week', () => { - const timex = new TimexProperty('2017-W41'); - const today = new Date(2017, 8, 25); - timexRelativeConvert.convertTimexToStringRelative(timex, today).should.equal('next week'); - }); - it('last week', () => { - const timex = new TimexProperty('2017-W39'); - const today = new Date(2017, 8, 25); - timexRelativeConvert.convertTimexToStringRelative(timex, today).should.equal('last week'); - }); - it('this week', () => { - const timex = new TimexProperty('2017-W41'); - const today = new Date(2017, 9, 4); - timexRelativeConvert.convertTimexToStringRelative(timex, today).should.equal('this week'); - }); - it('next week', () => { - const timex = new TimexProperty('2017-W42'); - const today = new Date(2017, 9, 4); - timexRelativeConvert.convertTimexToStringRelative(timex, today).should.equal('next week'); - }); - it('last week', () => { - const timex = new TimexProperty('2017-W40'); - const today = new Date(2017, 9, 4); - timexRelativeConvert.convertTimexToStringRelative(timex, today).should.equal('last week'); - }); - }); - describe('weekend', () => { - it('this weekend', () => { - const timex = new TimexProperty('2017-W40-WE'); - const today = new Date(2017, 8, 25); - timexRelativeConvert.convertTimexToStringRelative(timex, today).should.equal('this weekend'); - }); - it('next weekend', () => { - const timex = new TimexProperty('2017-W41-WE'); - const today = new Date(2017, 8, 25); - timexRelativeConvert.convertTimexToStringRelative(timex, today).should.equal('next weekend'); - }); - it('last weekend', () => { - const timex = new TimexProperty('2017-W39-WE'); - const today = new Date(2017, 8, 25); - timexRelativeConvert.convertTimexToStringRelative(timex, today).should.equal('last weekend'); - }); - }); - describe('month', () => { - it('this month', () => { - const timex = new TimexProperty('2017-09'); - const today = new Date(2017, 8, 25); - timexRelativeConvert.convertTimexToStringRelative(timex, today).should.equal('this month'); - }); - it('next month', () => { - const timex = new TimexProperty('2017-10'); - const today = new Date(2017, 8, 25); - timexRelativeConvert.convertTimexToStringRelative(timex, today).should.equal('next month'); - }); - it('last month', () => { - const timex = new TimexProperty('2017-08'); - const today = new Date(2017, 8, 25); - timexRelativeConvert.convertTimexToStringRelative(timex, today).should.equal('last month'); - }); - }); - describe('year', () => { - it('this year', () => { - const timex = new TimexProperty('2017'); - const today = new Date(2017, 8, 25); - timexRelativeConvert.convertTimexToStringRelative(timex, today).should.equal('this year'); - }); - it('next year', () => { - const timex = new TimexProperty('2018'); - const today = new Date(2017, 8, 25); - timexRelativeConvert.convertTimexToStringRelative(timex, today).should.equal('next year'); - }); - it('last year', () => { - const timex = new TimexProperty('2016'); - const today = new Date(2017, 8, 25); - timexRelativeConvert.convertTimexToStringRelative(timex, today).should.equal('last year'); - }); - }); - describe('season', () => { - it('this summer', () => { - const timex = new TimexProperty('2017-SU'); - const today = new Date(2017, 8, 25); - timexRelativeConvert.convertTimexToStringRelative(timex, today).should.equal('this summer'); - }); - it('next summer', () => { - const timex = new TimexProperty('2018-SU'); - const today = new Date(2017, 8, 25); - timexRelativeConvert.convertTimexToStringRelative(timex, today).should.equal('next summer'); - }); - it('last summer', () => { - const timex = new TimexProperty('2016-SU'); - const today = new Date(2017, 8, 25); - timexRelativeConvert.convertTimexToStringRelative(timex, today).should.equal('last summer'); - }); - }); - }); - describe('datetimerange', () => { - describe('partOfDay', () => { - it('this evening', () => { - const timex = new TimexProperty('2017-09-25TEV'); - const today = new Date(2017, 8, 25); - timexRelativeConvert.convertTimexToStringRelative(timex, today).should.equal('this evening'); - }); - it('tonight', () => { - const timex = new TimexProperty('2017-09-25TNI'); - const today = new Date(2017, 8, 25); - timexRelativeConvert.convertTimexToStringRelative(timex, today).should.equal('tonight'); - }); - it('tomorrow morning', () => { - const timex = new TimexProperty('2017-09-26TMO'); - const today = new Date(2017, 8, 25); - timexRelativeConvert.convertTimexToStringRelative(timex, today).should.equal('tomorrow morning'); - }); - it('yesterday afternoon', () => { - const timex = new TimexProperty('2017-09-24TAF'); - const today = new Date(2017, 8, 25); - timexRelativeConvert.convertTimexToStringRelative(timex, today).should.equal('yesterday afternoon'); - }); - it('next wednesday evening', () => { - const timex = new TimexProperty('2017-10-04TEV'); - const today = new Date(2017, 8, 25); - timexRelativeConvert.convertTimexToStringRelative(timex, today).should.equal('next Wednesday evening'); - }); - }); - }); - }); - }); -}); diff --git a/JavaScript/packages/datatypes-date-time/test/timexResolver.spec.js b/JavaScript/packages/datatypes-date-time/test/timexResolver.spec.js deleted file mode 100644 index d8c0a1159e..0000000000 --- a/JavaScript/packages/datatypes-date-time/test/timexResolver.spec.js +++ /dev/null @@ -1,282 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -const chai = require('chai'); -const { TimexProperty } = require('../index.js'); -const resolver = require('../src/timexResolver.js'); - -const assert = chai.assert; -const expect = chai.expect; -chai.should(); - -describe('No Network', () => { - describe('Datatypes', () => { - describe('Timex resolution', () => { - describe('date', () => { - it('definite', () => { - const today = new Date(2017, 8, 26, 15, 30, 0); - const resolution = resolver.resolve(['2017-09-28'], today); - resolution.should.have.property('values').that.is.an('array').of.length(1); - resolution.values[0].should.have.property('timex', '2017-09-28'); - resolution.values[0].should.have.property('type', 'date'); - resolution.values[0].should.have.property('value', '2017-09-28'); - }); - it('Saturday', () => { - const today = new Date(2017, 8, 28, 15, 30, 0); - const resolution = resolver.resolve(['XXXX-WXX-6'], today); - resolution.should.have.property('values').that.is.an('array').of.length(2); - resolution.values[0].should.have.property('timex', 'XXXX-WXX-6'); - resolution.values[0].should.have.property('type', 'date'); - resolution.values[0].should.have.property('value', '2017-09-23'); - resolution.values[1].should.have.property('timex', 'XXXX-WXX-6'); - resolution.values[1].should.have.property('type', 'date'); - resolution.values[1].should.have.property('value', '2017-09-30'); - }); - }); - describe('datetime', () => { - it('Wednesday 4 Oclock', () => { - const today = new Date(2017, 8, 28, 15, 30, 0); - const resolution = resolver.resolve(['XXXX-WXX-3T04', 'XXXX-WXX-3T16'], today); - resolution.should.have.property('values').that.is.an('array').of.length(4); - resolution.values[0].should.have.property('timex', 'XXXX-WXX-3T04'); - resolution.values[0].should.have.property('type', 'datetime'); - resolution.values[0].should.have.property('value', '2017-09-27 04:00:00'); - resolution.values[1].should.have.property('timex', 'XXXX-WXX-3T04'); - resolution.values[1].should.have.property('type', 'datetime'); - resolution.values[1].should.have.property('value', '2017-10-04 04:00:00'); - resolution.values[2].should.have.property('timex', 'XXXX-WXX-3T16'); - resolution.values[2].should.have.property('type', 'datetime'); - resolution.values[2].should.have.property('value', '2017-09-27 16:00:00'); - resolution.values[3].should.have.property('timex', 'XXXX-WXX-3T16'); - resolution.values[3].should.have.property('type', 'datetime'); - resolution.values[3].should.have.property('value', '2017-10-04 16:00:00'); - }); - it('Wednesday 4pm', () => { - const today = new Date(2017, 8, 28, 15, 30, 0); - const resolution = resolver.resolve(['XXXX-WXX-3T04'], today); - resolution.should.have.property('values').that.is.an('array').of.length(2); - resolution.values[0].should.have.property('timex', 'XXXX-WXX-3T04'); - resolution.values[0].should.have.property('type', 'datetime'); - resolution.values[0].should.have.property('value', '2017-09-27 04:00:00'); - resolution.values[1].should.have.property('timex', 'XXXX-WXX-3T04'); - resolution.values[1].should.have.property('type', 'datetime'); - resolution.values[1].should.have.property('value', '2017-10-04 04:00:00'); - }); - it('next Wednesday 4am', () => { - const today = new Date(2017, 9, 7); - const resolution = resolver.resolve(['2017-10-11T04'], today); - resolution.should.have.property('values').that.is.an('array').of.length(1); - resolution.values[0].should.have.property('timex', '2017-10-11T04'); - resolution.values[0].should.have.property('type', 'datetime'); - resolution.values[0].should.have.property('value', '2017-10-11 04:00:00'); - }); - }); - describe('duration', () => { - it('2 years', () => { - const resolution = resolver.resolve(['P2Y']); - resolution.should.have.property('values').that.is.an('array').of.length(1); - resolution.values[0].should.have.property('timex', 'P2Y'); - resolution.values[0].should.have.property('type', 'duration'); - resolution.values[0].should.have.property('value', '63072000'); - }); - it('6 months', () => { - const resolution = resolver.resolve(['P6M']); - resolution.should.have.property('values').that.is.an('array').of.length(1); - resolution.values[0].should.have.property('timex', 'P6M'); - resolution.values[0].should.have.property('type', 'duration'); - resolution.values[0].should.have.property('value', '15552000'); - }); - it('3 weeks', () => { - const resolution = resolver.resolve(['P3W']); - resolution.should.have.property('values').that.is.an('array').of.length(1); - resolution.values[0].should.have.property('timex', 'P3W'); - resolution.values[0].should.have.property('type', 'duration'); - resolution.values[0].should.have.property('value', '1814400'); - }); - it('5 days', () => { - const resolution = resolver.resolve(['P5D']); - resolution.should.have.property('values').that.is.an('array').of.length(1); - resolution.values[0].should.have.property('timex', 'P5D'); - resolution.values[0].should.have.property('type', 'duration'); - resolution.values[0].should.have.property('value', '432000'); - }); - it('8 hours', () => { - const resolution = resolver.resolve(['PT8H']); - resolution.should.have.property('values').that.is.an('array').of.length(1); - resolution.values[0].should.have.property('timex', 'PT8H'); - resolution.values[0].should.have.property('type', 'duration'); - resolution.values[0].should.have.property('value', '28800'); - }); - it('15 minutes', () => { - const resolution = resolver.resolve(['PT15M']); - resolution.should.have.property('values').that.is.an('array').of.length(1); - resolution.values[0].should.have.property('timex', 'PT15M'); - resolution.values[0].should.have.property('type', 'duration'); - resolution.values[0].should.have.property('value', '900'); - }); - it('10 seconds', () => { - const resolution = resolver.resolve(['PT10S']); - resolution.should.have.property('values').that.is.an('array').of.length(1); - resolution.values[0].should.have.property('timex', 'PT10S'); - resolution.values[0].should.have.property('type', 'duration'); - resolution.values[0].should.have.property('value', '10'); - }); - }); - describe('daterange', () => { - it('September', () => { - const today = new Date(2017, 8, 28); - const resolution = resolver.resolve(['XXXX-09'], today); - resolution.should.have.property('values').that.is.an('array').of.length(2); - resolution.values[0].should.have.property('timex', 'XXXX-09'); - resolution.values[0].should.have.property('type', 'daterange'); - resolution.values[0].should.have.property('start', '2016-09-01'); - resolution.values[0].should.have.property('end', '2016-10-01'); - resolution.values[1].should.have.property('timex', 'XXXX-09'); - resolution.values[1].should.have.property('type', 'daterange'); - resolution.values[1].should.have.property('start', '2017-09-01'); - resolution.values[1].should.have.property('end', '2017-10-01'); - }); - it('Winter', () => { - const today = new Date(2017, 8, 28); - const resolution = resolver.resolve(['WI'], today); - resolution.should.have.property('values').that.is.an('array').of.length(1); - resolution.values[0].should.have.property('timex', 'WI'); - resolution.values[0].should.have.property('type', 'daterange'); - resolution.values[0].should.have.property('value', 'not resolved'); - }); - it('Last Week', () => { - const today = new Date(2019, 3, 30); - const resolution = resolver.resolve(['2019-W17'], today); - resolution.should.have.property('values').that.is.an('array').of.length(1); - resolution.values[0].should.have.property('timex', '2019-W17'); - resolution.values[0].should.have.property('type', 'daterange'); - resolution.values[0].should.have.property('start', '2019-04-22'); - resolution.values[0].should.have.property('end', '2019-04-29'); - }); - it('Last Month', () => { - const today = new Date(2019, 3, 30); - const resolution = resolver.resolve(['2019-03'], today); - resolution.should.have.property('values').that.is.an('array').of.length(1); - resolution.values[0].should.have.property('timex', '2019-03'); - resolution.values[0].should.have.property('type', 'daterange'); - resolution.values[0].should.have.property('start', '2019-03-01'); - resolution.values[0].should.have.property('end', '2019-04-01'); - }); - it('Last Year', () => { - const today = new Date(2019, 3, 30); - const resolution = resolver.resolve(['2018'], today); - resolution.should.have.property('values').that.is.an('array').of.length(1); - resolution.values[0].should.have.property('timex', '2018'); - resolution.values[0].should.have.property('type', 'daterange'); - resolution.values[0].should.have.property('start', '2018-01-01'); - resolution.values[0].should.have.property('end', '2019-01-01'); - }); - it('Last Three Weeks', () => { - const today = new Date(2019, 3, 30); - const resolution = resolver.resolve(['(2019-04-10,2019-05-01,P3W)'], today); - resolution.should.have.property('values').that.is.an('array').of.length(1); - resolution.values[0].should.have.property('timex', '(2019-04-10,2019-05-01,P3W)'); - resolution.values[0].should.have.property('type', 'daterange'); - resolution.values[0].should.have.property('start', '2019-04-10'); - resolution.values[0].should.have.property('end', '2019-05-01'); - }); - it('December', () => { - const today = new Date(2020, 3, 27); - const resolution = resolver.resolve(['XXXX-12'], today); - resolution.should.have.property('values').that.is.an('array').of.length(2); - resolution.values[0].should.have.property('timex', 'XXXX-12'); - resolution.values[0].should.have.property('type', 'daterange'); - resolution.values[0].should.have.property('start', '2019-12-01'); - resolution.values[0].should.have.property('end', '2020-01-01'); - resolution.values[1].should.have.property('timex', 'XXXX-12'); - resolution.values[1].should.have.property('type', 'daterange'); - resolution.values[1].should.have.property('start', '2020-12-01'); - resolution.values[1].should.have.property('end', '2021-01-01'); - }); - }); - describe('timerange', () => { - it('4am to 8pm', () => { - const today = new Date(); - const resolution = resolver.resolve(['(T04,T20,PT16H)'], today); - resolution.should.have.property('values').that.is.an('array').of.length(1); - resolution.values[0].should.have.property('timex', '(T04,T20,PT16H)'); - resolution.values[0].should.have.property('type', 'timerange'); - resolution.values[0].should.have.property('start', '04:00:00'); - resolution.values[0].should.have.property('end', '20:00:00'); - }); - it('morning', () => { - const today = new Date(); - const resolution = resolver.resolve(['TMO'], today); - resolution.should.have.property('values').that.is.an('array').of.length(1); - resolution.values[0].should.have.property('timex', 'TMO'); - resolution.values[0].should.have.property('type', 'timerange'); - resolution.values[0].should.have.property('start', '08:00:00'); - resolution.values[0].should.have.property('end', '12:00:00'); - }); - it('afternoon', () => { - const today = new Date(); - const resolution = resolver.resolve(['TAF'], today); - resolution.should.have.property('values').that.is.an('array').of.length(1); - resolution.values[0].should.have.property('timex', 'TAF'); - resolution.values[0].should.have.property('type', 'timerange'); - resolution.values[0].should.have.property('start', '12:00:00'); - resolution.values[0].should.have.property('end', '16:00:00'); - }); - it('evening', () => { - const today = new Date(); - const resolution = resolver.resolve(['TEV'], today); - resolution.should.have.property('values').that.is.an('array').of.length(1); - resolution.values[0].should.have.property('timex', 'TEV'); - resolution.values[0].should.have.property('type', 'timerange'); - resolution.values[0].should.have.property('start', '16:00:00'); - resolution.values[0].should.have.property('end', '20:00:00'); - }); - }); - describe('datetimerange', () => { - it('this morning', () => { - const resolution = resolver.resolve(['2017-10-07TMO']); - resolution.should.have.property('values').that.is.an('array').of.length(1); - resolution.values[0].should.have.property('timex', '2017-10-07TMO'); - resolution.values[0].should.have.property('type', 'datetimerange'); - resolution.values[0].should.have.property('start', '2017-10-07 08:00:00'); - resolution.values[0].should.have.property('end', '2017-10-07 12:00:00'); - }); - it('tonight', () => { - const resolution = resolver.resolve(['2018-03-18TNI']); - resolution.should.have.property('values').that.is.an('array').of.length(1); - resolution.values[0].should.have.property('timex', '2018-03-18TNI'); - resolution.values[0].should.have.property('type', 'datetimerange'); - resolution.values[0].should.have.property('start', '2018-03-18 20:00:00'); - resolution.values[0].should.have.property('end', '2018-03-18 24:00:00'); - }); - it('next monday 4am to next thursday 3pm', () => { - const resolution = resolver.resolve(['(2017-10-09T04,2017-10-12T15,PT83H)']); - resolution.should.have.property('values').that.is.an('array').of.length(1); - resolution.values[0].should.have.property('timex', '(2017-10-09T04,2017-10-12T15,PT83H)'); - resolution.values[0].should.have.property('type', 'datetimerange'); - resolution.values[0].should.have.property('start', '2017-10-09 04:00:00'); - resolution.values[0].should.have.property('end', '2017-10-12 15:00:00'); - }); - }); - describe('time', () => { - it('4am', () => { - const resolution = resolver.resolve(['T04']); - resolution.should.have.property('values').that.is.an('array').of.length(1); - resolution.values[0].should.have.property('timex', 'T04'); - resolution.values[0].should.have.property('type', 'time'); - resolution.values[0].should.have.property('value', '04:00:00'); - }); - it('4 oclock', () => { - const resolution = resolver.resolve(['T04', 'T16']); - resolution.should.have.property('values').that.is.an('array').of.length(2); - resolution.values[0].should.have.property('timex', 'T04'); - resolution.values[0].should.have.property('type', 'time'); - resolution.values[0].should.have.property('value', '04:00:00'); - resolution.values[1].should.have.property('timex', 'T16'); - resolution.values[1].should.have.property('type', 'time'); - resolution.values[1].should.have.property('value', '16:00:00'); - }); - }); - }); - }); -}); diff --git a/JavaScript/packages/datatypes-date-time/test/timexSet.spec.js b/JavaScript/packages/datatypes-date-time/test/timexSet.spec.js deleted file mode 100644 index 2ec7ce84a6..0000000000 --- a/JavaScript/packages/datatypes-date-time/test/timexSet.spec.js +++ /dev/null @@ -1,236 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -const chai = require('chai'); - -const { TimexProperty, TimexSet } = require('../index.js'); - -const assert = chai.assert; -const expect = chai.expect; -chai.should(); - -describe('No Network', () => { - describe('Datatypes', () => { - describe('Timex', () => { - describe('Set', () => { - it('every 2 days', () => { - const timexSet = new TimexSet('P2D'); - timexSet.should.have.property('timex'); - const timex = timexSet.timex; - timex.should.have.property('types').that.is.a('Set').that.has.keys('duration'); - timex.should.not.have.property('year'); - timex.should.not.have.property('month'); - timex.should.not.have.property('dayOfMonth'); - timex.should.not.have.property('dayOfWeek'); - timex.should.not.have.property('weekOfYear'); - timex.should.not.have.property('weekOfMonth'); - timex.should.not.have.property('season'); - timex.should.not.have.property('hour'); - timex.should.not.have.property('minute'); - timex.should.not.have.property('second'); - timex.should.not.have.property('weekend'); - timex.should.not.have.property('partOfDay'); - timex.should.not.have.property('years'); - timex.should.not.have.property('months'); - timex.should.not.have.property('weeks'); - timex.should.have.property('days', 2); - timex.should.not.have.property('hours'); - timex.should.not.have.property('minutes'); - timex.should.not.have.property('seconds'); - }); - it('each week', () => { - const timexSet = new TimexSet('P1W'); - const timex = timexSet.timex; - timex.should.have.property('types').that.is.a('Set').that.has.keys('duration'); - timex.should.not.have.property('year'); - timex.should.not.have.property('month'); - timex.should.not.have.property('dayOfMonth'); - timex.should.not.have.property('dayOfWeek'); - timex.should.not.have.property('weekOfYear'); - timex.should.not.have.property('weekOfMonth'); - timex.should.not.have.property('season'); - timex.should.not.have.property('hour'); - timex.should.not.have.property('minute'); - timex.should.not.have.property('second'); - timex.should.not.have.property('weekend'); - timex.should.not.have.property('partOfDay'); - timex.should.not.have.property('years'); - timex.should.not.have.property('months'); - timex.should.have.property('weeks', 1); - timex.should.not.have.property('days'); - timex.should.not.have.property('hours'); - timex.should.not.have.property('minutes'); - timex.should.not.have.property('seconds'); - }); - it('every october', () => { - const timexSet = new TimexSet('XXXX-10'); - const timex = timexSet.timex; - timex.should.have.property('types').that.is.a('Set').that.has.keys('daterange'); - timex.should.not.have.property('year'); - timex.should.have.property('month', 10); - timex.should.not.have.property('dayOfMonth'); - timex.should.not.have.property('dayOfWeek'); - timex.should.not.have.property('weekOfYear'); - timex.should.not.have.property('weekOfMonth'); - timex.should.not.have.property('season'); - timex.should.not.have.property('hour'); - timex.should.not.have.property('minute'); - timex.should.not.have.property('second'); - timex.should.not.have.property('weekend'); - timex.should.not.have.property('partOfDay'); - timex.should.not.have.property('years'); - timex.should.not.have.property('months'); - timex.should.not.have.property('weeks'); - timex.should.not.have.property('days'); - timex.should.not.have.property('hours'); - timex.should.not.have.property('minutes'); - timex.should.not.have.property('seconds'); - }); - it('every sunday', () => { - const timexSet = new TimexSet('XXXX-WXX-7'); - const timex = timexSet.timex; - timex.should.have.property('types').that.is.a('Set').that.has.keys('date'); - timex.should.not.have.property('year'); - timex.should.not.have.property('month'); - timex.should.not.have.property('dayOfMonth'); - timex.should.have.property('dayOfWeek', 7); - timex.should.not.have.property('weekOfYear'); - timex.should.not.have.property('weekOfMonth'); - timex.should.not.have.property('season'); - timex.should.not.have.property('hour'); - timex.should.not.have.property('minute'); - timex.should.not.have.property('second'); - timex.should.not.have.property('weekend'); - timex.should.not.have.property('partOfDay'); - timex.should.not.have.property('years'); - timex.should.not.have.property('months'); - timex.should.not.have.property('weeks'); - timex.should.not.have.property('days'); - timex.should.not.have.property('hours'); - timex.should.not.have.property('minutes'); - timex.should.not.have.property('seconds'); - }); - it('every day', () => { - const timexSet = new TimexSet('P1D'); - const timex = timexSet.timex; - timex.should.have.property('types').that.is.a('Set').that.has.keys('duration'); - timex.should.not.have.property('year'); - timex.should.not.have.property('month'); - timex.should.not.have.property('dayOfMonth'); - timex.should.not.have.property('dayOfWeek'); - timex.should.not.have.property('weekOfYear'); - timex.should.not.have.property('weekOfMonth'); - timex.should.not.have.property('season'); - timex.should.not.have.property('hour'); - timex.should.not.have.property('minute'); - timex.should.not.have.property('second'); - timex.should.not.have.property('weekend'); - timex.should.not.have.property('partOfDay'); - timex.should.not.have.property('years'); - timex.should.not.have.property('months'); - timex.should.not.have.property('weeks'); - timex.should.have.property('days', 1); - timex.should.not.have.property('hours'); - timex.should.not.have.property('minutes'); - timex.should.not.have.property('seconds'); - }); - it('every year', () => { - const timexSet = new TimexSet('P1Y'); - const timex = timexSet.timex; - timex.should.have.property('types').that.is.a('Set').that.has.keys('duration'); - timex.should.not.have.property('year'); - timex.should.not.have.property('month'); - timex.should.not.have.property('dayOfMonth'); - timex.should.not.have.property('dayOfWeek'); - timex.should.not.have.property('weekOfYear'); - timex.should.not.have.property('weekOfMonth'); - timex.should.not.have.property('season'); - timex.should.not.have.property('hour'); - timex.should.not.have.property('minute'); - timex.should.not.have.property('second'); - timex.should.not.have.property('weekend'); - timex.should.not.have.property('partOfDay'); - timex.should.have.property('years', 1); - timex.should.not.have.property('months'); - timex.should.not.have.property('weeks'); - timex.should.not.have.property('days'); - timex.should.not.have.property('hours'); - timex.should.not.have.property('minutes'); - timex.should.not.have.property('seconds'); - }); - it('every spring', () => { - const timexSet = new TimexSet('SP'); - const timex = timexSet.timex; - timex.should.have.property('types').that.is.a('Set').that.has.keys('daterange'); - timex.should.not.have.property('year'); - timex.should.not.have.property('month'); - timex.should.not.have.property('dayOfMonth'); - timex.should.not.have.property('dayOfWeek'); - timex.should.not.have.property('weekOfYear'); - timex.should.not.have.property('weekOfMonth'); - timex.should.have.property('season', 'SP'); - timex.should.not.have.property('hour'); - timex.should.not.have.property('minute'); - timex.should.not.have.property('second'); - timex.should.not.have.property('weekend'); - timex.should.not.have.property('partOfDay'); - timex.should.not.have.property('years'); - timex.should.not.have.property('months'); - timex.should.not.have.property('weeks'); - timex.should.not.have.property('days'); - timex.should.not.have.property('hours'); - timex.should.not.have.property('minutes'); - timex.should.not.have.property('seconds'); - }); - it('each winter', () => { - const timexSet = new TimexSet('WI'); - const timex = timexSet.timex; - timex.should.have.property('types').that.is.a('Set').that.has.keys('daterange'); - timex.should.not.have.property('year'); - timex.should.not.have.property('month'); - timex.should.not.have.property('dayOfMonth'); - timex.should.not.have.property('dayOfWeek'); - timex.should.not.have.property('weekOfYear'); - timex.should.not.have.property('weekOfMonth'); - timex.should.have.property('season', 'WI'); - timex.should.not.have.property('hour'); - timex.should.not.have.property('minute'); - timex.should.not.have.property('second'); - timex.should.not.have.property('weekend'); - timex.should.not.have.property('partOfDay'); - timex.should.not.have.property('years'); - timex.should.not.have.property('months'); - timex.should.not.have.property('weeks'); - timex.should.not.have.property('days'); - timex.should.not.have.property('hours'); - timex.should.not.have.property('minutes'); - timex.should.not.have.property('seconds'); - }); - it('every evening', () => { - const timexSet = new TimexSet('TEV'); - const timex = timexSet.timex; - timex.should.have.property('types').that.is.a('Set').that.has.keys('timerange'); - timex.should.not.have.property('year'); - timex.should.not.have.property('month'); - timex.should.not.have.property('dayOfMonth'); - timex.should.not.have.property('dayOfWeek'); - timex.should.not.have.property('weekOfYear'); - timex.should.not.have.property('weekOfMonth'); - timex.should.not.have.property('season'); - timex.should.not.have.property('hour'); - timex.should.not.have.property('minute'); - timex.should.not.have.property('second'); - timex.should.not.have.property('weekend'); - timex.should.have.property('partOfDay', 'EV'); - timex.should.not.have.property('years'); - timex.should.not.have.property('months'); - timex.should.not.have.property('weeks'); - timex.should.not.have.property('days'); - timex.should.not.have.property('hours'); - timex.should.not.have.property('minutes'); - timex.should.not.have.property('seconds'); - }); - }); - }); - }); -}); diff --git a/JavaScript/packages/recognizers-choice/.npmignore b/JavaScript/packages/recognizers-choice/.npmignore deleted file mode 100644 index 757fb9517d..0000000000 --- a/JavaScript/packages/recognizers-choice/.npmignore +++ /dev/null @@ -1,4 +0,0 @@ -* -!dist/*.js -!dist/types/**/* -!README.md \ No newline at end of file diff --git a/JavaScript/packages/recognizers-choice/README.md b/JavaScript/packages/recognizers-choice/README.md deleted file mode 100644 index ddf45c6f5c..0000000000 --- a/JavaScript/packages/recognizers-choice/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# Microsoft.Recognizers.Text for JavaScript - -This module (`recognizers-text-choice`) is a sub-module of `recognizers-text-suite`. - -Please check the [main README](https://github.com/Microsoft/Recognizers-Text/tree/master/JavaScript/packages/recognizers-text-suite) for more details. \ No newline at end of file diff --git a/JavaScript/packages/recognizers-choice/package-lock.json b/JavaScript/packages/recognizers-choice/package-lock.json deleted file mode 100644 index caeb464e9a..0000000000 --- a/JavaScript/packages/recognizers-choice/package-lock.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "requires": true, - "lockfileVersion": 1, - "dependencies": { - "grapheme-splitter": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/grapheme-splitter/-/grapheme-splitter-1.0.2.tgz", - "integrity": "sha1-Y56dwb8GWJLGQ94x2qJ89YsQaOI=" - } - }, - "version": "1.3.0" -} diff --git a/JavaScript/packages/recognizers-choice/package.json b/JavaScript/packages/recognizers-choice/package.json deleted file mode 100644 index 62b9aa85d3..0000000000 --- a/JavaScript/packages/recognizers-choice/package.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "name": "@microsoft/recognizers-text-choice", - "version": "1.3.0", - "description": "recognizers-text-choice provides recognition of Boolean (yes/no) answers expressed in multiple languages, as well as base classes to support lists of alternative choices.", - "author": "Microsoft Corp.", - "license": "MIT", - "keywords": [ - "nlp", - "nlp-entity-extraction", - "entity-extraction", - "boolean", - "alternatives", - "choices", - "parser-library" - ], - "main": "dist/recognizers-text-choice.umd.js", - "module": "dist/recognizers-text-choice.es5.js", - "typings": "dist/types/recognizers-text-choice.d.ts", - "browser": "dist/recognizers-text-choice.browser.js", - "repository": { - "type": "git", - "url": "https://github.com/Microsoft/Recognizers-Text" - }, - "bugs": { - "url": "https://github.com/Microsoft/Recognizers-Text/issues" - }, - "engines": { - "node": ">=10.3.0" - }, - "scripts": { - "build-resources": "ts-node --project ../resource-generator/tsconfig.json ../resource-generator/ ../recognizers-choice/resource-definitions.json", - "clean-build": "rimraf dist && rimraf compiled", - "prepare": "npm run build-resources && npm run clean-build && tsc && rollup -c" - }, - "dependencies": { - "@microsoft/recognizers-text": "~1.3.0", - "grapheme-splitter": "^1.0.2" - } -} diff --git a/JavaScript/packages/recognizers-choice/resource-definitions.json b/JavaScript/packages/recognizers-choice/resource-definitions.json deleted file mode 100644 index 9bd8f5b41e..0000000000 --- a/JavaScript/packages/recognizers-choice/resource-definitions.json +++ /dev/null @@ -1,69 +0,0 @@ -{ - "outputPath": "./src/resources/", - "configFiles": [ - { - "input": [ "Chinese", "Chinese-Choice" ], - "output": "chineseChoice", - "header": [ - "export namespace ChineseChoice {" - ], - "footer": [ "}" ] - }, - { - "input": [ "Dutch", "Dutch-Choice" ], - "output": "dutchChoice", - "header": [ - "export namespace DutchChoice {" - ], - "footer": [ "}" ] - }, - { - "input": [ "English", "English-Choice" ], - "output": "englishChoice", - "header": [ - "export namespace EnglishChoice {" - ], - "footer": [ "}" ] - }, - { - "input": [ "French", "French-Choice" ], - "output": "frenchChoice", - "header": [ - "export namespace FrenchChoice {" - ], - "footer": [ "}" ] - }, - { - "input": [ "German", "German-Choice" ], - "output": "germanChoice", - "header": [ - "export namespace GermanChoice {" - ], - "footer": [ "}" ] - }, - { - "input": [ "Japanese", "Japanese-Choice" ], - "output": "japaneseChoice", - "header": [ - "export namespace JapaneseChoice {" - ], - "footer": [ "}" ] - }, - { - "input": [ "Portuguese", "Portuguese-Choice" ], - "output": "portugueseChoice", - "header": [ - "export namespace PortugueseChoice {" - ], - "footer": [ "}" ] - }, - { - "input": [ "Spanish", "Spanish-Choice" ], - "output": "spanishChoice", - "header": [ - "export namespace SpanishChoice {" - ], - "footer": [ "}" ] - } - ] -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-choice/rollup.config.js b/JavaScript/packages/recognizers-choice/rollup.config.js deleted file mode 100644 index 227477483f..0000000000 --- a/JavaScript/packages/recognizers-choice/rollup.config.js +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import resolve from 'rollup-plugin-node-resolve'; -import commonjs from 'rollup-plugin-commonjs'; -import sourceMaps from 'rollup-plugin-sourcemaps'; -import pkg from './package.json'; -import camelCase from 'lodash.camelcase'; -import alias from 'rollup-plugin-alias'; -import path from 'path'; - -export default { - input: `compiled/recognizers-text-choice.js`, - output: [ - { file: pkg.module, format: 'es' }, - { file: pkg.main, name: camelCase(pkg.name), format: 'umd', exports: 'named' }, - { file: pkg.browser, format: 'iife', name: camelCase(pkg.name), exports: 'named' } - ], - exports: 'named', - sourcemap: true, - plugins: [ - alias({ - '@microsoft/recognizers-text': path.resolve(__dirname, '../recognizers-text/compiled/recognizers-text.js') - }), - // Allow bundling cjs modules (unlike webpack, rollup doesn't understand cjs) - commonjs(), - // Allow node_modules resolution, so you can use 'external' to control - // which external modules to include in the bundle - // https://github.com/rollup/rollup-plugin-node-resolve#usage - resolve(), - - // Resolve source maps to the original source - sourceMaps() - ] -}; diff --git a/JavaScript/packages/recognizers-choice/src/choice/chinese/boolean.ts b/JavaScript/packages/recognizers-choice/src/choice/chinese/boolean.ts deleted file mode 100644 index 14f2cd8f3a..0000000000 --- a/JavaScript/packages/recognizers-choice/src/choice/chinese/boolean.ts +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { RegExpUtility } from "@microsoft/recognizers-text"; -import { IBooleanExtractorConfiguration } from "../extractors"; -import { ChineseChoice } from "../../resources/chineseChoice"; - -export class ChineseBooleanExtractorConfiguration implements IBooleanExtractorConfiguration { - readonly regexTrue: RegExp; - readonly regexFalse: RegExp; - readonly tokenRegex: RegExp; - readonly emojiSkinToneRegex: RegExp; - readonly onlyTopMatch: boolean; - - constructor(onlyTopMatch: boolean = true) { - this.emojiSkinToneRegex = RegExpUtility.getSafeRegExp(ChineseChoice.SkinToneRegex); - this.regexTrue = RegExpUtility.getSafeRegExp(ChineseChoice.TrueRegex); - this.regexFalse = RegExpUtility.getSafeRegExp(ChineseChoice.FalseRegex); - this.tokenRegex = RegExpUtility.getSafeRegExp(ChineseChoice.TokenizerRegex, 'is'); - this.onlyTopMatch = onlyTopMatch; - } -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-choice/src/choice/choiceRecognizer.ts b/JavaScript/packages/recognizers-choice/src/choice/choiceRecognizer.ts deleted file mode 100644 index 50ddf701a2..0000000000 --- a/JavaScript/packages/recognizers-choice/src/choice/choiceRecognizer.ts +++ /dev/null @@ -1,99 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { Recognizer, IModel, Culture, ModelResult } from "@microsoft/recognizers-text"; -import { BooleanModel } from "./models"; -import { BooleanExtractor } from "./extractors"; -import { BooleanParser } from "./parsers"; -import { ChineseBooleanExtractorConfiguration } from "./chinese/boolean"; -import { DutchBooleanExtractorConfiguration } from "./dutch/boolean"; -import { EnglishBooleanExtractorConfiguration } from "./english/boolean"; -import { FrenchBooleanExtractorConfiguration } from "./french/boolean"; -import { GermanBooleanExtractorConfiguration } from "./german/boolean"; -import { JapaneseBooleanExtractorConfiguration } from "./japanese/boolean"; -import { PortugueseBooleanExtractorConfiguration } from "./portuguese/boolean"; -import { SpanishBooleanExtractorConfiguration } from "./spanish/boolean"; - - -export enum ChoiceOptions { - None = 0, -} - -export function recognizeBoolean(query: string, culture: string, options: ChoiceOptions = ChoiceOptions.None, - fallbackToDefaultCulture: boolean = true): ModelResult[] { - let recognizer = new ChoiceRecognizer(culture, options); - let model = recognizer.getBooleanModel(culture, fallbackToDefaultCulture); - return model.parse(query); -} - -export default class ChoiceRecognizer extends Recognizer { - constructor(culture: string, options: ChoiceOptions = ChoiceOptions.None, lazyInitialization: boolean = false) { - super(culture, options, lazyInitialization); - } - - protected InitializeConfiguration() { - // #region Chinese - this.registerModel("BooleanModel", Culture.Chinese, (options) => new BooleanModel( - new BooleanParser(), - new BooleanExtractor(new ChineseBooleanExtractorConfiguration()) - )); - // #endregion - - // #region Dutch - this.registerModel("BooleanModel", Culture.Dutch, (options) => new BooleanModel( - new BooleanParser(), - new BooleanExtractor(new DutchBooleanExtractorConfiguration()) - )); - // #endregion - - // #region English - this.registerModel("BooleanModel", Culture.English, (options) => new BooleanModel( - new BooleanParser(), - new BooleanExtractor(new EnglishBooleanExtractorConfiguration()) - )); - // #endregion - - // #region French - this.registerModel("BooleanModel", Culture.French, (options) => new BooleanModel( - new BooleanParser(), - new BooleanExtractor(new FrenchBooleanExtractorConfiguration()) - )); - // #endregion - - // #region German - this.registerModel("BooleanModel", Culture.German, (options) => new BooleanModel( - new BooleanParser(), - new BooleanExtractor(new GermanBooleanExtractorConfiguration()) - )); - // #endregion - - // #region Japanese - this.registerModel("BooleanModel", Culture.Japanese, (options) => new BooleanModel( - new BooleanParser(), - new BooleanExtractor(new JapaneseBooleanExtractorConfiguration()) - )); - // #endregion - - // #region Portuguese - this.registerModel("BooleanModel", Culture.Portuguese, (options) => new BooleanModel( - new BooleanParser(), - new BooleanExtractor(new PortugueseBooleanExtractorConfiguration()) - )); - // #endregion - - // #region Spanish - this.registerModel("BooleanModel", Culture.Spanish, (options) => new BooleanModel( - new BooleanParser(), - new BooleanExtractor(new SpanishBooleanExtractorConfiguration()) - )); - // #endregion - } - - protected IsValidOptions(options: number): boolean { - return options >= 0 && options <= ChoiceOptions.None; - } - - getBooleanModel(culture: string = null, fallbackToDefaultCulture: boolean = true): IModel { - return this.getModel("BooleanModel", culture, fallbackToDefaultCulture); - } -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-choice/src/choice/constants.ts b/JavaScript/packages/recognizers-choice/src/choice/constants.ts deleted file mode 100644 index 5b15e39ad6..0000000000 --- a/JavaScript/packages/recognizers-choice/src/choice/constants.ts +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -export class Constants { - static readonly SYS_BOOLEAN: string = "boolean"; - static readonly SYS_BOOLEAN_TRUE: string = "boolean-true"; - static readonly SYS_BOOLEAN_FALSE: string = "boolean-false"; -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-choice/src/choice/dutch/boolean.ts b/JavaScript/packages/recognizers-choice/src/choice/dutch/boolean.ts deleted file mode 100644 index 32b65d5ace..0000000000 --- a/JavaScript/packages/recognizers-choice/src/choice/dutch/boolean.ts +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { RegExpUtility } from "@microsoft/recognizers-text"; -import { IBooleanExtractorConfiguration } from "../extractors"; -import { DutchChoice } from "../../resources/dutchChoice"; - -export class DutchBooleanExtractorConfiguration implements IBooleanExtractorConfiguration { - readonly regexTrue: RegExp; - readonly regexFalse: RegExp; - readonly tokenRegex: RegExp; - readonly emojiSkinToneRegex: RegExp; - readonly onlyTopMatch: boolean; - - constructor(onlyTopMatch: boolean = true) { - this.emojiSkinToneRegex = RegExpUtility.getSafeRegExp(DutchChoice.SkinToneRegex); - this.regexTrue = RegExpUtility.getSafeRegExp(DutchChoice.TrueRegex); - this.regexFalse = RegExpUtility.getSafeRegExp(DutchChoice.FalseRegex); - this.tokenRegex = RegExpUtility.getSafeRegExp(DutchChoice.TokenizerRegex, 'is'); - this.onlyTopMatch = onlyTopMatch; - } -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-choice/src/choice/english/boolean.ts b/JavaScript/packages/recognizers-choice/src/choice/english/boolean.ts deleted file mode 100644 index 66686eee0a..0000000000 --- a/JavaScript/packages/recognizers-choice/src/choice/english/boolean.ts +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { RegExpUtility } from "@microsoft/recognizers-text"; -import { IBooleanExtractorConfiguration } from "../extractors"; -import { EnglishChoice } from "../../resources/englishChoice"; - -export class EnglishBooleanExtractorConfiguration implements IBooleanExtractorConfiguration { - readonly regexTrue: RegExp; - readonly regexFalse: RegExp; - readonly tokenRegex: RegExp; - readonly emojiSkinToneRegex: RegExp; - readonly onlyTopMatch: boolean; - - constructor(onlyTopMatch: boolean = true) { - this.emojiSkinToneRegex = RegExpUtility.getSafeRegExp(EnglishChoice.SkinToneRegex); - this.regexTrue = RegExpUtility.getSafeRegExp(EnglishChoice.TrueRegex); - this.regexFalse = RegExpUtility.getSafeRegExp(EnglishChoice.FalseRegex); - this.tokenRegex = RegExpUtility.getSafeRegExp(EnglishChoice.TokenizerRegex, 'is'); - this.onlyTopMatch = onlyTopMatch; - } -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-choice/src/choice/extractors.ts b/JavaScript/packages/recognizers-choice/src/choice/extractors.ts deleted file mode 100644 index be4738aae8..0000000000 --- a/JavaScript/packages/recognizers-choice/src/choice/extractors.ts +++ /dev/null @@ -1,168 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { IExtractor, ExtractResult, RegExpUtility, Match, StringUtility } from "@microsoft/recognizers-text"; -import { Constants } from "./constants"; -import GraphemeSplitter = require("grapheme-splitter"); -const splitter = new GraphemeSplitter(); - -export interface IChoiceExtractorConfiguration { - regexesMap: Map; - tokenRegex: RegExp; - allowPartialMatch: boolean; - maxDistance: number; - onlyTopMatch: boolean; - emojiSkinToneRegex: RegExp; -} - -export class ChoiceExtractor implements IExtractor { - private readonly config: IChoiceExtractorConfiguration; - protected extractType: string; - - constructor(config: IChoiceExtractorConfiguration) { - this.config = config; - } - - extract(source: string): ExtractResult[] { - let results = new Array(); - let trimmedSource = source.toLowerCase(); - - if (StringUtility.isNullOrWhitespace(source)) { - return results; - } - - let allMatches = new Array(); - let partialResults = new Array(); - let sourceTokens = this.tokenize(trimmedSource); - - this.config.regexesMap.forEach((typeExtracted, regex) => { - RegExpUtility.getMatches(regex, trimmedSource).forEach(match => { - let matchTokens = this.tokenize(match.value); - let topScore = sourceTokens - .map((sToken, index) => this.matchValue(sourceTokens, matchTokens, index)) - .reduce((top, value) => top = Math.max(top, value), 0.0); - if (topScore > 0.0) { - let start = match.index; - let length = match.length; - let text = source.substr(start, length).trim(); - partialResults.push({ - start: start, - length: length, - text: text, - type: typeExtracted, - data: { - source: source, - score: topScore - } - }); - } - }); - }); - - if (partialResults.length === 0) { - return results; - } - - partialResults = partialResults.sort((a, b) => a.start - b.start); - - if (this.config.onlyTopMatch) { - let topResult = partialResults.reduce((top, value) => top = top.data.score < value.data.score ? value : top, partialResults[0]); - topResult.data.otherMatches = partialResults.filter(r => r !== topResult); - results.push(topResult); - } - else { - results = partialResults; - } - - return results; - } - - matchValue(source: string[], match: string[], startPos: number): number { - let matched = 0; - let emojiSkinToneMatch = 0; - let totalDeviation = 0; - match.forEach(matchToken => { - let pos = source.indexOf(matchToken, startPos); - if (pos >= 0) { - let distance = matched > 0 ? pos - startPos : 0; - if (distance <= this.config.maxDistance) { - matched++; - totalDeviation += distance; - startPos = pos + 1; - emojiSkinToneMatch += RegExpUtility.getMatches(this.config.emojiSkinToneRegex, matchToken).length; - } - } - }); - - let score = 0.0; - let emojiSkinToneLen = RegExpUtility.getMatches(this.config.emojiSkinToneRegex, source.join()).length; - if (matched > 0 && (matched === (match.length) || this.config.allowPartialMatch)) { - let completeness = matched / match.length; - let accuracy = completeness * (matched / (matched + totalDeviation)); - let initialScore = accuracy * ((matched + emojiSkinToneMatch) / (source.length + emojiSkinToneLen)); - score = 0.4 + (0.6 * initialScore); - } - return score; - } - - private tokenize(source: string): string[] { - let tokens: string[] = []; - let chars = splitter.splitGraphemes(source); - let token = ''; - chars.forEach(c => { - let codePoint = c.codePointAt(0) || c.charAt(0); - if (codePoint > 0xFFFF) { - // Character is in a Supplementary Unicode Plane. This is where emoji live so - // we're going to just break each character in this range out as its own token. - tokens.push(c); - if (!StringUtility.isNullOrWhitespace(token)) { - tokens.push(token); - token = ''; - } - } - else if (!(this.config.tokenRegex.test(c) || StringUtility.isWhitespace(c))) { - token = token.concat(c); - } - else if (!StringUtility.isNullOrWhitespace(token)) { - tokens.push(token); - token = ''; - } - }); - - if (!StringUtility.isNullOrWhitespace(token)) { - tokens.push(token); - token = ''; - } - return tokens; - } -} - -export interface IBooleanExtractorConfiguration { - regexTrue: RegExp; - regexFalse: RegExp; - tokenRegex: RegExp; - onlyTopMatch: boolean; - emojiSkinToneRegex: RegExp; -} - -export class BooleanExtractor extends ChoiceExtractor { - private static readonly booleanTrue = Constants.SYS_BOOLEAN_TRUE; - private static readonly booleanFalse = Constants.SYS_BOOLEAN_FALSE; - - constructor(config: IBooleanExtractorConfiguration) { - let regexesMap = new Map() - .set(config.regexTrue, Constants.SYS_BOOLEAN_TRUE) - .set(config.regexFalse, Constants.SYS_BOOLEAN_FALSE); - - let optionsConfig: IChoiceExtractorConfiguration = { - regexesMap: regexesMap, - tokenRegex: config.tokenRegex, - allowPartialMatch: false, - maxDistance: 2, - onlyTopMatch: config.onlyTopMatch, - emojiSkinToneRegex: config.emojiSkinToneRegex - }; - super(optionsConfig); - this.extractType = Constants.SYS_BOOLEAN; - } -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-choice/src/choice/french/boolean.ts b/JavaScript/packages/recognizers-choice/src/choice/french/boolean.ts deleted file mode 100644 index 2192b55cac..0000000000 --- a/JavaScript/packages/recognizers-choice/src/choice/french/boolean.ts +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { RegExpUtility } from "@microsoft/recognizers-text"; -import { IBooleanExtractorConfiguration } from "../extractors"; -import { FrenchChoice } from "../../resources/frenchChoice"; - -export class FrenchBooleanExtractorConfiguration implements IBooleanExtractorConfiguration { - readonly regexTrue: RegExp; - readonly regexFalse: RegExp; - readonly tokenRegex: RegExp; - readonly emojiSkinToneRegex: RegExp; - readonly onlyTopMatch: boolean; - - constructor(onlyTopMatch: boolean = true) { - this.emojiSkinToneRegex = RegExpUtility.getSafeRegExp(FrenchChoice.SkinToneRegex); - this.regexTrue = RegExpUtility.getSafeRegExp(FrenchChoice.TrueRegex); - this.regexFalse = RegExpUtility.getSafeRegExp(FrenchChoice.FalseRegex); - this.tokenRegex = RegExpUtility.getSafeRegExp(FrenchChoice.TokenizerRegex, 'is'); - this.onlyTopMatch = onlyTopMatch; - } -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-choice/src/choice/german/boolean.ts b/JavaScript/packages/recognizers-choice/src/choice/german/boolean.ts deleted file mode 100644 index 5a500e533f..0000000000 --- a/JavaScript/packages/recognizers-choice/src/choice/german/boolean.ts +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { RegExpUtility } from "@microsoft/recognizers-text"; -import { IBooleanExtractorConfiguration } from "../extractors"; -import { GermanChoice } from "../../resources/germanChoice"; - -export class GermanBooleanExtractorConfiguration implements IBooleanExtractorConfiguration { - readonly regexTrue: RegExp; - readonly regexFalse: RegExp; - readonly tokenRegex: RegExp; - readonly emojiSkinToneRegex: RegExp; - readonly onlyTopMatch: boolean; - - constructor(onlyTopMatch: boolean = true) { - this.emojiSkinToneRegex = RegExpUtility.getSafeRegExp(GermanChoice.SkinToneRegex); - this.regexTrue = RegExpUtility.getSafeRegExp(GermanChoice.TrueRegex); - this.regexFalse = RegExpUtility.getSafeRegExp(GermanChoice.FalseRegex); - this.tokenRegex = RegExpUtility.getSafeRegExp(GermanChoice.TokenizerRegex, 'is'); - this.onlyTopMatch = onlyTopMatch; - } -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-choice/src/choice/japanese/boolean.ts b/JavaScript/packages/recognizers-choice/src/choice/japanese/boolean.ts deleted file mode 100644 index bb4e8c1a4e..0000000000 --- a/JavaScript/packages/recognizers-choice/src/choice/japanese/boolean.ts +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { RegExpUtility } from "@microsoft/recognizers-text"; -import { IBooleanExtractorConfiguration } from "../extractors"; -import { JapaneseChoice } from "../../resources/japaneseChoice"; - -export class JapaneseBooleanExtractorConfiguration implements IBooleanExtractorConfiguration { - readonly regexTrue: RegExp; - readonly regexFalse: RegExp; - readonly tokenRegex: RegExp; - readonly emojiSkinToneRegex: RegExp; - readonly onlyTopMatch: boolean; - - constructor(onlyTopMatch: boolean = true) { - this.emojiSkinToneRegex = RegExpUtility.getSafeRegExp(JapaneseChoice.SkinToneRegex); - this.regexTrue = RegExpUtility.getSafeRegExp(JapaneseChoice.TrueRegex); - this.regexFalse = RegExpUtility.getSafeRegExp(JapaneseChoice.FalseRegex); - this.tokenRegex = RegExpUtility.getSafeRegExp(JapaneseChoice.TokenizerRegex, 'is'); - this.onlyTopMatch = onlyTopMatch; - } -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-choice/src/choice/models.ts b/JavaScript/packages/recognizers-choice/src/choice/models.ts deleted file mode 100644 index 571b4015c2..0000000000 --- a/JavaScript/packages/recognizers-choice/src/choice/models.ts +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { IModel, ModelResult, IExtractor, IParser, ParseResult } from "@microsoft/recognizers-text"; - -export abstract class ChoiceModel implements IModel { - public abstract readonly modelTypeName: string; - - protected readonly extractor: IExtractor; - protected readonly parser: IParser; - - constructor(parser: IParser, extractor: IExtractor) { - this.extractor = extractor; - this.parser = parser; - } - - parse(source: string): ModelResult[] { - let parseResults: ParseResult[]; - - try { - let extractResults = this.extractor.extract(source); - parseResults = extractResults.map(r => this.parser.parse(r)); - } - catch (err) { - // Nothing to do. Exceptions in parse should not break users of recognizers. - // No result. - } - finally { - return parseResults - .map(o => o as ParseResult) - .map(o => ({ - start: o.start, - end: o.start + o.length - 1, - resolution: this.getResolution(o), - text: o.text, - typeName: this.modelTypeName - })); - } - } - - protected abstract getResolution(data: any): any; -} - -export class BooleanModel extends ChoiceModel { - public readonly modelTypeName = 'boolean'; - - protected getResolution(sources: any): any { - let results: any = { - value: sources.value, - score: sources.data.score - }; - if (sources.data.otherMatches) { - results.otherResults = sources.data.otherMatches.map(o => ({ - text: o.text, - value: o.value, - score: o.data.score - })); - } - return results; - } -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-choice/src/choice/parsers.ts b/JavaScript/packages/recognizers-choice/src/choice/parsers.ts deleted file mode 100644 index 2a6c415c85..0000000000 --- a/JavaScript/packages/recognizers-choice/src/choice/parsers.ts +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { IParser, ExtractResult, ParseResult } from "@microsoft/recognizers-text"; -import { Constants } from "./constants"; - -export interface IChoiceParserConfiguration { - resolutions: Map; -} - -export class ChoiceParser implements IParser { - private readonly config: IChoiceParserConfiguration; - - constructor(config: IChoiceParserConfiguration) { - this.config = config; - } - - parse(extResult: ExtractResult): ParseResult { - let result = new ParseResult(extResult); - result.value = this.config.resolutions.get(result.type); - if (result.data.otherMatches) { - result.data.otherMatches = result.data.otherMatches.map(m => { - let r = new ParseResult(m); - r.value = this.config.resolutions.get(r.type); - return r; - }); - } - return result; - } -} - -export class BooleanParser extends ChoiceParser { - constructor() { - let resolutions = new Map([ - [Constants.SYS_BOOLEAN_TRUE, true], - [Constants.SYS_BOOLEAN_FALSE, false] - ]); - let config: IChoiceParserConfiguration = { - resolutions: resolutions - }; - super(config); - } -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-choice/src/choice/portuguese/boolean.ts b/JavaScript/packages/recognizers-choice/src/choice/portuguese/boolean.ts deleted file mode 100644 index f0c67f35f7..0000000000 --- a/JavaScript/packages/recognizers-choice/src/choice/portuguese/boolean.ts +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { RegExpUtility } from "@microsoft/recognizers-text"; -import { IBooleanExtractorConfiguration } from "../extractors"; -import { PortugueseChoice } from "../../resources/portugueseChoice"; - -export class PortugueseBooleanExtractorConfiguration implements IBooleanExtractorConfiguration { - readonly regexTrue: RegExp; - readonly regexFalse: RegExp; - readonly tokenRegex: RegExp; - readonly emojiSkinToneRegex: RegExp; - readonly onlyTopMatch: boolean; - - constructor(onlyTopMatch: boolean = true) { - this.emojiSkinToneRegex = RegExpUtility.getSafeRegExp(PortugueseChoice.SkinToneRegex); - this.regexTrue = RegExpUtility.getSafeRegExp(PortugueseChoice.TrueRegex); - this.regexFalse = RegExpUtility.getSafeRegExp(PortugueseChoice.FalseRegex); - this.tokenRegex = RegExpUtility.getSafeRegExp(PortugueseChoice.TokenizerRegex, 'is'); - this.onlyTopMatch = onlyTopMatch; - } -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-choice/src/choice/spanish/boolean.ts b/JavaScript/packages/recognizers-choice/src/choice/spanish/boolean.ts deleted file mode 100644 index 61036b57f3..0000000000 --- a/JavaScript/packages/recognizers-choice/src/choice/spanish/boolean.ts +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { RegExpUtility } from "@microsoft/recognizers-text"; -import { IBooleanExtractorConfiguration } from "../extractors"; -import { SpanishChoice } from "../../resources/spanishChoice"; - -export class SpanishBooleanExtractorConfiguration implements IBooleanExtractorConfiguration { - readonly regexTrue: RegExp; - readonly regexFalse: RegExp; - readonly tokenRegex: RegExp; - readonly emojiSkinToneRegex: RegExp; - readonly onlyTopMatch: boolean; - - constructor(onlyTopMatch: boolean = true) { - this.emojiSkinToneRegex = RegExpUtility.getSafeRegExp(SpanishChoice.SkinToneRegex); - this.regexTrue = RegExpUtility.getSafeRegExp(SpanishChoice.TrueRegex); - this.regexFalse = RegExpUtility.getSafeRegExp(SpanishChoice.FalseRegex); - this.tokenRegex = RegExpUtility.getSafeRegExp(SpanishChoice.TokenizerRegex, 'is'); - this.onlyTopMatch = onlyTopMatch; - } -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-choice/src/recognizers-text-choice.ts b/JavaScript/packages/recognizers-choice/src/recognizers-text-choice.ts deleted file mode 100644 index 78ad8d6e08..0000000000 --- a/JavaScript/packages/recognizers-choice/src/recognizers-text-choice.ts +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -export { default as ChoiceRecognizer, ChoiceOptions, recognizeBoolean } from "./choice/choiceRecognizer"; -export { Culture } from "@microsoft/recognizers-text"; -export { Constants } from "./choice/constants"; -export { ChoiceModel, BooleanModel } from "./choice/models"; -export { IChoiceExtractorConfiguration, ChoiceExtractor, IBooleanExtractorConfiguration, BooleanExtractor } from "./choice/extractors"; -export { IChoiceParserConfiguration, ChoiceParser, BooleanParser } from "./choice/parsers"; -export { ChineseBooleanExtractorConfiguration } from "./choice/chinese/boolean"; -export { DutchBooleanExtractorConfiguration } from "./choice/dutch/boolean"; -export { EnglishBooleanExtractorConfiguration } from "./choice/english/boolean"; -export { FrenchBooleanExtractorConfiguration } from "./choice/french/boolean"; -export { GermanBooleanExtractorConfiguration } from "./choice/german/boolean"; -export { JapaneseBooleanExtractorConfiguration } from "./choice/japanese/boolean"; -export { PortugueseBooleanExtractorConfiguration } from "./choice/portuguese/boolean"; -export { SpanishBooleanExtractorConfiguration } from "./choice/spanish/boolean"; -export { ChineseChoice } from "./resources/chineseChoice"; -export { DutchChoice } from "./resources/dutchChoice"; -export { EnglishChoice } from "./resources/englishChoice"; -export { FrenchChoice } from "./resources/frenchChoice"; -export { GermanChoice } from "./resources/germanChoice"; -export { JapaneseChoice } from "./resources/japaneseChoice"; -export { PortugueseChoice } from "./resources/portugueseChoice"; -export { SpanishChoice } from "./resources/spanishChoice"; \ No newline at end of file diff --git a/JavaScript/packages/recognizers-choice/src/resources/chineseChoice.ts b/JavaScript/packages/recognizers-choice/src/resources/chineseChoice.ts deleted file mode 100644 index 6ee23ec04f..0000000000 --- a/JavaScript/packages/recognizers-choice/src/resources/chineseChoice.ts +++ /dev/null @@ -1,18 +0,0 @@ -// ------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// ------------------------------------------------------------------------------ - -export namespace ChineseChoice { - export const LangMarker = `Chs`; - export const TokenizerRegex = `[^\\u3040-\\u30ff\\u3400-\\u4dbf\\u4e00-\\u9fff\\uf900-\\ufaff\\uff66-\\uff9f]`; - export const SkinToneRegex = `(\\uD83C\\uDFFB|\\uD83C\\uDFFC|\\uD83C\\uDFFD|\\uD83C\\uDFFE|\\uD83C\\uDFFF)`; - export const TrueRegex = `(好[的啊呀嘞哇]|没问题|可以|中|好|同意|行|是的|是|对)|(\\uD83D\\uDC4D|\\uD83D\\uDC4C)${SkinToneRegex}?`; - export const FalseRegex = `(不行|不好|拒绝|否定|不中|不可以|不是的|不是|不对|不)|(\\uD83D\\uDC4E|\\u270B|\\uD83D\\uDD90)${SkinToneRegex}?`; -} diff --git a/JavaScript/packages/recognizers-choice/src/resources/dutchChoice.ts b/JavaScript/packages/recognizers-choice/src/resources/dutchChoice.ts deleted file mode 100644 index e60ac23848..0000000000 --- a/JavaScript/packages/recognizers-choice/src/resources/dutchChoice.ts +++ /dev/null @@ -1,18 +0,0 @@ -// ------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// ------------------------------------------------------------------------------ - -export namespace DutchChoice { - export const LangMarker = `Nl`; - export const TokenizerRegex = `[^\\w\\d]`; - export const SkinToneRegex = `(\\uD83C\\uDFFB|\\uD83C\\uDFFC|\\uD83C\\uDFFD|\\uD83C\\uDFFE|\\uD83C\\uDFFF)`; - export const TrueRegex = `\\b(ja|jawel|jazeker|natuurlijk|vanzelfsprekend|zeker|prima|jep|yes|yep|y|ok|oke|akkoord)\\b|(\\uD83D\\uDC4D|\\uD83D\\uDC4C)${SkinToneRegex}?`; - export const FalseRegex = `\\b(nee|neen|nope|nein|nop|no|niet|nooit)\\b|(\\uD83D\\uDC4E|\\u270B|\\uD83D\\uDD90)${SkinToneRegex}?`; -} diff --git a/JavaScript/packages/recognizers-choice/src/resources/englishChoice.ts b/JavaScript/packages/recognizers-choice/src/resources/englishChoice.ts deleted file mode 100644 index 201d839ccc..0000000000 --- a/JavaScript/packages/recognizers-choice/src/resources/englishChoice.ts +++ /dev/null @@ -1,18 +0,0 @@ -// ------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// ------------------------------------------------------------------------------ - -export namespace EnglishChoice { - export const LangMarker = `Eng`; - export const TokenizerRegex = `[^\\w\\d]`; - export const SkinToneRegex = `(\\uD83C\\uDFFB|\\uD83C\\uDFFC|\\uD83C\\uDFFD|\\uD83C\\uDFFE|\\uD83C\\uDFFF)`; - export const TrueRegex = `\\b(true|yes|yep|yup|yeah|y|sure|ok|agree)\\b|(\\uD83D\\uDC4D|\\uD83D\\uDC4C|\\u0001f44c)${SkinToneRegex}?`; - export const FalseRegex = `\\b(false|nope|nop|no|not\\s+ok|disagree)\\b|(\\uD83D\\uDC4E|\\u270B|\\uD83D\\uDD90|\\u0001F44E|\\u0001F590)${SkinToneRegex}?`; -} diff --git a/JavaScript/packages/recognizers-choice/src/resources/frenchChoice.ts b/JavaScript/packages/recognizers-choice/src/resources/frenchChoice.ts deleted file mode 100644 index 4461c226b0..0000000000 --- a/JavaScript/packages/recognizers-choice/src/resources/frenchChoice.ts +++ /dev/null @@ -1,18 +0,0 @@ -// ------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// ------------------------------------------------------------------------------ - -export namespace FrenchChoice { - export const LangMarker = `Fr`; - export const TokenizerRegex = `[^\\w\\d\\u00E0-\\u00FC]`; - export const SkinToneRegex = `(\\uD83C\\uDFFB|\\uD83C\\uDFFC|\\uD83C\\uDFFD|\\uD83C\\uDFFE|\\uD83C\\uDFFF)`; - export const TrueRegex = `\\b(s[uû]r|ouais|oui|yep|y|sure|approuver|accepter|consentir|d'accord|ça march[eé])\\b|(\\uD83D\\uDC4D|\\uD83D\\uDC4C)${SkinToneRegex}?`; - export const FalseRegex = `\\b(faux|nan|non|pas\\s+d'accord|pas\\s+concorder|n'est\\s+pas\\s+(correct|ok)|pas)\\b|(\\uD83D\\uDC4E|\\u270B|\\uD83D\\uDD90)${SkinToneRegex}?`; -} diff --git a/JavaScript/packages/recognizers-choice/src/resources/germanChoice.ts b/JavaScript/packages/recognizers-choice/src/resources/germanChoice.ts deleted file mode 100644 index b22ad003e6..0000000000 --- a/JavaScript/packages/recognizers-choice/src/resources/germanChoice.ts +++ /dev/null @@ -1,18 +0,0 @@ -// ------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// ------------------------------------------------------------------------------ - -export namespace GermanChoice { - export const LangMarker = `Ger`; - export const TokenizerRegex = `[^\\w\\d\\u00E0-\\u00FC]`; - export const SkinToneRegex = `(\\uD83C\\uDFFB|\\uD83C\\uDFFC|\\uD83C\\uDFFD|\\uD83C\\uDFFE|\\uD83C\\uDFFF)`; - export const TrueRegex = `\\b(wahr|ja|jep|j|sicher|ok|einverstanden|mit\\s+Sicherheit|sicherlich|jap|mache ich)\\b|(\\uD83D\\uDC4D|\\uD83D\\uDC4C)${SkinToneRegex}?`; - export const FalseRegex = `\\b(falsch|nein|ne|nö|nicht\\s+ok|nicht\\s+einverstanden|n)\\b|(\\uD83D\\uDC4E|\\u270B|\\uD83D\\uDD90)${SkinToneRegex}?`; -} diff --git a/JavaScript/packages/recognizers-choice/src/resources/japaneseChoice.ts b/JavaScript/packages/recognizers-choice/src/resources/japaneseChoice.ts deleted file mode 100644 index cb7fa7d9e7..0000000000 --- a/JavaScript/packages/recognizers-choice/src/resources/japaneseChoice.ts +++ /dev/null @@ -1,18 +0,0 @@ -// ------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// ------------------------------------------------------------------------------ - -export namespace JapaneseChoice { - export const LangMarker = `Jpn`; - export const TokenizerRegex = `[^\\w\\d\\u3040-\\u309f\\u30a0-\\u30ff\\uff00-\\uff9f\\u4e00-\\u9faf\\u3400-\\u4dbf]`; - export const SkinToneRegex = `(\\uD83C\\uDFFB|\\uD83C\\uDFFC|\\uD83C\\uDFFD|\\uD83C\\uDFFE|\\uD83C\\uDFFF)`; - export const TrueRegex = `(はい(!)*|そうです|よい(です)*)|(\\uD83D\\uDC4D|\\uD83D\\uDC4C)${SkinToneRegex}?`; - export const FalseRegex = `(いいえ|ではありません|ではない|じゃない|じゃありません)|(\\uD83D\\uDC4E|\\u270B|\\uD83D\\uDD90)${SkinToneRegex}?`; -} diff --git a/JavaScript/packages/recognizers-choice/src/resources/portugueseChoice.ts b/JavaScript/packages/recognizers-choice/src/resources/portugueseChoice.ts deleted file mode 100644 index b09b4366b7..0000000000 --- a/JavaScript/packages/recognizers-choice/src/resources/portugueseChoice.ts +++ /dev/null @@ -1,18 +0,0 @@ -// ------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// ------------------------------------------------------------------------------ - -export namespace PortugueseChoice { - export const LangMarker = `Por`; - export const TokenizerRegex = `[^\\w\\d\\u00E0-\\u00FC]`; - export const SkinToneRegex = `(\\uD83C\\uDFFB|\\uD83C\\uDFFC|\\uD83C\\uDFFD|\\uD83C\\uDFFE|\\uD83C\\uDFFF)`; - export const TrueRegex = `\\b(verdade|verdadeir[oa]|sim|isso|claro|ok)\\b|(\\uD83D\\uDC4D|\\uD83D\\uDC4C)${SkinToneRegex}?`; - export const FalseRegex = `\\b(falso|n[aã]o|incorreto|nada disso)\\b|(\\uD83D\\uDC4E|\\u270B|\\uD83D\\uDD90)${SkinToneRegex}?`; -} diff --git a/JavaScript/packages/recognizers-choice/src/resources/spanishChoice.ts b/JavaScript/packages/recognizers-choice/src/resources/spanishChoice.ts deleted file mode 100644 index d433f30a84..0000000000 --- a/JavaScript/packages/recognizers-choice/src/resources/spanishChoice.ts +++ /dev/null @@ -1,18 +0,0 @@ -// ------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// ------------------------------------------------------------------------------ - -export namespace SpanishChoice { - export const LangMarker = `Spa`; - export const TokenizerRegex = `[^\\w\\d\\u00E0-\\u00FC]`; - export const SkinToneRegex = `(\\uD83C\\uDFFB|\\uD83C\\uDFFC|\\uD83C\\uDFFD|\\uD83C\\uDFFE|\\uD83C\\uDFFF)`; - export const TrueRegex = `\\b(verdad|verdadero|sí|sip|s|si|cierto|por supuesto|ok)\\b|(\\uD83D\\uDC4D|\\uD83D\\uDC4C)${SkinToneRegex}?`; - export const FalseRegex = `\\b(falso|no|nop|n|no)\\b|(\\uD83D\\uDC4E|\\u270B|\\uD83D\\uDD90)${SkinToneRegex}?`; -} diff --git a/JavaScript/packages/recognizers-choice/tsconfig.json b/JavaScript/packages/recognizers-choice/tsconfig.json deleted file mode 100644 index 35ad0e3efa..0000000000 --- a/JavaScript/packages/recognizers-choice/tsconfig.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "target": "es2015", - "outDir": "compiled", - "sourceMap": true, - "rootDir": "src", - "moduleResolution": "node", - "declaration": true, - "declarationDir": "dist/types", - "allowSyntheticDefaultImports": true, - "typeRoots": [ - "node_modules/@types" - ] - }, - "include": [ - "src" - ] -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-date-time/.npmignore b/JavaScript/packages/recognizers-date-time/.npmignore deleted file mode 100644 index 757fb9517d..0000000000 --- a/JavaScript/packages/recognizers-date-time/.npmignore +++ /dev/null @@ -1,4 +0,0 @@ -* -!dist/*.js -!dist/types/**/* -!README.md \ No newline at end of file diff --git a/JavaScript/packages/recognizers-date-time/README.md b/JavaScript/packages/recognizers-date-time/README.md deleted file mode 100644 index 05e1121106..0000000000 --- a/JavaScript/packages/recognizers-date-time/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# Microsoft.Recognizers.Text for JavaScript - -This module (`recognizers-text-date-time`) is a sub-module of `recognizers-text-suite`. - -Please check the [main README](https://github.com/Microsoft/Recognizers-Text/tree/master/JavaScript/packages/recognizers-text-suite) for more details. \ No newline at end of file diff --git a/JavaScript/packages/recognizers-date-time/package-lock.json b/JavaScript/packages/recognizers-date-time/package-lock.json deleted file mode 100644 index baddd840bf..0000000000 --- a/JavaScript/packages/recognizers-date-time/package-lock.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "requires": true, - "lockfileVersion": 1, - "dependencies": { - "lodash.isequal": { - "version": "4.5.0", - "resolved": "https://registry.npmjs.org/lodash.isequal/-/lodash.isequal-4.5.0.tgz", - "integrity": "sha1-QVxEePK8wwEgwizhDtMib30+GOA=" - }, - "lodash.tonumber": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/lodash.tonumber/-/lodash.tonumber-4.0.3.tgz", - "integrity": "sha1-C5azGzVnJ5Prf1pj7nkfG56QJdk=" - } - }, - "version": "1.3.0" -} diff --git a/JavaScript/packages/recognizers-date-time/package.json b/JavaScript/packages/recognizers-date-time/package.json deleted file mode 100644 index 700e802875..0000000000 --- a/JavaScript/packages/recognizers-date-time/package.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "name": "@microsoft/recognizers-text-date-time", - "version": "1.3.0", - "description": "recognizers-text provides robust recognition and resolution of date/time expressed in multiple languages.", - "author": "Microsoft Corp.", - "license": "MIT", - "keywords": [ - "nlp", - "nlp-entity-extraction", - "datetime", - "entity-extraction", - "timex", - "numex", - "parser-library" - ], - "main": "dist/recognizers-text-date-time.umd.js", - "module": "dist/recognizers-text-date-time.es5.js", - "typings": "dist/types/recognizers-text-date-time.d.ts", - "browser": "dist/recognizers-text-date-time.browser.js", - "repository": { - "type": "git", - "url": "https://github.com/Microsoft/Recognizers-Text" - }, - "bugs": { - "url": "https://github.com/Microsoft/Recognizers-Text/issues" - }, - "engines": { - "node": ">=10.3.0" - }, - "scripts": { - "build-resources": "ts-node --project ../resource-generator/tsconfig.json ../resource-generator/ ../recognizers-date-time/resource-definitions.json", - "clean-build": "rimraf dist && rimraf compiled", - "prepare": "npm run build-resources && npm run clean-build && tsc && rollup -c" - }, - "dependencies": { - "lodash.isequal": "^4.5.0", - "lodash.tonumber": "^4.0.3", - "@microsoft/recognizers-text": "~1.3.0", - "@microsoft/recognizers-text-number": "~1.3.0", - "@microsoft/recognizers-text-number-with-unit": "~1.3.0" - } -} diff --git a/JavaScript/packages/recognizers-date-time/resource-definitions.json b/JavaScript/packages/recognizers-date-time/resource-definitions.json deleted file mode 100644 index 5e39c5d202..0000000000 --- a/JavaScript/packages/recognizers-date-time/resource-definitions.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "outputPath": "./src/resources/", - "configFiles": [ - { - "input": [ "Base-DateTime" ], - "output": "baseDateTime", - "header": [ - "export namespace BaseDateTime {" - ], - "footer": [ "}" ] - }, - { - "input": [ "English", "English-DateTime" ], - "output": "englishDateTime", - "header": [ - "import { BaseDateTime } from \"./baseDateTime\";", - "export namespace EnglishDateTime {" - ], - "footer": [ "}" ] - }, - { - "input": [ "Spanish", "Spanish-DateTime" ], - "output": "spanishDateTime", - "header": [ - "import { BaseDateTime } from \"./baseDateTime\";", - "export namespace SpanishDateTime {" - ], - "footer": [ "}" ] - }, - { - "input": [ "Portuguese", "Portuguese-DateTime" ], - "output": "portugueseDateTime", - "header": [ - "import { BaseDateTime } from \"./baseDateTime\";", - "export namespace PortugueseDateTime {" - ], - "footer": [ "}" ] - }, - { - "input": [ "Chinese", "Chinese-DateTime" ], - "output": "chineseDateTime", - "header": [ - "import { BaseDateTime } from \"./baseDateTime\";", - "export namespace ChineseDateTime {" - ], - "footer": [ "}" ] - }, - { - "input": [ "French", "French-DateTime" ], - "output": "frenchDateTime", - "header": [ - "import { BaseDateTime } from \"./baseDateTime\";", - "export namespace FrenchDateTime {" - ], - "footer": [ "}" ] - } - ] -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-date-time/rollup.config.js b/JavaScript/packages/recognizers-date-time/rollup.config.js deleted file mode 100644 index 6a04b3e9e2..0000000000 --- a/JavaScript/packages/recognizers-date-time/rollup.config.js +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import resolve from 'rollup-plugin-node-resolve'; -import commonjs from 'rollup-plugin-commonjs'; -import sourceMaps from 'rollup-plugin-sourcemaps'; -import pkg from './package.json'; -import camelCase from 'lodash.camelcase'; -import alias from 'rollup-plugin-alias'; -import path from 'path'; - -export default { - input: `compiled/recognizers-text-date-time.js`, - output: [ - { file: pkg.module, format: 'es' }, - { file: pkg.main, name: camelCase(pkg.name), format: 'umd', exports: 'named' }, - { file: pkg.browser, format: 'iife', name: camelCase(pkg.name), exports: 'named' } - ], - exports: 'named', - sourcemap: true, - plugins: [ - alias({ - '@microsoft/recognizers-text': path.resolve(__dirname, '../recognizers-text/compiled/recognizers-text.js'), - '@microsoft/recognizers-text-number': path.resolve(__dirname, '../recognizers-number/compiled/recognizers-text-number.js'), - '@microsoft/recognizers-text-number-with-unit': path.resolve(__dirname, '../recognizers-number-with-unit/compiled/recognizers-text-number-with-unit.js') - }), - // Allow bundling cjs modules (unlike webpack, rollup doesn't understand cjs) - commonjs(), - // Allow node_modules resolution, so you can use 'external' to control - // which external modules to include in the bundle - // https://github.com/rollup/rollup-plugin-node-resolve#usage - resolve(), - - // Resolve source maps to the original source - sourceMaps() - ] -}; diff --git a/JavaScript/packages/recognizers-date-time/src/dateTime/baseDate.ts b/JavaScript/packages/recognizers-date-time/src/dateTime/baseDate.ts deleted file mode 100644 index 740692ffb6..0000000000 --- a/JavaScript/packages/recognizers-date-time/src/dateTime/baseDate.ts +++ /dev/null @@ -1,839 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { ExtractResult, RegExpUtility, Match, StringUtility } from "@microsoft/recognizers-text"; -import { Constants, TimeTypeConstants } from "./constants"; -import { Constants as NumberConstants } from "@microsoft/recognizers-text-number"; -import { BaseNumberExtractor, BaseNumberParser } from "@microsoft/recognizers-text-number"; -import { Token, DateTimeFormatUtil, DateTimeResolutionResult, IDateTimeUtilityConfiguration, AgoLaterUtil, AgoLaterMode, DateUtils, DayOfWeek, MatchingUtil } from "./utilities"; -import { IDateTimeExtractor } from "./baseDateTime"; -import { BaseDurationExtractor, BaseDurationParser } from "./baseDuration"; -import { IDateTimeParser, DateTimeParseResult } from "./parsers"; -import toNumber = require("lodash.tonumber"); - -export interface IDateExtractorConfiguration { - dateRegexList: RegExp[], - implicitDateList: RegExp[], - monthEnd: RegExp, - ofMonth: RegExp, - dateUnitRegex: RegExp, - forTheRegex: RegExp, - weekDayAndDayOfMonthRegex: RegExp, - relativeMonthRegex: RegExp, - strictRelativeRegex: RegExp, - weekDayRegex: RegExp, - dayOfWeek: ReadonlyMap; - ordinalExtractor: BaseNumberExtractor, - integerExtractor: BaseNumberExtractor, - numberParser: BaseNumberParser, - durationExtractor: IDateTimeExtractor, - utilityConfiguration: IDateTimeUtilityConfiguration, - rangeConnectorSymbolRegex: RegExp, -} - -export class BaseDateExtractor implements IDateTimeExtractor { - protected readonly extractorName = Constants.SYS_DATETIME_DATE; - protected readonly config: IDateExtractorConfiguration; - - constructor(config: IDateExtractorConfiguration) { - this.config = config; - } - - extract(source: string, refDate: Date): ExtractResult[] { - if (!refDate) { - refDate = new Date(); - } - let referenceDate = refDate; - - let tokens: Token[] = new Array(); - tokens = tokens.concat(this.basicRegexMatch(source)); - tokens = tokens.concat(this.implicitDate(source)); - tokens = tokens.concat(this.numberWithMonth(source, referenceDate)); - tokens = tokens.concat(this.durationWithBeforeAndAfter(source, referenceDate)); - let result = Token.mergeAllTokens(tokens, source, this.extractorName); - return result; - } - - protected basicRegexMatch(source: string): Token[] { - let ret = []; - this.config.dateRegexList.forEach(regexp => { - let matches = RegExpUtility.getMatches(regexp, source); - matches.forEach(match => { - if (this.ValidateMatch(match, source)) { - let preText = source.substring(0, match.index); - let relativeRegex = RegExpUtility.getMatchEnd(this.config.strictRelativeRegex, preText, true); - if (relativeRegex.success) { - ret.push(new Token(relativeRegex.match.index, match.index + match.length)); - } - else { - ret.push(new Token(match.index, match.index + match.length)); - } - } - }); - }); - return ret; - } - - // this method is to validate whether the match is part of date range and is a correct split - // For example: in case "10-1 - 11-7", "10-1 - 11" can be matched by some of the Regexes, but the full text is a date range, so "10-1 - 11" is not a correct split - protected ValidateMatch(match: Match, text: string): boolean { - // If the match doesn't contains "year" part, it will not be ambiguous and it's a valid match - let isValidMatch = match.groups('year') === undefined; - - if (!isValidMatch) { - let yearGroup = match.groups("year"); - - // If the "year" part is not at the end of the match, it's a valid match - if (yearGroup.index + yearGroup.length != match.index + match.length) { - isValidMatch = true; - } - else { - let subText = text.substring(yearGroup.index); - - // If the following text (include the "year" part) doesn't start with a Date entity, it's a valid match - if (!this.StartsWithBasicDate(subText)) { - isValidMatch = true; - } - else { - // If the following text (include the "year" part) starts with a Date entity, but the following text (doesn't include the "year" part) also starts with a valid Date entity, the current match is still valid - // For example, "10-1-2018-10-2-2018". Match "10-1-2018" is valid because though "2018-10-2" a valid match (indicates the first year "2018" might belongs to the second Date entity), but "10-2-2018" is also a valid match. - subText = text.substring(yearGroup.index + yearGroup.length).trim(); - subText = this.TrimStartRangeConnectorSymbols(subText); - isValidMatch = this.StartsWithBasicDate(subText); - } - } - - // Expressions with mixed separators are not considered valid dates e.g. "30/4.85" (unless one is a comma "30/4, 2016") - if (match.groups("day") !== undefined && match.groups("month") !== undefined) { - let noDateText = match.value.replace(match.groups("year").value, "") - .replace(match.groups("month").value, "") - .replace(match.groups("day").value, ""); - let separators = [ '/', '\\', '-', '.' ]; - if (separators.filter(separator => noDateText.indexOf(separator) >= 0).length > 1) { - isValidMatch = false; - } - } - } - - return isValidMatch; - } - - // TODO: Simplify this method to improve its performance - protected TrimStartRangeConnectorSymbols(text: string): string { - let rangeConnectorSymbolMatches = RegExpUtility.getMatches(this.config.rangeConnectorSymbolRegex, text); - - rangeConnectorSymbolMatches.forEach( symbolMatch => { - let startSymbolLength = -1; - - if (symbolMatch && symbolMatch.index === 0 && symbolMatch.length > startSymbolLength) { - startSymbolLength = symbolMatch.length; - } - - if (startSymbolLength > 0) { - text = text.substring(startSymbolLength); - } - }); - - return text.trim(); - } - - // TODO: Simplify this method to improve its performance - protected StartsWithBasicDate(text: string): boolean { - this.config.dateRegexList.forEach(regex => { - let match = RegExpUtility.getMatches(regex, text.trim()).pop(); - - if (match && match.index === 0) { - return true; - } - }); - - return false; - } - - protected implicitDate(source: string): Token[] { - let ret = []; - this.config.implicitDateList.forEach(regexp => { - let matches = RegExpUtility.getMatches(regexp, source); - matches.forEach(match => { - ret.push(new Token(match.index, match.index + match.length)); - }); - }); - return ret; - } - - private numberWithMonth(source: string, refDate: Date): Token[] { - let ret = []; - let er = this.config.ordinalExtractor.extract(source).concat(this.config.integerExtractor.extract(source)); - er.forEach(result => { - let num = toNumber(this.config.numberParser.parse(result).value); - if (num < 1 || num > 31) { - return; - } - if (result.start >= 0) { - let frontString = source.substring(0, result.start | 0); - - // Check that the extracted number is not part of a decimal number, time expression or currency - // (e.g. '123.24', '12:24', '$12') - if (MatchingUtil.isInvalidDayNumberPrefix(frontString)) { - return; - } - - let match = RegExpUtility.getMatches(this.config.monthEnd, frontString)[0]; - if (match && match.length) { - ret.push(new Token(match.index, match.index + match.length + result.length)); - return; - } - - // handling cases like 'for the 25th' - let matches = RegExpUtility.getMatches(this.config.forTheRegex, source); - let isFound = false; - matches.forEach(matchCase => { - if (matchCase) { - let ordinalNum = matchCase.groups('DayOfMonth').value; - if (ordinalNum === result.text) { - let length = matchCase.groups('end').value.length; - ret.push(new Token(matchCase.index, matchCase.index + matchCase.length - length)); - isFound = true; - } - } - }); - - if (isFound) { - return; - } - - // handling cases like 'Thursday the 21st', which both 'Thursday' and '21st' refer to a same date - matches = RegExpUtility.getMatches(this.config.weekDayAndDayOfMonthRegex, source); - matches.forEach(matchCase => { - if (matchCase) { - let ordinalNum = matchCase.groups('DayOfMonth').value; - if (ordinalNum === result.text) { - let month = refDate.getMonth(); - let year = refDate.getFullYear(); - - // get week of day for the ordinal number which is regarded as a date of reference month - let date = DateUtils.safeCreateFromMinValue(year, month, num); - let numWeekDayStr = DayOfWeek[date.getDay()].toString().toLowerCase(); - - // get week day from text directly, compare it with the weekday generated above - // to see whether they refer to a same week day - let extractedWeekDayStr = matchCase.groups("weekday").value.toString().toLowerCase(); - if (date !== DateUtils.minValue() && - this.config.dayOfWeek.get(numWeekDayStr) === this.config.dayOfWeek.get(extractedWeekDayStr)) { - ret.push(new Token(matchCase.index, result.start + result.length)); - isFound = true; - } - } - } - }); - - if (isFound) { - return; - } - - // handling cases like '20th of next month' - let suffixStr = source.substr(result.start + result.length).toLowerCase(); - match = RegExpUtility.getMatches(this.config.relativeMonthRegex, suffixStr.trim()).pop(); - if (match && match.index === 0) { - let spaceLen = suffixStr.length - suffixStr.trim().length; - ret.push(new Token(result.start, result.start + result.length + spaceLen + match.length)); - } - - // handling cases like 'second Sunday' - match = RegExpUtility.getMatches(this.config.weekDayRegex, suffixStr.trim()).pop(); - if (match && match.index === 0 && num >= 1 && num <= 5 - && result.type === NumberConstants.SYS_NUM_ORDINAL) { - let weekDayStr = match.groups('weekday').value; - if (this.config.dayOfWeek.has(weekDayStr)) { - let spaceLen = suffixStr.length - suffixStr.trim().length; - ret.push(new Token(result.start, result.start + result.length + spaceLen + match.length)); - } - } - } - if (result.start + result.length < source.length) { - let afterString = source.substring(result.start + result.length); - let match = RegExpUtility.getMatches(this.config.ofMonth, afterString)[0]; - if (match && match.length) { - ret.push(new Token(result.start, result.start + result.length + match.length)); - return; - } - } - }); - return ret; - } - - protected durationWithBeforeAndAfter(source: string, refDate: Date): Token[] { - let ret = []; - let durEx = this.config.durationExtractor.extract(source, refDate); - durEx.forEach(er => { - let match = RegExpUtility.getMatches(this.config.dateUnitRegex, er.text).pop(); - if (!match) { - return; - } - ret = AgoLaterUtil.extractorDurationWithBeforeAndAfter(source, er, ret, this.config.utilityConfiguration); - }); - return ret; - } -} - -export interface IDateParserConfiguration { - ordinalExtractor: BaseNumberExtractor - integerExtractor: BaseNumberExtractor - cardinalExtractor: BaseNumberExtractor - durationExtractor: IDateTimeExtractor - durationParser: IDateTimeParser - numberParser: BaseNumberParser - monthOfYear: ReadonlyMap - dayOfMonth: ReadonlyMap - dayOfWeek: ReadonlyMap - unitMap: ReadonlyMap - cardinalMap: ReadonlyMap - dateRegex: RegExp[] - onRegex: RegExp - specialDayRegex: RegExp - specialDayWithNumRegex: RegExp - nextRegex: RegExp - unitRegex: RegExp - monthRegex: RegExp - weekDayRegex: RegExp - lastRegex: RegExp - thisRegex: RegExp - weekDayOfMonthRegex: RegExp - forTheRegex: RegExp - weekDayAndDayOfMonthRegex: RegExp - relativeMonthRegex: RegExp - strictRelativeRegex: RegExp - relativeWeekDayRegex: RegExp - utilityConfiguration: IDateTimeUtilityConfiguration - dateTokenPrefix: string - getSwiftDay(source: string): number - getSwiftMonthOrYear(source: string): number - isCardinalLast(source: string): boolean -} - -export class BaseDateParser implements IDateTimeParser { - protected readonly parserName = Constants.SYS_DATETIME_DATE; - protected readonly config: IDateParserConfiguration; - - constructor(config: IDateParserConfiguration) { - this.config = config; - } - - parse(extractorResult: ExtractResult, referenceDate?: Date): DateTimeParseResult | null { - if (!referenceDate) { - referenceDate = new Date(); - } - let resultValue; - if (extractorResult.type === this.parserName) { - let source = extractorResult.text.toLowerCase(); - let innerResult = this.parseBasicRegexMatch(source, referenceDate); - if (!innerResult.success) { - innerResult = this.parseImplicitDate(source, referenceDate); - } - if (!innerResult.success) { - innerResult = this.parseWeekdayOfMonth(source, referenceDate); - } - if (!innerResult.success) { - innerResult = this.parserDurationWithAgoAndLater(source, referenceDate); - } - if (!innerResult.success) { - innerResult = this.parseNumberWithMonth(source, referenceDate); - } - if (!innerResult.success) { - innerResult = this.parseSingleNumber(source, referenceDate); - } - if (innerResult.success) { - innerResult.futureResolution = {}; - innerResult.futureResolution[TimeTypeConstants.DATE] = DateTimeFormatUtil.formatDate(innerResult.futureValue); - innerResult.pastResolution = {}; - innerResult.pastResolution[TimeTypeConstants.DATE] = DateTimeFormatUtil.formatDate(innerResult.pastValue); - resultValue = innerResult; - } - } - let result = new DateTimeParseResult(extractorResult); - result.value = resultValue; - result.timexStr = resultValue ? resultValue.timex : ''; - result.resolutionStr = ''; - - return result; - } - - protected parseBasicRegexMatch(source: string, referenceDate: Date): DateTimeResolutionResult { - let trimmedSource = source.trim(); - let result = new DateTimeResolutionResult(); - this.config.dateRegex.some(regex => { - let offset = 0; - let relativeStr = null; - let match = RegExpUtility.getMatches(regex, trimmedSource).pop(); - if (!match) { - match = RegExpUtility.getMatches(regex, this.config.dateTokenPrefix + trimmedSource).pop(); - if (match) { - offset = this.config.dateTokenPrefix.length; - relativeStr = match.groups('order').value; - } - - } - if (match) { - let relativeRegex = RegExpUtility.getMatchEnd(this.config.strictRelativeRegex, source.substring(0, match.index), true); - let isContainRelative = relativeRegex.success && match.index + match.length === trimmedSource.length; - if ((match.index === offset && match.length === trimmedSource.length) || isContainRelative) { - - if (match.index !== offset) { - relativeStr = relativeRegex.match.value; - } - result = this.matchToDate(match, referenceDate, relativeStr); - return true; - } - } - }); - return result; - } - - protected parseImplicitDate(source: string, referenceDate: Date): DateTimeResolutionResult { - let trimmedSource = source.trim(); - let result = new DateTimeResolutionResult(); - // handle "on 12" - let match = RegExpUtility.getMatches(this.config.onRegex, this.config.dateTokenPrefix + trimmedSource).pop(); - if (match && match.index === this.config.dateTokenPrefix.length && match.length === trimmedSource.length) { - let day = 0; - let month = referenceDate.getMonth(); - let year = referenceDate.getFullYear(); - let dayStr = match.groups('day').value; - day = this.config.dayOfMonth.get(dayStr); - - result.timex = DateTimeFormatUtil.luisDate(-1, -1, day); - - let tryStr = DateTimeFormatUtil.luisDate(year, month, day); - let tryDate = Date.parse(tryStr); - let futureDate: Date; - let pastDate: Date; - - if (tryDate && !isNaN(tryDate)) { - futureDate = DateUtils.safeCreateFromMinValue(year, month, day); - pastDate = DateUtils.safeCreateFromMinValue(year, month, day); - if (futureDate < referenceDate) { - futureDate.setMonth(futureDate.getMonth() + 1); - } - - if (pastDate >= referenceDate) { - pastDate.setMonth(pastDate.getMonth() - 1); - } - } - else { - futureDate = DateUtils.safeCreateFromMinValue(year, month + 1, day); - pastDate = DateUtils.safeCreateFromMinValue(year, month - 1, day); - } - - result.futureValue = futureDate; - result.pastValue = pastDate; - result.success = true; - return result; - } - - // handle "today", "the day before yesterday" - match = RegExpUtility.getMatches(this.config.specialDayRegex, trimmedSource).pop(); - if (match && match.index === 0 && match.length === trimmedSource.length) { - let swift = this.config.getSwiftDay(match.value); - let today = DateUtils.safeCreateFromMinValue(referenceDate.getFullYear(), referenceDate.getMonth(), referenceDate.getDate()); - let value = DateUtils.addDays(today, swift); - result.timex = DateTimeFormatUtil.luisDateFromDate(value); - result.futureValue = value; - result.pastValue = value; - result.success = true; - return result; - } - - // handle "two days from tomorrow" - match = RegExpUtility.getMatches(this.config.specialDayWithNumRegex, trimmedSource).pop(); - if (match && match.index === 0 && match.length === trimmedSource.length) { - let swift = this.config.getSwiftDay(match.groups('day').value); - let numErs = this.config.integerExtractor.extract(trimmedSource); - let numOfDays = Number.parseInt(this.config.numberParser.parse(numErs[0]).value); - - let value = DateUtils.addDays(referenceDate, swift + numOfDays); - result.timex = DateTimeFormatUtil.luisDateFromDate(value); - result.futureValue = value; - result.pastValue = value; - result.success = true; - return result; - } - - // handle "two sundays from now" - match = RegExpUtility.getMatches(this.config.relativeWeekDayRegex, trimmedSource).pop(); - if (match && match.index === 0 && match.length === trimmedSource.length) { - let numErs = this.config.integerExtractor.extract(trimmedSource); - let num = Number.parseInt(this.config.numberParser.parse(numErs[0]).value); - let weekdayStr = match.groups('weekday').value.toLowerCase(); - let value = referenceDate; - - // Check whether the determined day of this week has passed. - if (value.getDay() > this.config.dayOfWeek.get(weekdayStr)) { - num--; - } - - while (num-- > 0) { - value = DateUtils.next(value, this.config.dayOfWeek.get(weekdayStr)); - } - - result.timex = DateTimeFormatUtil.luisDateFromDate(value); - result.futureValue = value; - result.pastValue = value; - result.success = true; - return result; - } - - // handle "next Sunday" - match = RegExpUtility.getMatches(this.config.nextRegex, trimmedSource).pop(); - if (match && match.index === 0 && match.length === trimmedSource.length) { - let weekdayStr = match.groups('weekday').value; - let value = DateUtils.next(referenceDate, this.config.dayOfWeek.get(weekdayStr)); - - result.timex = DateTimeFormatUtil.luisDateFromDate(value); - result.futureValue = value; - result.pastValue = value; - result.success = true; - return result; - } - - // handle "this Friday" - match = RegExpUtility.getMatches(this.config.thisRegex, trimmedSource).pop(); - if (match && match.index === 0 && match.length === trimmedSource.length) { - let weekdayStr = match.groups('weekday').value; - let value = DateUtils.this(referenceDate, this.config.dayOfWeek.get(weekdayStr)); - - result.timex = DateTimeFormatUtil.luisDateFromDate(value); - result.futureValue = value; - result.pastValue = value; - result.success = true; - return result; - } - - // handle "last Friday", "last mon" - match = RegExpUtility.getMatches(this.config.lastRegex, trimmedSource).pop(); - if (match && match.index === 0 && match.length === trimmedSource.length) { - let weekdayStr = match.groups('weekday').value; - let value = DateUtils.last(referenceDate, this.config.dayOfWeek.get(weekdayStr)); - - result.timex = DateTimeFormatUtil.luisDateFromDate(value); - result.futureValue = value; - result.pastValue = value; - result.success = true; - return result; - } - - // handle "Friday" - match = RegExpUtility.getMatches(this.config.weekDayRegex, trimmedSource).pop(); - if (match && match.index === 0 && match.length === trimmedSource.length) { - let weekdayStr = match.groups('weekday').value; - let weekday = this.config.dayOfWeek.get(weekdayStr); - let value = DateUtils.this(referenceDate, this.config.dayOfWeek.get(weekdayStr)); - - if (weekday === 0) { - weekday = 7; - } - if (weekday < referenceDate.getDay()) { - value = DateUtils.next(referenceDate, weekday); - } - result.timex = 'XXXX-WXX-' + weekday; - let futureDate = new Date(value); - let pastDate = new Date(value); - if (futureDate < referenceDate) { - futureDate.setDate(value.getDate() + 7); - } - if (pastDate >= referenceDate) { - pastDate.setDate(value.getDate() - 7); - } - - result.futureValue = futureDate; - result.pastValue = pastDate; - result.success = true; - return result; - } - - // handle "for the 27th." - match = RegExpUtility.getMatches(this.config.forTheRegex, trimmedSource).pop(); - if (match) { - let dayStr = match.groups('DayOfMonth').value; - let er = ExtractResult.getFromText(dayStr); - let day = Number.parseInt(this.config.numberParser.parse(er).value); - - let month = referenceDate.getMonth(); - let year = referenceDate.getFullYear(); - - result.timex = DateTimeFormatUtil.luisDate(-1, -1, day); - let date = new Date(year, month, day); - result.futureValue = date; - result.pastValue = date; - result.success = true; - - return result; - } - - // handling cases like 'Thursday the 21st', which both 'Thursday' and '21st' refer to a same date - match = RegExpUtility.getMatches(this.config.weekDayAndDayOfMonthRegex, trimmedSource).pop(); - if (match) { - let dayStr = match.groups('DayOfMonth').value; - let er = ExtractResult.getFromText(dayStr); - let day = Number.parseInt(this.config.numberParser.parse(er).value); - let month = referenceDate.getMonth(); - let year = referenceDate.getFullYear(); - - // the validity of the phrase is guaranteed in the Date Extractor - result.timex = DateTimeFormatUtil.luisDate(year, month, day); - result.futureValue = new Date(year, month, day); - result.pastValue = new Date(year, month, day); - result.success = true; - - return result; - } - - return result; - } - - private parseNumberWithMonth(source: string, referenceDate: Date): DateTimeResolutionResult { - let trimmedSource = source.trim(); - let ambiguous = true; - let result = new DateTimeResolutionResult(); - - let ers = this.config.ordinalExtractor.extract(trimmedSource); - if (!ers || ers.length === 0) { - ers = this.config.integerExtractor.extract(trimmedSource); - } - if (!ers || ers.length === 0) { - return result; - } - - let num = Number.parseInt(this.config.numberParser.parse(ers[0]).value); - let day = 1; - let month = 0; - - let match = RegExpUtility.getMatches(this.config.monthRegex, trimmedSource).pop(); - if (match) { - month = this.config.monthOfYear.get(match.value) - 1; - day = num; - } - else { - // handling relative month - match = RegExpUtility.getMatches(this.config.relativeMonthRegex, trimmedSource).pop(); - if (match) { - let monthStr = match.groups('order').value; - let swift = this.config.getSwiftMonthOrYear(monthStr); - let date = new Date(referenceDate); - date.setMonth(referenceDate.getMonth() + swift); - month = date.getMonth(); - day = num; - ambiguous = false; - } - } - - // handling casesd like 'second Sunday' - if (!match) { - match = RegExpUtility.getMatches(this.config.weekDayRegex, trimmedSource).pop(); - if (match) { - month = referenceDate.getMonth(); - // resolve the date of wanted week day - let wantedWeekDay = this.config.dayOfWeek.get(match.groups('weekday').value); - let firstDate = DateUtils.safeCreateFromMinValue(referenceDate.getFullYear(), referenceDate.getMonth(), 1); - let firstWeekday = firstDate.getDay(); - let firstWantedWeekDay = new Date(firstDate); - firstWantedWeekDay.setDate(firstDate.getDate() + ((wantedWeekDay > firstWeekday) ? wantedWeekDay - firstWeekday : wantedWeekDay - firstWeekday + 7)); - day = firstWantedWeekDay.getDate() + ((num - 1) * 7); - ambiguous = false; - } - } - - if (!match) { - return result; - } - - let year = referenceDate.getFullYear(); - - // for LUIS format value string - let futureDate = DateUtils.safeCreateFromMinValue(year, month, day); - let pastDate = DateUtils.safeCreateFromMinValue(year, month, day); - - if (ambiguous) { - result.timex = DateTimeFormatUtil.luisDate(-1, month, day); - if (futureDate < referenceDate) { - futureDate.setFullYear(year + 1); - } - if (pastDate >= referenceDate) { - pastDate.setFullYear(year - 1); - } - } - else { - result.timex = DateTimeFormatUtil.luisDate(year, month, day); - } - - result.futureValue = futureDate; - result.pastValue = pastDate; - result.success = true; - return result; - } - - // handle cases like "the 27th". In the extractor, only the unmatched weekday and date will output this date. - private parseSingleNumber(source: string, referenceDate: Date): DateTimeResolutionResult { - let trimmedSource = source.trim(); - let result = new DateTimeResolutionResult(); - - let er = this.config.ordinalExtractor.extract(trimmedSource).pop(); - if (!er || StringUtility.isNullOrEmpty(er.text)) { - er = this.config.integerExtractor.extract(trimmedSource).pop(); - } - if (!er || StringUtility.isNullOrEmpty(er.text)) { - return result; - } - - let day = Number.parseInt(this.config.numberParser.parse(er).value); - let month = referenceDate.getMonth(); - let year = referenceDate.getFullYear(); - - result.timex = DateTimeFormatUtil.luisDate(-1, -1, day); - let pastDate = DateUtils.safeCreateFromMinValue(year, month, day); - let futureDate = DateUtils.safeCreateFromMinValue(year, month, day); - - if (futureDate !== DateUtils.minValue() && futureDate < referenceDate) { - futureDate.setMonth(month + 1); - } - if (pastDate !== DateUtils.minValue() && pastDate >= referenceDate) { - pastDate.setMonth(month - 1); - } - - result.futureValue = futureDate; - result.pastValue = pastDate; - result.success = true; - return result; - } - - protected parserDurationWithAgoAndLater(source: string, referenceDate: Date): DateTimeResolutionResult { - return AgoLaterUtil.parseDurationWithAgoAndLater( - source, - referenceDate, - this.config.durationExtractor, - this.config.durationParser, - this.config.unitMap, - this.config.unitRegex, - this.config.utilityConfiguration, - AgoLaterMode.Date - ); - } - - protected parseWeekdayOfMonth(source: string, referenceDate: Date): DateTimeResolutionResult { - let trimmedSource = source.trim(); - let result = new DateTimeResolutionResult(); - let match = RegExpUtility.getMatches(this.config.weekDayOfMonthRegex, trimmedSource).pop(); - if (!match) { - return result; - } - let cardinalStr = match.groups('cardinal').value; - let weekdayStr = match.groups('weekday').value; - let monthStr = match.groups('month').value; - let noYear = false; - let cardinal = this.config.isCardinalLast(cardinalStr) ? 5 : this.config.cardinalMap.get(cardinalStr); - let weekday = this.config.dayOfWeek.get(weekdayStr); - let month = referenceDate.getMonth(); - let year = referenceDate.getFullYear(); - if (StringUtility.isNullOrEmpty(monthStr)) { - let swift = this.config.getSwiftMonthOrYear(trimmedSource); - let temp = new Date(referenceDate); - temp.setMonth(referenceDate.getMonth() + swift); - month = temp.getMonth(); - year = temp.getFullYear(); - } - else { - month = this.config.monthOfYear.get(monthStr) - 1; - noYear = true; - } - let value = this.computeDate(cardinal, weekday, month, year); - if (value.getMonth() !== month) { - cardinal -= 1; - value.setDate(value.getDate() - 7); - } - let futureDate = value; - let pastDate = value; - if (noYear && futureDate < referenceDate) { - futureDate = this.computeDate(cardinal, weekday, month, year + 1); - if (futureDate.getMonth() !== month) { - futureDate.setDate(futureDate.getDate() - 7); - } - } - if (noYear && pastDate >= referenceDate) { - pastDate = this.computeDate(cardinal, weekday, month, year - 1); - if (pastDate.getMonth() !== month) { - pastDate.setDate(pastDate.getDate() - 7); - } - } - result.timex = ['XXXX', DateTimeFormatUtil.toString(month + 1, 2), 'WXX', weekday, '#' + cardinal].join('-'); - result.futureValue = futureDate; - result.pastValue = pastDate; - result.success = true; - return result; - } - - protected matchToDate(match: Match, referenceDate: Date, relativeStr: string): DateTimeResolutionResult { - let result = new DateTimeResolutionResult(); - let yearStr = match.groups('year').value; - let monthStr = match.groups('month').value; - let dayStr = match.groups('day').value; - let weekdayStr = match.groups('weekday').value; - let month = 0; - let day = 0; - let year = 0; - if (this.config.monthOfYear.has(monthStr) && this.config.dayOfMonth.has(dayStr)) { - month = this.config.monthOfYear.get(monthStr) - 1; - day = this.config.dayOfMonth.get(dayStr); - if (!StringUtility.isNullOrEmpty(yearStr)) { - year = Number.parseInt(yearStr, 10); - if (year < 100 && year >= Constants.MinTwoDigitYearPastNum) { - year += 1900; - } - else if (year >= 0 && year < Constants.MaxTwoDigitYearFutureNum) { - year += 2000; - } - } - } - let noYear = false; - if (year === 0) { - year = referenceDate.getFullYear(); - result.timex = DateTimeFormatUtil.luisDate(-1, month, day); - if (!StringUtility.isNullOrEmpty(relativeStr)) { - let swift = this.config.getSwiftMonthOrYear(relativeStr); - if (!StringUtility.isNullOrEmpty(weekdayStr)) { - swift = 0; - } - year += swift; - } - else { - noYear = true; - } - - } - else { - result.timex = DateTimeFormatUtil.luisDate(year, month, day); - } - - let futurePastDates = DateUtils.generateDates(noYear, referenceDate, year, month, day); - - result.futureValue = futurePastDates.future; - result.pastValue = futurePastDates.past; - result.success = true; - return result; - } - - private computeDate(cardinal: number, weekday: number, month: number, year: number) { - let firstDay = new Date(year, month, 1); - let firstWeekday = DateUtils.this(firstDay, weekday); - let dayOfWeekOfFirstDay = firstDay.getDay(); - if (weekday === 0) { - weekday = 7; - } - if (dayOfWeekOfFirstDay === 0) { - dayOfWeekOfFirstDay = 7; - } - if (weekday < dayOfWeekOfFirstDay) { - firstWeekday = DateUtils.next(firstDay, weekday); - } - firstWeekday.setDate(firstWeekday.getDate() + (7 * (cardinal - 1))); - return firstWeekday; - } -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-date-time/src/dateTime/baseDatePeriod.ts b/JavaScript/packages/recognizers-date-time/src/dateTime/baseDatePeriod.ts deleted file mode 100644 index 93650772be..0000000000 --- a/JavaScript/packages/recognizers-date-time/src/dateTime/baseDatePeriod.ts +++ /dev/null @@ -1,1341 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { IExtractor, ExtractResult, RegExpUtility, Match, StringUtility } from "@microsoft/recognizers-text"; -import { Constants, TimeTypeConstants } from "./constants"; -import { BaseNumberExtractor, BaseNumberParser } from "@microsoft/recognizers-text-number"; -import { Token, DateTimeFormatUtil, DateTimeResolutionResult, DateUtils, DayOfWeek, StringMap, AbstractYearExtractor, TimexUtil } from "./utilities"; -import { BaseDurationExtractor, BaseDurationParser } from "./baseDuration"; -import { IDateTimeParser, DateTimeParseResult } from "./parsers"; -import { BaseDateExtractor, BaseDateParser } from "./baseDate"; -import { IDateTimeExtractor } from "./baseDateTime"; -import toNumber = require("lodash.tonumber"); - -export interface IDatePeriodExtractorConfiguration { - simpleCasesRegexes: RegExp[] - illegalYearRegex: RegExp - YearRegex: RegExp - tillRegex: RegExp - followedUnit: RegExp - numberCombinedWithUnit: RegExp - pastRegex: RegExp - futureRegex: RegExp - weekOfRegex: RegExp - monthOfRegex: RegExp - dateUnitRegex: RegExp - inConnectorRegex: RegExp - rangeUnitRegex: RegExp - nowRegex: RegExp - datePointExtractor: IDateTimeExtractor - integerExtractor: BaseNumberExtractor - numberParser: BaseNumberParser - durationExtractor: IDateTimeExtractor - getFromTokenIndex(source: string): { matched: boolean, index: number }; - getBetweenTokenIndex(source: string): { matched: boolean, index: number }; - hasConnectorToken(source: string): boolean; -} - -export class BaseDatePeriodExtractor implements IDateTimeExtractor { - protected readonly extractorName = Constants.SYS_DATETIME_DATEPERIOD; - protected readonly config: IDatePeriodExtractorConfiguration; - - constructor(config: IDatePeriodExtractorConfiguration) { - this.config = config; - } - - extract(source: string, refDate: Date): ExtractResult[] { - if (!refDate) { - refDate = new Date(); - } - let referenceDate = refDate; - - let tokens: Token[] = new Array(); - tokens = tokens.concat(this.matchSimpleCases(source)); - tokens = tokens.concat(this.mergeTwoTimePoints(source, referenceDate)); - tokens = tokens.concat(this.matchDuration(source, referenceDate)); - tokens = tokens.concat(this.singleTimePointWithPatterns(source, referenceDate)); - let result = Token.mergeAllTokens(tokens, source, this.extractorName); - return result; - } - - protected matchSimpleCases(source: string): Token[] { - let tokens: Token[] = new Array(); - this.config.simpleCasesRegexes.forEach(regexp => { - RegExpUtility.getMatches(regexp, source).forEach(match => { - let addToken = true; - let matchYear = RegExpUtility.getMatches(this.config.YearRegex, match.value).pop(); - if (matchYear && matchYear.length === match.value.length) { - let yearStr = matchYear.groups('year').value; - if (StringUtility.isNullOrEmpty(yearStr)) { - let year = AbstractYearExtractor.getYearFromText(matchYear, this.config.numberParser); - if (!(year >= Constants.MinYearNum && year <= Constants.MaxYearNum)) { - addToken = false; - } - } - } - - if (match.length === Constants.FourDigitsYearLength && RegExpUtility.isMatch(this.config.YearRegex, match.value) && this.infixBoundaryCheck(match, source)) { - let substr = source.substr(match.index - 1, 6); - if (RegExpUtility.isMatch(this.config.illegalYearRegex, substr)) { - addToken = false; - } - } - - if (addToken) { - tokens.push(new Token(match.index, match.index + match.length)); - } - }); - }); - return tokens; - } - - protected mergeTwoTimePoints(source: string, refDate: Date): Token[] { - let tokens: Token[] = new Array(); - let er = this.config.datePointExtractor.extract(source, refDate); - if (er.length <= 1) { - let matches = RegExpUtility.getMatches(this.config.nowRegex, source); - if (matches.length) { - let nowEr = new ExtractResult(); - nowEr.start = matches[0].index; - nowEr.length = matches[0].length; - er.push(nowEr); - er = er.sort((x, y) => (x.start - y.start)); - } - else { - return tokens; - } - - } - - let idx = 0; - while (idx < er.length - 1) { - let middleBegin = er[idx].start + (er[idx].length || 0); - let middleEnd = er[idx + 1].start || 0; - if (middleBegin >= middleEnd) { - idx++; - continue; - } - let middleStr = source.substr(middleBegin, middleEnd - middleBegin).trim().toLowerCase(); - let match = RegExpUtility.getMatches(this.config.tillRegex, middleStr); - if (match && match.length > 0 && match[0].index === 0 && match[0].length === middleStr.length) { - let periodBegin = er[idx].start || 0; - let periodEnd = (er[idx + 1].start || 0) + (er[idx + 1].length || 0); - - let beforeStr = source.substring(0, periodBegin).trim().toLowerCase(); - let fromTokenIndex = this.config.getFromTokenIndex(beforeStr); - let betweenTokenIndex = this.config.getBetweenTokenIndex(beforeStr); - if (fromTokenIndex.matched || betweenTokenIndex.matched) { - periodBegin = fromTokenIndex.matched ? fromTokenIndex.index : betweenTokenIndex.index; - } - tokens.push(new Token(periodBegin, periodEnd)); - idx += 2; - continue; - } - - if (this.config.hasConnectorToken(middleStr)) { - let periodBegin = er[idx].start || 0; - let periodEnd = (er[idx + 1].start || 0) + (er[idx + 1].length || 0); - - let beforeStr = source.substring(0, periodBegin).trim().toLowerCase(); - let betweenTokenIndex = this.config.getBetweenTokenIndex(beforeStr); - if (betweenTokenIndex.matched) { - periodBegin = betweenTokenIndex.index; - tokens.push(new Token(periodBegin, periodEnd)); - idx += 2; - continue; - } - } - idx++; - } - return tokens; - } - - private matchDuration(source: string, refDate: Date): Token[] { - let tokens: Token[] = new Array(); - let durations: Token[] = new Array(); - this.config.durationExtractor.extract(source, refDate).forEach(durationEx => { - let match = RegExpUtility.getMatches(this.config.dateUnitRegex, durationEx.text).pop(); - if (match) { - durations.push(new Token(durationEx.start, durationEx.start + durationEx.length)); - } - }); - durations.forEach(duration => { - let beforeStr = source.substring(0, duration.start).toLowerCase(); - if (StringUtility.isNullOrWhitespace(beforeStr)) { - return; - } - let match = RegExpUtility.getMatches(this.config.pastRegex, beforeStr).pop(); - if (this.matchRegexInPrefix(beforeStr, match)) { - tokens.push(new Token(match.index, duration.end)); - return; - } - match = RegExpUtility.getMatches(this.config.futureRegex, beforeStr).pop(); - if (this.matchRegexInPrefix(beforeStr, match)) { - tokens.push(new Token(match.index, duration.end)); - return; - } - }); - return tokens; - } - - private singleTimePointWithPatterns(source: string, refDate: Date): Token[] { - let tokens: Token[] = new Array(); - let ers = this.config.datePointExtractor.extract(source, refDate); - if (ers.length < 1) { - return tokens; - } - ers.forEach(er => { - if (er.start && er.length) { - let beforeStr = source.substring(0, er.start); - tokens = tokens - .concat(this.getTokenForRegexMatching(beforeStr, this.config.weekOfRegex, er)) - .concat(this.getTokenForRegexMatching(beforeStr, this.config.monthOfRegex, er)); - } - }); - return tokens; - } - - private getTokenForRegexMatching(source: string, regexp: RegExp, er: ExtractResult): Token[] { - let tokens: Token[] = new Array(); - let match = RegExpUtility.getMatches(regexp, source).shift(); - if (match && source.trim().endsWith(match.value.trim())) { - let startIndex = source.lastIndexOf(match.value); - tokens.push(new Token(startIndex, er.start + er.length)); - } - return tokens; - } - - private matchRegexInPrefix(source: string, match: Match): boolean { - return (match && StringUtility.isNullOrWhitespace(source.substring(match.index + match.length))); - } - - private infixBoundaryCheck(match: Match, source: string): boolean { - let isMatchInfixOfSource = false; - if (match.index > 0 && match.index + match.length < source.length) { - if (source.substr(match.index, match.length) === match.value) { - isMatchInfixOfSource = true; - } - } - - return isMatchInfixOfSource; - } -} - -export interface IDatePeriodParserConfiguration { - dateExtractor: IDateTimeExtractor - dateParser: BaseDateParser - durationExtractor: IDateTimeExtractor - durationParser: BaseDurationParser - integerExtractor: BaseNumberExtractor - numberParser: BaseNumberParser - monthFrontBetweenRegex: RegExp - betweenRegex: RegExp - monthFrontSimpleCasesRegex: RegExp - simpleCasesRegex: RegExp - oneWordPeriodRegex: RegExp - monthWithYear: RegExp - monthNumWithYear: RegExp - yearRegex: RegExp - relativeRegex: RegExp - pastRegex: RegExp - futureRegex: RegExp - inConnectorRegex: RegExp - weekOfMonthRegex: RegExp - weekOfYearRegex: RegExp - quarterRegex: RegExp - quarterRegexYearFront: RegExp - allHalfYearRegex: RegExp - seasonRegex: RegExp - weekOfRegex: RegExp - monthOfRegex: RegExp - whichWeekRegex: RegExp - restOfDateRegex: RegExp - laterEarlyPeriodRegex: RegExp - weekWithWeekDayRangeRegex: RegExp - unspecificEndOfRangeRegex: RegExp - nowRegex: RegExp - tokenBeforeDate: string - dayOfMonth: ReadonlyMap - monthOfYear: ReadonlyMap - cardinalMap: ReadonlyMap - seasonMap: ReadonlyMap - unitMap: ReadonlyMap - getSwiftDayOrMonth(source: string): number - getSwiftYear(source: string): number - isFuture(source: string): boolean - isYearToDate(source: string): boolean - isMonthToDate(source: string): boolean - isWeekOnly(source: string): boolean - isWeekend(source: string): boolean - isMonthOnly(source: string): boolean - isYearOnly(source: string): boolean - isLastCardinal(source: string): boolean -} - -export class BaseDatePeriodParser implements IDateTimeParser { - protected readonly parserName = Constants.SYS_DATETIME_DATEPERIOD; - protected readonly config: IDatePeriodParserConfiguration; - - protected readonly inclusiveEndPeriod; - private readonly weekOfComment = 'WeekOf'; - private readonly monthOfComment = 'MonthOf'; - - constructor(config: IDatePeriodParserConfiguration, inclusiveEndPeriod = false) { - this.config = config; - this.inclusiveEndPeriod = inclusiveEndPeriod; - } - - parse(extractorResult: ExtractResult, referenceDate?: Date): DateTimeParseResult | null { - if (!referenceDate) { - referenceDate = new Date(); - } - let resultValue; - if (extractorResult.type === this.parserName) { - let source = extractorResult.text.trim().toLowerCase(); - let innerResult = this.parseMonthWithYear(source, referenceDate); - if (!innerResult.success) { - innerResult = this.parseSimpleCases(source, referenceDate); - } - if (!innerResult.success) { - innerResult = this.parseOneWordPeriod(source, referenceDate); - } - if (!innerResult.success) { - innerResult = this.mergeTwoTimePoints(source, referenceDate); - } - if (!innerResult.success) { - innerResult = this.parseYear(source, referenceDate); - } - if (!innerResult.success) { - innerResult = this.parseWeekOfMonth(source, referenceDate); - } - if (!innerResult.success) { - innerResult = this.parseWeekOfYear(source, referenceDate); - } - if (!innerResult.success) { - innerResult = this.parseHalfYear(source, referenceDate); - } - if (!innerResult.success) { - innerResult = this.parseQuarter(source, referenceDate); - } - if (!innerResult.success) { - innerResult = this.parseSeason(source, referenceDate); - } - if (!innerResult.success) { - innerResult = this.parseWhichWeek(source, referenceDate); - } - if (!innerResult.success) { - innerResult = this.parseWeekOfDate(source, referenceDate); - } - if (!innerResult.success) { - innerResult = this.parseMonthOfDate(source, referenceDate); - } - - // parse duration should be at the end since it will extract "the last week" from "the last week of July" - if (!innerResult.success) { - innerResult = this.parseDuration(source, referenceDate); - } - - if (innerResult.success) { - if (innerResult.futureValue && innerResult.pastValue) { - - innerResult.futureResolution = {}; - innerResult.futureResolution[TimeTypeConstants.START_DATE] = DateTimeFormatUtil.formatDate(innerResult.futureValue[0]); - innerResult.futureResolution[TimeTypeConstants.END_DATE] = DateTimeFormatUtil.formatDate(innerResult.futureValue[1]); - innerResult.pastResolution = {}; - innerResult.pastResolution[TimeTypeConstants.START_DATE] = DateTimeFormatUtil.formatDate(innerResult.pastValue[0]); - innerResult.pastResolution[TimeTypeConstants.END_DATE] = DateTimeFormatUtil.formatDate(innerResult.pastValue[1]); - - } - else { - innerResult.futureResolution = {}; - innerResult.pastResolution = {}; - } - resultValue = innerResult; - } - } - let result = new DateTimeParseResult(extractorResult); - result.value = resultValue; - result.timexStr = resultValue ? resultValue.timex : ''; - result.resolutionStr = ''; - - return result; - } - - private parseMonthWithYear(source: string, referenceDate: Date): DateTimeResolutionResult { - let trimmedSource = source.trim().toLowerCase(); - let result = new DateTimeResolutionResult(); - let match = RegExpUtility.getMatches(this.config.monthWithYear, trimmedSource).pop(); - if (!match) { - match = RegExpUtility.getMatches(this.config.monthNumWithYear, trimmedSource).pop(); - } - if (!match || match.length !== trimmedSource.length) { - return result; - } - - let monthStr = match.groups('month').value; - let yearStr = match.groups('year').value; - let orderStr = match.groups('order').value; - - let month = this.config.monthOfYear.get(monthStr) - 1; - let year = Number.parseInt(yearStr, 10); - if (!year || isNaN(year)) { - let swift = this.config.getSwiftYear(orderStr); - if (swift < -1) { - return result; - } - year = referenceDate.getFullYear() + swift; - } - let beginDate = DateUtils.safeCreateFromValue(DateUtils.minValue(), year, month, 1); - let endDate = DateUtils.addDays(DateUtils.addMonths(beginDate, 1), this.inclusiveEndPeriod ? -1 : 0); - result.futureValue = [beginDate, endDate]; - result.pastValue = [beginDate, endDate]; - result.timex = `${DateTimeFormatUtil.toString(year, 4)}-${DateTimeFormatUtil.toString(month + 1, 2)}`; - result.success = true; - return result; - } - - protected getMatchSimpleCase(source: string): Match { - let match = RegExpUtility.getMatches(this.config.monthFrontBetweenRegex, source).pop(); - if (!match) { - match = RegExpUtility.getMatches(this.config.betweenRegex, source).pop(); - } - if (!match) { - match = RegExpUtility.getMatches(this.config.monthFrontSimpleCasesRegex, source).pop(); - } - if (!match) { - match = RegExpUtility.getMatches(this.config.simpleCasesRegex, source).pop(); - } - return match; - } - - protected parseSimpleCases(source: string, referenceDate: Date): DateTimeResolutionResult { - let result = new DateTimeResolutionResult(); - let year = referenceDate.getFullYear(); - let month = referenceDate.getMonth(); - let noYear = true; - - let match = this.getMatchSimpleCase(source); - - if (!match || match.index !== 0 || match.length !== source.length) { - return result; - } - let days = match.groups('day'); - let beginDay = this.config.dayOfMonth.get(days.captures[0]); - let endDay = this.config.dayOfMonth.get(days.captures[1]); - let yearStr = match.groups('year').value; - if (!StringUtility.isNullOrEmpty(yearStr)) { - year = Number.parseInt(yearStr, 10); - noYear = false; - } - let monthStr = match.groups('month').value; - if (!StringUtility.isNullOrEmpty(monthStr)) { - month = this.config.monthOfYear.get(monthStr) - 1; - } - else { - monthStr = match.groups('relmonth').value; - month += this.config.getSwiftDayOrMonth(monthStr); - if (month < 0) { - month = 0; - year--; - } - else if (month > 11) { - month = 11; - year++; - } - - if (this.config.isFuture(monthStr)) { - noYear = false; - } - } - let beginDateLuis = DateTimeFormatUtil.luisDate(noYear ? -1 : year, month, beginDay); - let endDateLuis = DateTimeFormatUtil.luisDate(noYear ? -1 : year, month, endDay); - - let futureYear = year; - let pastYear = year; - let startDate = DateUtils.safeCreateFromValue(DateUtils.minValue(), year, month, beginDay); - if (noYear && startDate < referenceDate) { - futureYear++; - } - if (noYear && startDate >= referenceDate) { - pastYear--; - } - - result.timex = `(${beginDateLuis},${endDateLuis},P${endDay - beginDay}D)`; - result.futureValue = [ - DateUtils.safeCreateFromValue(DateUtils.minValue(), futureYear, month, beginDay), - DateUtils.safeCreateFromValue(DateUtils.minValue(), futureYear, month, endDay), - ]; - result.pastValue = [ - DateUtils.safeCreateFromValue(DateUtils.minValue(), pastYear, month, beginDay), - DateUtils.safeCreateFromValue(DateUtils.minValue(), pastYear, month, endDay), - ]; - result.success = true; - return result; - } - - private isPresent(swift: number): boolean { - return swift === 0; - } - - protected parseOneWordPeriod(source: string, referenceDate: Date): DateTimeResolutionResult { - let result = new DateTimeResolutionResult(); - let year = referenceDate.getFullYear(); - let month = referenceDate.getMonth(); - let earlyPrefix = false; - let latePrefix = false; - let midPrefix = false; - let isRef = false; - - let earlierPrefix = false; - let laterPrefix = false; - - if (this.config.isYearToDate(source)) { - result.timex = DateTimeFormatUtil.toString(year, 4); - result.futureValue = [DateUtils.safeCreateFromValue(DateUtils.minValue(), year, 0, 1), referenceDate]; - result.pastValue = [DateUtils.safeCreateFromValue(DateUtils.minValue(), year, 0, 1), referenceDate]; - result.success = true; - return result; - } - if (this.config.isMonthToDate(source)) { - result.timex = `${DateTimeFormatUtil.toString(year, 4)}-${DateTimeFormatUtil.toString(month + 1, 2)}`; - result.futureValue = [DateUtils.safeCreateFromValue(DateUtils.minValue(), year, month, 1), referenceDate]; - result.pastValue = [DateUtils.safeCreateFromValue(DateUtils.minValue(), year, month, 1), referenceDate]; - result.success = true; - return result; - } - - let futureYear = year; - let pastYear = year; - let trimedText = source.trim().toLowerCase(); - let match = RegExpUtility.getMatches(this.config.oneWordPeriodRegex, trimedText).pop(); - - if (!(match && match.index === 0 && match.length === trimedText.length)) { - match = RegExpUtility.getMatches(this.config.laterEarlyPeriodRegex, trimedText).pop(); - } - - if (!match || match.index !== 0 || match.length !== trimedText.length) { - return result; - } - - if (match.groups("EarlyPrefix").value) { - earlyPrefix = true; - trimedText = match.groups("suffix").value; - result.mod = Constants.EARLY_MOD; - } - - if (match.groups("LatePrefix").value) { - latePrefix = true; - trimedText = match.groups("suffix").value; - result.mod = Constants.LATE_MOD; - } - - if (match.groups("MidPrefix").value) { - latePrefix = true; - trimedText = match.groups("suffix").value; - result.mod = Constants.MID_MOD; - } - - let monthStr = match.groups('month').value; - let swift = 0; - if (!StringUtility.isNullOrEmpty(monthStr)) { - swift = this.config.getSwiftYear(trimedText); - } - else { - swift = this.config.getSwiftDayOrMonth(trimedText); - } - - if (RegExpUtility.isMatch(this.config.unspecificEndOfRangeRegex, match.value)) { - latePrefix = true; - trimedText = match.value; - result.mod = Constants.LATE_MOD; - } - - if (match.groups("RelEarly").value) { - earlierPrefix = true; - if (this.isPresent(swift)) { - result.mod = null; - } - } - - if (match.groups("RelLate").value) { - laterPrefix = true; - if (this.isPresent(swift)) { - result.mod = null; - } - } - - if (!StringUtility.isNullOrEmpty(monthStr)) { - swift = this.config.getSwiftYear(trimedText); - month = this.config.monthOfYear.get(monthStr) - 1; - if (swift >= -1) { - result.timex = `${DateTimeFormatUtil.toString(year + swift, 4)}-${DateTimeFormatUtil.toString(month + 1, 2)}`; - year += swift; - futureYear = year; - pastYear = year; - } - else { - result.timex = `XXXX-${DateTimeFormatUtil.toString(month + 1, 2)}`; - if (month < referenceDate.getMonth()) { - futureYear++; - } - if (month >= referenceDate.getMonth()) { - pastYear--; - } - } - } - else { - swift = this.config.getSwiftDayOrMonth(trimedText); - if (this.config.isWeekOnly(trimedText)) { - let monday = DateUtils.addDays(DateUtils.this(referenceDate, DayOfWeek.Monday), 7 * swift); - let weekNumber = DateUtils.getWeekNumber(monday); - - result.timex = `${DateTimeFormatUtil.toString(weekNumber.year, 4)}-W${DateTimeFormatUtil.toString(weekNumber.weekNo, 2)}`; - - let beginDate = DateUtils.addDays(DateUtils.this(referenceDate, DayOfWeek.Monday), 7 * swift); - let endDate = this.inclusiveEndPeriod - ? DateUtils.addDays(DateUtils.this(referenceDate, DayOfWeek.Sunday), 7 * swift) - : DateUtils.addDays( - DateUtils.addDays(DateUtils.this(referenceDate, DayOfWeek.Sunday), 7 * swift), 1); - - if (earlyPrefix) { - endDate = this.inclusiveEndPeriod - ? DateUtils.addDays(DateUtils.this(referenceDate, DayOfWeek.Wednesday), 7 * swift) - : DateUtils.addDays( - DateUtils.addDays(DateUtils.this(referenceDate, DayOfWeek.Wednesday), 7 * swift), 1); - } - - if (latePrefix) { - beginDate = DateUtils.addDays(DateUtils.this(referenceDate, DayOfWeek.Thursday), 7 * swift); - } - - if (earlierPrefix && swift === 0) { - if (endDate > referenceDate) { - endDate = referenceDate; - } - } - else if (laterPrefix && swift === 0) { - if (beginDate < referenceDate) { - beginDate = referenceDate; - } - } - - result.futureValue = [beginDate, endDate]; - result.pastValue = [beginDate, endDate]; - result.success = true; - return result; - } - if (this.config.isWeekend(trimedText)) { - let beginDate = DateUtils.addDays(DateUtils.this(referenceDate, DayOfWeek.Saturday), 7 * swift); - let endDate = DateUtils.addDays(DateUtils.this(referenceDate, DayOfWeek.Sunday), (7 * swift) + (this.inclusiveEndPeriod ? 0 : 1)); - - result.timex = `${DateTimeFormatUtil.toString(beginDate.getFullYear(), 4)}-W${DateTimeFormatUtil.toString(DateUtils.getWeekNumber(beginDate).weekNo, 2)}-WE`; - result.futureValue = [beginDate, endDate]; - result.pastValue = [beginDate, endDate]; - result.success = true; - return result; - } - if (this.config.isMonthOnly(trimedText)) { - let tempDate = new Date(referenceDate); - tempDate.setMonth(referenceDate.getMonth() + swift); - month = tempDate.getMonth(); - year = tempDate.getFullYear(); - result.timex = `${DateTimeFormatUtil.toString(year, 4)}-${DateTimeFormatUtil.toString(month + 1, 2)}`; - futureYear = year; - pastYear = year; - } - else if (this.config.isYearOnly(trimedText)) { - let tempDate = new Date(referenceDate); - tempDate.setFullYear(referenceDate.getFullYear() + swift); - year = tempDate.getFullYear(); - let beginDate = DateUtils.safeCreateFromMinValue(year, 0, 1); - let endDate = this.inclusiveEndPeriod - ? DateUtils.safeCreateFromMinValue(year, 11, 31) - : DateUtils.addDays( - DateUtils.safeCreateFromMinValue(year, 11, 31), 1); - if (earlyPrefix) { - endDate = this.inclusiveEndPeriod - ? DateUtils.safeCreateFromMinValue(year, 5, 30) - : DateUtils.addDays( - DateUtils.safeCreateFromMinValue(year, 5, 30), 1); - } - if (latePrefix) { - beginDate = DateUtils.safeCreateFromMinValue(year, 6, 1); - } - - if (earlierPrefix && swift === 0) { - if (endDate > referenceDate) { - endDate = referenceDate; - } - } - else if (laterPrefix && swift === 0) { - if (beginDate < referenceDate) { - beginDate = referenceDate; - } - } - - result.timex = DateTimeFormatUtil.toString(year, 4); - result.futureValue = [beginDate, endDate]; - result.pastValue = [beginDate, endDate]; - result.success = true; - return result; - } - } - - // only "month" will come to here - let futureStart = DateUtils.safeCreateFromMinValue(futureYear, month, 1); - let futureEnd = this.inclusiveEndPeriod - ? DateUtils.addDays( - DateUtils.addMonths( - DateUtils.safeCreateFromMinValue(futureYear, month, 1), 1), -1) - : DateUtils.addMonths( - DateUtils.safeCreateFromMinValue(futureYear, month, 1), 1); - let pastStart = DateUtils.safeCreateFromMinValue(pastYear, month, 1); - let pastEnd = this.inclusiveEndPeriod - ? DateUtils.addDays( - DateUtils.addMonths( - DateUtils.safeCreateFromMinValue(pastYear, month, 1), 1), -1) - : DateUtils.addMonths( - DateUtils.safeCreateFromMinValue(pastYear, month, 1), 1); - if (earlyPrefix) { - futureEnd = this.inclusiveEndPeriod - ? DateUtils.safeCreateFromMinValue(futureYear, month, 15) - : DateUtils.addDays( - DateUtils.safeCreateFromMinValue(futureYear, month, 15), 1); - pastEnd = this.inclusiveEndPeriod - ? DateUtils.safeCreateFromMinValue(pastYear, month, 15) - : DateUtils.addDays( - DateUtils.safeCreateFromMinValue(pastYear, month, 15), 1); - } - else if (latePrefix) { - futureStart = DateUtils.safeCreateFromMinValue(futureYear, month, 16); - pastStart = DateUtils.safeCreateFromMinValue(pastYear, month, 16); - } - - if (earlierPrefix && futureYear === pastYear) { - if (futureEnd > referenceDate) { - futureEnd = pastEnd = referenceDate; - } - } - else if (laterPrefix && futureYear === pastYear) { - if (futureStart < referenceDate) { - futureStart = pastStart = referenceDate; - } - } - - result.futureValue = [futureStart, futureEnd]; - result.pastValue = [pastStart, pastEnd]; - result.success = true; - return result; - } - - protected mergeTwoTimePoints(source: string, referenceDate: Date): DateTimeResolutionResult { - let trimmedSource = source.trim(); - let result = new DateTimeResolutionResult(); - let ers = this.config.dateExtractor.extract(trimmedSource, referenceDate); - let prs: DateTimeParseResult[] = []; - if (!ers || ers.length < 2) { - ers = this.config.dateExtractor.extract(this.config.tokenBeforeDate + trimmedSource, referenceDate); - if (ers.length >= 2) { - ers = ers.map(er => { - er.start -= this.config.tokenBeforeDate.length; - return er; - }); - } - else { - let nowPr = this.parseNowAsDate(source, referenceDate); - if (!nowPr || !nowPr.start || ers.length < 1) { - return result; - } - let dataPr = this.config.dateParser.parse(ers[0], referenceDate); - prs.push(dataPr); - prs.push(nowPr); - prs = prs.sort((x, y) => (x.start - y.start)); - } - } - - if (ers.length >= 2) { - let match = RegExpUtility.getMatches(this.config.weekWithWeekDayRangeRegex, source).pop(); - let weekPrefix: string = null; - if (match) { - weekPrefix = match.groups("week").value; - } - - if (!StringUtility.isNullOrWhitespace(weekPrefix)) { - ers[0].text = weekPrefix + " " + ers[0].text; - ers[1].text = weekPrefix + " " + ers[1].text; - } - - prs = ers.map(er => this.config.dateParser.parse(er, referenceDate)).filter(pr => pr); - } - - if (prs.length < 2) { - return result; - } - - let prBegin = prs[0]; - let prEnd = prs[1]; - - if (ers.length >= 2) { - let matchYear = DateUtils.getYear(this.config, ers[0].text, ers[1].text, source); - if (matchYear != -1) { - prBegin = DateUtils.processDateEntityParsingResult(prBegin, matchYear); - prEnd = DateUtils.processDateEntityParsingResult(prEnd, matchYear); - } - - // When the case has no specified year, we should sync the future/past year due to invalid date Feb 29th. - if (matchYear == -1 && (DateUtils.isFeb29thDate(prBegin.value.futureValue) || DateUtils.isFeb29thDate(prEnd.value.futureValue))) { - let pastFuture = DateUtils.syncYear(prBegin, prEnd); - prBegin = pastFuture.pr1; - prEnd = pastFuture.pr2; - } - } - - let futureBegin = prBegin.value.futureValue; - let futureEnd = prEnd.value.futureValue; - let pastBegin = prBegin.value.pastValue; - let pastEnd = prEnd.value.pastValue; - - if (futureBegin > futureEnd) { - futureBegin = pastBegin; - } - - if (pastEnd < pastBegin) { - pastEnd = futureEnd; - } - - result.subDateTimeEntities = prs; - result.timex = TimexUtil.generateDatePeriodTimex(futureBegin, futureEnd, Constants.ByDay, prBegin.timexStr, prEnd.timexStr); - if (prBegin.timexStr.startsWith(Constants.TimexFuzzyYear) && futureBegin <= DateUtils.safeCreateFromMinValue(futureBegin.getFullYear(), 1, 28) && futureEnd >= DateUtils.safeCreateFromMinValue(futureBegin.getFullYear(), 2, 1)) { - // Handle cases like "2月28日到3月1日". - // There may be different timexes for FutureValue and PastValue due to the different validity of Feb 29th. - result.comment = Constants.Comment_DoubleTimex; - let pastTimex = TimexUtil.generateDatePeriodTimex(pastBegin, pastEnd, Constants.ByDay, prBegin.timexStr, prEnd.timexStr); - result.timex = TimexUtil.mergeTimexAlternatives(result.timex, pastTimex); - } - - result.futureValue = [futureBegin, futureEnd]; - result.pastValue = [pastBegin, pastEnd]; - result.success = true; - return result; - } - - protected parseNowAsDate(source: string, referenceDate: Date): DateTimeParseResult { - let pr = new DateTimeParseResult(); - let matches = RegExpUtility.getMatches(this.config.nowRegex, source); - if (matches.length) { - let value = DateUtils.safeCreateFromMinValue(referenceDate.getFullYear(), referenceDate.getMonth(), referenceDate.getDate()); - let retNow = new DateTimeResolutionResult(); - retNow.timex = DateTimeFormatUtil.luisDateFromDate(value); - retNow.futureValue = value; - retNow.pastValue = value; - pr.text = matches[0].value; - pr.start = matches[0].index; - pr.length = matches[0].length; - pr.value = retNow; - pr.timexStr = retNow.timex; - } - return pr; - } - - protected parseYear(source: string, referenceDate: Date): DateTimeResolutionResult { - let trimmedSource = source.trim(); - let result = new DateTimeResolutionResult(); - let match = RegExpUtility.getMatches(this.config.yearRegex, trimmedSource).pop(); - if (!match || match.length !== trimmedSource.length) { - return result; - } - - let year = AbstractYearExtractor.getYearFromText(match, this.config.numberParser); - let beginDate = DateUtils.safeCreateFromValue(DateUtils.minValue(), year, 0, 1); - let endDate = DateUtils.addDays(DateUtils.safeCreateFromValue(DateUtils.minValue(), year + 1, 0, 1), this.inclusiveEndPeriod ? -1 : 0); - result.timex = DateTimeFormatUtil.toString(year, 4); - result.futureValue = [beginDate, endDate]; - result.pastValue = [beginDate, endDate]; - result.success = true; - return result; - } - - protected parseDuration(source: string, referenceDate: Date): DateTimeResolutionResult { - let result = new DateTimeResolutionResult(); - let ers = this.config.durationExtractor.extract(source, referenceDate); - let beginDate = new Date(referenceDate); - let endDate = new Date(referenceDate); - let restNowSunday = false; - let durationTimex = ''; - - if (ers.length === 1) { - let pr = this.config.durationParser.parse(ers[0]); - if (pr === null) { - return result; - } - - let isMatch = false; - let beforeStr = source.substr(0, pr.start).trim(); - let mod: string; - let durationResult: DateTimeResolutionResult = pr.value; - if (StringUtility.isNullOrEmpty(durationResult.timex)) { - return result; - } - - let prefixMatch = RegExpUtility.getMatches(this.config.pastRegex, beforeStr).pop(); - if (prefixMatch) { - mod = TimeTypeConstants.beforeMod; - beginDate = this.getSwiftDate(endDate, durationResult.timex, false); - } - prefixMatch = RegExpUtility.getMatches(this.config.futureRegex, beforeStr).pop(); - if (prefixMatch && prefixMatch.length === beforeStr.length) { - mod = TimeTypeConstants.afterMod; - // for future the beginDate should add 1 first - beginDate = new Date(referenceDate.getFullYear(), referenceDate.getMonth(), referenceDate.getDate() + 1); - endDate = this.getSwiftDate(beginDate, durationResult.timex, true); - isMatch = true; - } - prefixMatch = RegExpUtility.getMatches(this.config.inConnectorRegex, beforeStr).pop(); - if (prefixMatch && prefixMatch.length === beforeStr.length && !isMatch) { - mod = TimeTypeConstants.afterMod; - beginDate = new Date(referenceDate.getFullYear(), referenceDate.getMonth(), referenceDate.getDate() + 1); - endDate = this.getSwiftDate(beginDate, durationResult.timex, true); - - let unit = durationResult.timex.substr(durationResult.timex.length - 1); - durationResult.timex = `P1${unit}`; - beginDate = this.getSwiftDate(endDate, durationResult.timex, false); - } - - if (mod) { - pr.value.mod = mod; - } - - durationTimex = durationResult.timex; - result.subDateTimeEntities = [pr]; - } - - // parse rest of - let match = RegExpUtility.getMatches(this.config.restOfDateRegex, source).pop(); - if (match) { - - let diffDays = 0; - let durationStr = match.groups('duration').value; - let durationUnit = this.config.unitMap.get(durationStr); - switch (durationUnit) { - case 'W': - diffDays = 7 - ((beginDate.getDay() === 0) ? 7 : beginDate.getDay()); - endDate = DateUtils.addDays(referenceDate, diffDays); - restNowSunday = (diffDays === 0); - break; - case 'MON': - endDate = DateUtils.safeCreateFromMinValue(beginDate.getFullYear(), beginDate.getMonth(), 1); - endDate.setMonth(beginDate.getMonth() + 1); - endDate.setDate(endDate.getDate() - 1); - diffDays = endDate.getDate() - beginDate.getDate() + 1; - break; - case 'Y': - endDate = DateUtils.safeCreateFromMinValue(beginDate.getFullYear(), 11, 1); - endDate.setMonth(endDate.getMonth() + 1); - endDate.setDate(endDate.getDate() - 1); - diffDays = DateUtils.dayOfYear(endDate) - DateUtils.dayOfYear(beginDate) + 1; - break; - } - durationTimex = `P${diffDays}D`; - } - - if (beginDate.getTime() !== endDate.getTime() || restNowSunday) { - endDate = DateUtils.addDays(endDate, this.inclusiveEndPeriod ? -1 : 0); - result.timex = `(${DateTimeFormatUtil.luisDateFromDate(beginDate)},${DateTimeFormatUtil.luisDateFromDate(endDate)},${durationTimex})`; - result.futureValue = [beginDate, endDate]; - result.pastValue = [beginDate, endDate]; - result.success = true; - } - - return result; - } - - private getSwiftDate(date: Date, timex: string, isPositiveSwift: boolean): Date { - let result = new Date(date); - let numStr = timex.replace('P', '').substr(0, timex.length - 2); - let unitStr = timex.substr(timex.length - 1); - let swift = Number.parseInt(numStr, 10) || 0; - if (swift === 0) { - return result; - } - - if (!isPositiveSwift) { - swift *= -1; - } - switch (unitStr) { - case 'D': result.setDate(date.getDate() + swift); break; - case 'W': result.setDate(date.getDate() + (7 * swift)); break; - case 'M': result.setMonth(date.getMonth() + swift); break; - case 'Y': result.setFullYear(date.getFullYear() + swift); break; - } - return result; - } - - protected parseWeekOfMonth(source: string, referenceDate: Date): DateTimeResolutionResult { - let result = new DateTimeResolutionResult(); - let match = RegExpUtility.getMatches(this.config.weekOfMonthRegex, source).pop(); - if (!match || match.length !== source.length) { - return result; - } - - let cardinalStr = match.groups('cardinal').value; - let monthStr = match.groups('month').value; - let month = referenceDate.getMonth(); - let year = referenceDate.getFullYear(); - let noYear = false; - let cardinal = this.config.isLastCardinal(cardinalStr) ? 5 - : this.config.cardinalMap.get(cardinalStr); - if (StringUtility.isNullOrEmpty(monthStr)) { - let relMonthValue = match.groups('relmonth').value; - let monthStr = !StringUtility.isNullOrEmpty(relMonthValue) ? relMonthValue : source; - - let swift = this.config.getSwiftDayOrMonth(monthStr); - let tempDate = new Date(referenceDate); - tempDate.setMonth(referenceDate.getMonth() + swift); - month = tempDate.getMonth(); - year = tempDate.getFullYear(); - } - else { - month = this.config.monthOfYear.get(monthStr) - 1; - noYear = true; - } - return this.getWeekOfMonth(cardinal, month, year, referenceDate, noYear); - } - - protected getWeekOfMonth(cardinal: number, month: number, year: number, referenceDate: Date, noYear: boolean): DateTimeResolutionResult { - let result = new DateTimeResolutionResult(); - let seedDate = this.computeDate(cardinal, 1, month, year); - let isLastCardinal = cardinal == 5; - - if (seedDate.getMonth() !== month) { - cardinal--; - seedDate.setDate(seedDate.getDate() - 7); - } - let futureDate = new Date(seedDate); - let pastDate = new Date(seedDate); - if (noYear && futureDate < referenceDate) { - futureDate = this.computeDate(cardinal, 1, month, year + 1); - if (futureDate.getMonth() !== month) { - futureDate.setDate(futureDate.getDate() - 7); - } - } - if (noYear && pastDate >= referenceDate) { - pastDate = this.computeDate(cardinal, 1, month, year - 1); - if (pastDate.getMonth() !== month) { - pastDate.setDate(pastDate.getDate() - 7); - } - } - - let adjustedCardinal = isLastCardinal ? 5 : cardinal; - result.timex = noYear ? - `XXXX-${DateTimeFormatUtil.toString(month + 1, 2)}-W${DateTimeFormatUtil.toString(adjustedCardinal, 2)}` : - `${DateTimeFormatUtil.toString(year, 4)}-${DateTimeFormatUtil.toString(month + 1, 2)}-W${DateTimeFormatUtil.toString(adjustedCardinal, 2)}`; - result.futureValue = [futureDate, DateUtils.addDays(futureDate, this.inclusiveEndPeriod ? 6 : 7)]; - result.pastValue = [pastDate, DateUtils.addDays(pastDate, this.inclusiveEndPeriod ? 6 : 7)]; - result.success = true; - return result; - } - - private parseWeekOfYear(source: string, referenceDate: Date): DateTimeResolutionResult { - let result = new DateTimeResolutionResult(); - let match = RegExpUtility.getMatches(this.config.weekOfYearRegex, source).pop(); - if (!match || match.length !== source.length) { - return result; - } - - let cardinalStr = match.groups('cardinal').value; - let yearStr = match.groups('year').value; - let orderStr = match.groups('order').value; - - let year = Number.parseInt(yearStr, 10); - if (isNaN(year)) { - let swift = this.config.getSwiftYear(orderStr); - if (swift < -1) { - return result; - } - year = referenceDate.getFullYear() + swift; - } - - let targetWeekMonday: Date; - if (this.config.isLastCardinal(cardinalStr)) { - let lastDay = DateUtils.safeCreateFromMinValue(year, 11, 31); - let lastDayWeekMonday = DateUtils.this(lastDay, DayOfWeek.Monday); - let weekNum = DateUtils.getWeekNumber(lastDay).weekNo; - if (weekNum === 1) { - lastDayWeekMonday = DateUtils.this(DateUtils.addDays(lastDay, -7), DayOfWeek.Monday); - } - - targetWeekMonday = lastDayWeekMonday; - weekNum = DateUtils.getWeekNumber(targetWeekMonday).weekNo; - - result.timex = `${DateTimeFormatUtil.toString(year, 4)}-W${DateTimeFormatUtil.toString(weekNum, 2)}`; - } - else { - let cardinal = this.config.cardinalMap.get(cardinalStr); - - let firstDay = DateUtils.safeCreateFromMinValue(year, 0, 1); - let firstDayWeekMonday = DateUtils.this(firstDay, DayOfWeek.Monday); - let weekNum = DateUtils.getWeekNumber(firstDay).weekNo; - if (weekNum !== 1) { - firstDayWeekMonday = DateUtils.this(DateUtils.addDays(firstDay, 7), DayOfWeek.Monday); - } - - targetWeekMonday = DateUtils.addDays(firstDayWeekMonday, 7 * (cardinal - 1)); - result.timex = `${DateTimeFormatUtil.toString(year, 4)}-W${DateTimeFormatUtil.toString(cardinal, 2)}`; - } - - result.futureValue = [targetWeekMonday, DateUtils.addDays(targetWeekMonday, this.inclusiveEndPeriod ? 6 : 7)]; - result.pastValue = [targetWeekMonday, DateUtils.addDays(targetWeekMonday, this.inclusiveEndPeriod ? 6 : 7)]; - result.success = true; - - return result; - } - - protected parseHalfYear(source: string, referenceDate: Date): DateTimeResolutionResult { - let result = new DateTimeResolutionResult(); - let match = RegExpUtility.getMatches(this.config.allHalfYearRegex, source).pop(); - if (!match || match.length !== source.length) { - return result; - } - - let cardinalStr = match.groups('cardinal').value; - let yearStr = match.groups('year').value; - let orderStr = match.groups('order').value; - let numberStr = match.groups('number').value; - - let year = Number.parseInt(yearStr, 10); - - if (isNaN(year)) { - let swift = this.config.getSwiftYear(orderStr); - if (swift < -1) { - return result; - } - year = referenceDate.getFullYear() + swift; - } - - let quarterNum: number; - if (!numberStr) { - quarterNum = this.config.cardinalMap.get(cardinalStr); - } - else { - quarterNum = parseInt(numberStr); - } - - let beginDate = DateUtils.safeCreateDateResolveOverflow(year, (quarterNum - 1) * Constants.SemesterMonthCount, 1); - let endDate = DateUtils.safeCreateDateResolveOverflow(year, quarterNum * Constants.SemesterMonthCount, 1); - - result.futureValue = [beginDate, endDate]; - result.pastValue = [beginDate, endDate]; - result.timex = `(${DateTimeFormatUtil.luisDateFromDate(beginDate)},${DateTimeFormatUtil.luisDateFromDate(endDate)},P6M)`; - result.success = true; - return result; - } - - protected parseQuarter(source: string, referenceDate: Date): DateTimeResolutionResult { - let result = new DateTimeResolutionResult(); - let match = RegExpUtility.getMatches(this.config.quarterRegex, source).pop(); - if (!match || match.length !== source.length) { - match = RegExpUtility.getMatches(this.config.quarterRegexYearFront, source).pop(); - } - if (!match || match.length !== source.length) { - return result; - } - - let cardinalStr = match.groups('cardinal').value; - let yearStr = match.groups('year').value; - let orderQuarterStr = match.groups('orderQuarter').value; - let orderStr = StringUtility.isNullOrEmpty(orderQuarterStr) ? match.groups('order').value : ''; - let numberStr = match.groups('number').value; - - let noSpecificYear = false; - let year = Number.parseInt(yearStr, 10); - - if (isNaN(year)) { - let swift = StringUtility.isNullOrEmpty(orderQuarterStr) ? this.config.getSwiftYear(orderStr) : 0; - if (swift < -1) { - swift = 0; - noSpecificYear = true; - } - year = referenceDate.getFullYear() + swift; - } - - let quarterNum: number; - let numOfQuarters = 0; - if (!StringUtility.isNullOrEmpty(cardinalStr)) { - quarterNum = this.config.cardinalMap.get(cardinalStr); - } - else if (!StringUtility.isNullOrEmpty(orderQuarterStr)) { - let month = referenceDate.getMonth() + 1; - quarterNum = Math.ceil(month / Constants.TrimesterMonthCount); - let swift = this.config.getSwiftYear(orderQuarterStr); - quarterNum += swift; - let numStr = match.groups('num').value; - let er = this.config.integerExtractor.extract(numStr); - if (er.length === 1) { - numOfQuarters = toNumber(this.config.numberParser.parse(er[0]).value) - 1 ; - } - - if (numOfQuarters > 0 && swift >= 0) { - quarterNum += numOfQuarters; - } - - if (quarterNum <= 0) { - quarterNum += Constants.QuarterCount; - year -= 1; - } - else if (quarterNum > Constants.QuarterCount) { - year += quarterNum / Constants.QuarterCount; - quarterNum = quarterNum % Constants.QuarterCount; - } - } - else { - quarterNum = parseInt(numberStr); - } - - let beginDate = DateUtils.safeCreateDateResolveOverflow(year, (quarterNum - 1) * Constants.TrimesterMonthCount, 1); - let endDate = DateUtils.safeCreateDateResolveOverflow(year, quarterNum * Constants.TrimesterMonthCount, 1); - beginDate = DateUtils.addMonths(beginDate, -numOfQuarters * Constants.TrimesterMonthCount); - - if (noSpecificYear) { - if (endDate < referenceDate) { - result.pastValue = [beginDate, endDate]; - - let futureBeginDate = DateUtils.safeCreateDateResolveOverflow(year + 1, (quarterNum - 1) * Constants.TrimesterMonthCount, 1); - let futureEndDate = DateUtils.safeCreateDateResolveOverflow(year + 1, quarterNum * Constants.TrimesterMonthCount, 1); - result.futureValue = [futureBeginDate, futureEndDate]; - } - else if (endDate > referenceDate) { - result.futureValue = [beginDate, endDate]; - - let pastBeginDate = DateUtils.safeCreateDateResolveOverflow(year - 1, (quarterNum - 1) * Constants.TrimesterMonthCount, 1); - let pastEndDate = DateUtils.safeCreateDateResolveOverflow(year - 1, quarterNum * Constants.TrimesterMonthCount, 1); - result.pastValue = [pastBeginDate, pastEndDate]; - } - else { - result.futureValue = [beginDate, endDate]; - result.pastValue = [beginDate, endDate]; - } - - result.timex = `(${DateTimeFormatUtil.luisDate(-1, beginDate.getMonth(), 1)},${DateTimeFormatUtil.luisDate(-1, endDate.getMonth(), 1)},P3M)`; - } - else { - result.futureValue = [beginDate, endDate]; - result.pastValue = [beginDate, endDate]; - let unitCount = (((endDate.getFullYear() - beginDate.getFullYear()) * 12) + (endDate.getMonth() - beginDate.getMonth())).toString(); - result.timex = `(${DateTimeFormatUtil.luisDateFromDate(beginDate)},${DateTimeFormatUtil.luisDateFromDate(endDate)},P${unitCount}M)`; - } - - result.success = true; - return result; - } - - protected parseSeason(source: string, referenceDate: Date): DateTimeResolutionResult { - let result = new DateTimeResolutionResult(); - let match = RegExpUtility.getMatches(this.config.seasonRegex, source).pop(); - if (!match || match.length !== source.length) { - return result; - } - - let swift = this.config.getSwiftYear(source); - let yearStr = match.groups('year').value; - let year = referenceDate.getFullYear(); - let seasonStr = match.groups('seas').value; - let season = this.config.seasonMap.get(seasonStr); - if (swift >= -1 || !StringUtility.isNullOrEmpty(yearStr)) { - if (StringUtility.isNullOrEmpty(yearStr)) { - yearStr = DateTimeFormatUtil.toString(year + swift, 4); - } - result.timex = `${yearStr}-${season}`; - } - else { - result.timex = season; - } - result.success = true; - return result; - } - - private parseWhichWeek(source: string, referenceDate: Date): DateTimeResolutionResult { - let result = new DateTimeResolutionResult(); - let match = RegExpUtility.getMatches(this.config.whichWeekRegex, source).pop(); - if (!match) { - return result; - } - let num = Number.parseInt(match.groups('number').value, 10); - let year = referenceDate.getFullYear(); - result.timex = `${DateTimeFormatUtil.toString(year, 4)}-W${DateTimeFormatUtil.toString(num, 2)}`; - - let firstDay = DateUtils.safeCreateFromValue(DateUtils.minValue(), year, 0, 1); - let firstThursday = DateUtils.this(firstDay, DayOfWeek.Thursday); - let firstWeek = DateUtils.getWeekNumber(firstThursday).weekNo; - if (firstWeek === 1) { - num -= 1; - } - - let resultDate = DateUtils.addDays(firstThursday, 7 * num - 3); - - result.futureValue = [resultDate, DateUtils.addDays(resultDate, 7)]; - result.pastValue = [resultDate, DateUtils.addDays(resultDate, 7)]; - result.success = true; - return result; - } - - private parseWeekOfDate(source: string, referenceDate: Date): DateTimeResolutionResult { - let result = new DateTimeResolutionResult(); - let match = RegExpUtility.getMatches(this.config.weekOfRegex, source).pop(); - let ers = this.config.dateExtractor.extract(source, referenceDate); - if (!match || ers.length !== 1) { - return result; - } - - let dateResolution: DateTimeResolutionResult = this.config.dateParser.parse(ers[0], referenceDate).value; - result.timex = dateResolution.timex; - result.comment = this.weekOfComment; - result.futureValue = this.getWeekRangeFromDate(dateResolution.futureValue); - result.pastValue = this.getWeekRangeFromDate(dateResolution.pastValue); - result.success = true; - return result; - } - - private parseMonthOfDate(source: string, referenceDate: Date): DateTimeResolutionResult { - let result = new DateTimeResolutionResult(); - let match = RegExpUtility.getMatches(this.config.monthOfRegex, source).pop(); - let ers = this.config.dateExtractor.extract(source, referenceDate); - if (!match || ers.length !== 1) { - return result; - } - - let dateResolution: DateTimeResolutionResult = this.config.dateParser.parse(ers[0], referenceDate).value; - result.timex = dateResolution.timex; - result.comment = this.monthOfComment; - result.futureValue = this.getMonthRangeFromDate(dateResolution.futureValue); - result.pastValue = this.getMonthRangeFromDate(dateResolution.pastValue); - result.success = true; - return result; - } - - protected computeDate(cardinal: number, weekday: number, month: number, year: number) { - let firstDay = new Date(year, month, 1); - let firstWeekday = DateUtils.this(firstDay, weekday); - if (weekday === 0) { - weekday = 7; - } - let firstDayOfWeek = firstDay.getDay() !== 0 ? firstDay.getDay() : 7; - if (weekday < firstDayOfWeek) { - firstWeekday = DateUtils.next(firstDay, weekday); - } - firstWeekday.setDate(firstWeekday.getDate() + (7 * (cardinal - 1))); - return firstWeekday; - } - - private getWeekRangeFromDate(seedDate: Date): Date[] { - let beginDate = DateUtils.this(seedDate, DayOfWeek.Monday); - let endDate = DateUtils.addDays(beginDate, this.inclusiveEndPeriod ? 6 : 7); - return [beginDate, endDate]; - } - - private getMonthRangeFromDate(seedDate: Date): Date[] { - let beginDate = DateUtils.safeCreateFromValue(DateUtils.minValue(), seedDate.getFullYear(), seedDate.getMonth(), 1); - let endDate = DateUtils.safeCreateFromValue(DateUtils.minValue(), seedDate.getFullYear(), seedDate.getMonth() + 1, 1); - endDate.setDate(endDate.getDate() + (this.inclusiveEndPeriod ? -1 : 0)); - return [beginDate, endDate]; - } -} diff --git a/JavaScript/packages/recognizers-date-time/src/dateTime/baseDateTime.ts b/JavaScript/packages/recognizers-date-time/src/dateTime/baseDateTime.ts deleted file mode 100644 index abc41eeb4b..0000000000 --- a/JavaScript/packages/recognizers-date-time/src/dateTime/baseDateTime.ts +++ /dev/null @@ -1,539 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { IExtractor, ExtractResult, RegExpUtility, StringUtility } from "@microsoft/recognizers-text"; -import { Constants, TimeTypeConstants } from "./constants"; -import { BaseNumberExtractor, BaseNumberParser } from "@microsoft/recognizers-text-number"; -import { BaseDateExtractor, BaseDateParser } from "./baseDate"; -import { BaseTimeExtractor, BaseTimeParser } from "./baseTime"; -import { BaseDurationExtractor, BaseDurationParser } from "./baseDuration"; -import { IDateTimeParser, DateTimeParseResult } from "./parsers"; -import { DateTimeFormatUtil, Token, IDateTimeUtilityConfiguration, AgoLaterUtil, AgoLaterMode, DateTimeResolutionResult, StringMap } from "./utilities"; - -export interface IDateTimeExtractor { - extract(input: string, refDate?: Date): ExtractResult[] -} - -export interface IDateTimeExtractorConfiguration { - datePointExtractor: IDateTimeExtractor - timePointExtractor: IDateTimeExtractor - durationExtractor: IDateTimeExtractor - suffixRegex: RegExp - nowRegex: RegExp - timeOfTodayAfterRegex: RegExp - simpleTimeOfTodayAfterRegex: RegExp - nightRegex: RegExp - timeOfTodayBeforeRegex: RegExp - simpleTimeOfTodayBeforeRegex: RegExp - specificEndOfRegex: RegExp - unspecificEndOfRegex: RegExp - unitRegex: RegExp - utilityConfiguration: IDateTimeUtilityConfiguration - isConnectorToken(source: string): boolean -} - -export class BaseDateTimeExtractor implements IDateTimeExtractor { - protected readonly extractorName = Constants.SYS_DATETIME_DATETIME; - protected readonly config: IDateTimeExtractorConfiguration; - - constructor(config: IDateTimeExtractorConfiguration) { - this.config = config; - } - - extract(source: string, refDate: Date): ExtractResult[] { - if (!refDate) { - refDate = new Date(); - } - let referenceDate = refDate; - - let tokens: Token[] = new Array(); - tokens = tokens.concat(this.mergeDateAndTime(source, referenceDate)); - tokens = tokens.concat(this.basicRegexMatch(source)); - tokens = tokens.concat(this.timeOfTodayBefore(source, referenceDate)); - tokens = tokens.concat(this.timeOfTodayAfter(source, referenceDate)); - tokens = tokens.concat(this.specialTimeOfDate(source, referenceDate)); - tokens = tokens.concat(this.durationWithBeforeAndAfter(source, referenceDate)); - - let result = Token.mergeAllTokens(tokens, source, this.extractorName); - return result; - } - - protected mergeDateAndTime(source: string, refDate: Date): Token[] { - let tokens: Token[] = new Array(); - let ers = this.config.datePointExtractor.extract(source, refDate); - if (ers.length < 1) { - return tokens; - } - ers = ers.concat(this.config.timePointExtractor.extract(source, refDate)); - if (ers.length < 2) { - return tokens; - } - ers = ers.sort((erA, erB) => erA.start < erB.start ? -1 : erA.start === erB.start ? 0 : 1); - let i = 0; - while (i < ers.length - 1) { - let j = i + 1; - while (j < ers.length && ExtractResult.isOverlap(ers[i], ers[j])) { - j++; - } - if (j >= ers.length) { - break; - } - if ((ers[i].type === Constants.SYS_DATETIME_DATE && ers[j].type === Constants.SYS_DATETIME_TIME) || - (ers[i].type === Constants.SYS_DATETIME_TIME && ers[j].type === Constants.SYS_DATETIME_DATE)) { - let middleBegin = ers[i].start + ers[i].length; - let middleEnd = ers[j].start; - if (middleBegin > middleEnd) { - i = j + 1; - continue; - } - let middleStr = source.substr(middleBegin, middleEnd - middleBegin).trim().toLowerCase(); - if (this.config.isConnectorToken(middleStr)) { - let begin = ers[i].start; - let end = ers[j].start + ers[j].length; - tokens.push(new Token(begin, end)); - i = j + 1; - continue; - } - } - i = j; - } - tokens.forEach((token, index) => { - let afterStr = source.substr(token.end); - let match = RegExpUtility.getMatches(this.config.suffixRegex, afterStr); - if (match && match.length > 0) { - // TODO: verify element - token.end += match[0].length; - } - }); - return tokens; - } - - protected basicRegexMatch(source: string): Token[] { - let tokens: Token[] = new Array(); - RegExpUtility.getMatches(this.config.nowRegex, source) - .forEach(match => { - tokens.push(new Token(match.index, match.index + match.length)); - }); - return tokens; - } - - private timeOfTodayBefore(source: string, refDate: Date): Token[] { - let tokens: Token[] = new Array(); - let ers = this.config.timePointExtractor.extract(source, refDate); - ers.forEach(er => { - let beforeStr = source.substr(0, er.start); - let innerMatches = RegExpUtility.getMatches(this.config.nightRegex, er.text); - if (innerMatches && innerMatches.length > 0 && innerMatches[0].index === 0) { - beforeStr = source.substr(0, er.start + innerMatches[0].length); - } - if (StringUtility.isNullOrWhitespace(beforeStr)) { - return; - } - let matches = RegExpUtility.getMatches(this.config.timeOfTodayBeforeRegex, beforeStr); - if (matches && matches.length > 0) { - let begin = matches[0].index; - let end = er.start + er.length; - tokens.push(new Token(begin, end)); - } - }); - RegExpUtility.getMatches(this.config.simpleTimeOfTodayBeforeRegex, source) - .forEach(match => { - tokens.push(new Token(match.index, match.index + match.length)); - }); - return tokens; - } - - private timeOfTodayAfter(source: string, refDate: Date): Token[] { - let tokens: Token[] = new Array(); - let ers = this.config.timePointExtractor.extract(source, refDate); - ers.forEach(er => { - let afterStr = source.substr(er.start + er.length); - if (StringUtility.isNullOrWhitespace(afterStr)) { - return; - } - let matches = RegExpUtility.getMatches(this.config.timeOfTodayAfterRegex, afterStr); - if (matches && matches.length > 0) { - let begin = er.start; - let end = er.start + er.length + matches[0].length; - tokens.push(new Token(begin, end)); - } - }); - RegExpUtility.getMatches(this.config.simpleTimeOfTodayAfterRegex, source) - .forEach(match => { - tokens.push(new Token(match.index, match.index + match.length)); - }); - return tokens; - } - - private specialTimeOfDate(source: string, refDate: Date): Token[] { - let tokens: Token[] = new Array(); - let ers = this.config.datePointExtractor.extract(source, refDate); - ers.forEach(er => { - let beforeStr = source.substr(0, er.start); - let beforeMatches = RegExpUtility.getMatches(this.config.specificEndOfRegex, beforeStr); - if (beforeMatches && beforeMatches.length > 0) { - tokens.push(new Token(beforeMatches[0].index, er.start + er.length)); - } - else { - let afterStr = source.substr(er.start + er.length); - let afterMatches = RegExpUtility.getMatches(this.config.specificEndOfRegex, afterStr); - if (afterMatches && afterMatches.length > 0) { - tokens.push(new Token(er.start, er.start + er.length + afterMatches[0].index + afterMatches[0].length)); - } - } - }); - - RegExpUtility.getMatches(this.config.unspecificEndOfRegex, source).forEach( - match => { - tokens.push(new Token(match.index, match.index + match.length)); - } - ); - - return tokens; - } - - protected durationWithBeforeAndAfter(source: string, refDate: Date): Token[] { - let tokens: Token[] = new Array(); - this.config.durationExtractor.extract(source, refDate).forEach(er => { - let matches = RegExpUtility.getMatches(this.config.unitRegex, er.text); - if (matches && matches.length > 0) { - tokens = AgoLaterUtil.extractorDurationWithBeforeAndAfter(source, er, tokens, this.config.utilityConfiguration); - } - }); - return tokens; - } -} - -export interface IDateTimeParserConfiguration { - tokenBeforeDate: string; - tokenBeforeTime: string; - dateExtractor: IDateTimeExtractor; - timeExtractor: IDateTimeExtractor; - dateParser: IDateTimeParser; - timeParser: IDateTimeParser; - cardinalExtractor: BaseNumberExtractor; - numberParser: BaseNumberParser; - durationExtractor: IDateTimeExtractor; - durationParser: IDateTimeParser; - nowRegex: RegExp; - amTimeRegex: RegExp; - pmTimeRegex: RegExp; - simpleTimeOfTodayAfterRegex: RegExp; - simpleTimeOfTodayBeforeRegex: RegExp; - specificTimeOfDayRegex: RegExp; - specificEndOfRegex: RegExp; - unspecificEndOfRegex: RegExp; - unitRegex: RegExp; - unitMap: ReadonlyMap; - numbers: ReadonlyMap; - haveAmbiguousToken(text: string, matchedText: string): boolean; - getMatchedNowTimex(text: string): { matched: boolean, timex: string }; - getSwiftDay(text: string): number; - getHour(text: string, hour: number): number; - utilityConfiguration: IDateTimeUtilityConfiguration; -} - -export class BaseDateTimeParser implements IDateTimeParser { - public static readonly ParserName = Constants.SYS_DATETIME_DATETIME; // "DateTime"; - protected readonly config: IDateTimeParserConfiguration; - - constructor(configuration: IDateTimeParserConfiguration) { - this.config = configuration; - } - - public parse(er: ExtractResult, refTime: Date): DateTimeParseResult { - if (!refTime) { - refTime = new Date(); - } - let referenceTime = refTime; - - let value = null; - if (er.type === BaseDateTimeParser.ParserName) { - let innerResult = this.mergeDateAndTime(er.text, referenceTime); - if (!innerResult.success) { - innerResult = this.parseBasicRegex(er.text, referenceTime); - } - - if (!innerResult.success) { - innerResult = this.parseTimeOfToday(er.text, referenceTime); - } - - if (!innerResult.success) { - innerResult = this.parseSpecialTimeOfDate(er.text, referenceTime); - } - - if (!innerResult.success) { - innerResult = this.parserDurationWithAgoAndLater(er.text, referenceTime); - } - - if (innerResult.success) { - innerResult.futureResolution = {}; - innerResult.futureResolution[TimeTypeConstants.DATETIME] = DateTimeFormatUtil.formatDateTime(innerResult.futureValue); - innerResult.pastResolution = {}; - innerResult.pastResolution[TimeTypeConstants.DATETIME] = DateTimeFormatUtil.formatDateTime(innerResult.pastValue); - value = innerResult; - } - } - - let ret = new DateTimeParseResult(er); { - ret.value = value, - ret.timexStr = value === null ? "" : value.timex, - ret.resolutionStr = ""; - }; - return ret; - } - - protected parseBasicRegex(text: string, referenceTime: Date): DateTimeResolutionResult { - let ret = new DateTimeResolutionResult(); - let trimmedText = text.trim().toLowerCase(); - - // handle "now" - let matches = RegExpUtility.getMatches(this.config.nowRegex, trimmedText); - if (matches.length && matches[0].index === 0 && matches[0].length === trimmedText.length) { - let getMatchedNowTimex = this.config.getMatchedNowTimex(trimmedText); - ret.timex = getMatchedNowTimex.timex; - ret.futureValue = ret.pastValue = referenceTime; - ret.success = true; - return ret; - } - - return ret; - } - - // merge a Date entity and a Time entity - protected mergeDateAndTime(text: string, referenceTime: Date): DateTimeResolutionResult { - let ret = new DateTimeResolutionResult(); - - let er1 = this.config.dateExtractor.extract(text, referenceTime); - if (er1.length === 0) { - er1 = this.config.dateExtractor.extract(this.config.tokenBeforeDate + text, referenceTime); - if (er1.length === 1) { - er1[0].start -= this.config.tokenBeforeDate.length; - } - else { - return ret; - } - } - else { - // this is to understand if there is an ambiguous token in the text. For some languages (e.g. spanish) - // the same word could mean different things (e.g a time in the day or an specific day). - if (this.config.haveAmbiguousToken(text, er1[0].text)) { - return ret; - } - } - - let er2 = this.config.timeExtractor.extract(text, referenceTime); - if (er2.length === 0) { - // here we filter out "morning, afternoon, night..." time entities - er2 = this.config.timeExtractor.extract(this.config.tokenBeforeTime + text, referenceTime); - if (er2.length === 1) { - er2[0].start -= this.config.tokenBeforeTime.length; - } - else { - return ret; - } - } - - // handle case "Oct. 5 in the afternoon at 7:00" - // in this case "5 in the afternoon" will be extract as a Time entity - let correctTimeIdx = 0; - while (correctTimeIdx < er2.length && ExtractResult.isOverlap(er2[correctTimeIdx], er1[0])) { - correctTimeIdx++; - } - - if (correctTimeIdx >= er2.length) { - return ret; - } - - let pr1 = this.config.dateParser.parse(er1[0], new Date(referenceTime.toDateString())); - let pr2 = this.config.timeParser.parse(er2[correctTimeIdx], referenceTime); - if (pr1.value === null || pr2.value === null) { - return ret; - } - - let futureDate = pr1.value.futureValue; - let pastDate = pr1.value.pastValue; - let time = pr2.value.futureValue; - - let hour = time.getHours(); - let min = time.getMinutes(); - let sec = time.getSeconds(); - - // handle morning, afternoon - if (RegExpUtility.getMatches(this.config.pmTimeRegex, text).length && hour < 12) { - hour += 12; - } - else if (RegExpUtility.getMatches(this.config.amTimeRegex, text).length && hour >= 12) { - hour -= 12; - } - - let timeStr = pr2.timexStr; - if (timeStr.endsWith("ampm")) { - timeStr = timeStr.substring(0, timeStr.length - 4); - } - timeStr = "T" + DateTimeFormatUtil.toString(hour, 2) + timeStr.substring(3); - ret.timex = pr1.timexStr + timeStr; - - let val = pr2.value; - if (hour <= 12 && !RegExpUtility.getMatches(this.config.pmTimeRegex, text).length - && !RegExpUtility.getMatches(this.config.amTimeRegex, text).length && val.comment) { - ret.comment = "ampm"; - } - ret.futureValue = new Date(futureDate.getFullYear(), futureDate.getMonth(), futureDate.getDate(), hour, min, sec); - ret.pastValue = new Date(pastDate.getFullYear(), pastDate.getMonth(), pastDate.getDate(), hour, min, sec); - ret.success = true; - - // change the value of time object - pr2.timexStr = timeStr; - if (!StringUtility.isNullOrEmpty(ret.comment)) { - pr2.value.comment = ret.comment === "ampm" ? "ampm" : ""; - } - - // add the date and time object in case we want to split them - ret.subDateTimeEntities = [pr1, pr2]; - - return ret; - } - - protected parseTimeOfToday(text: string, referenceTime: Date): DateTimeResolutionResult { - let ret = new DateTimeResolutionResult(); - let trimmedText = text.toLowerCase().trim(); - - let hour = 0; - let min = 0; - let sec = 0; - let timeStr: string; - - let wholeMatches = RegExpUtility.getMatches(this.config.simpleTimeOfTodayAfterRegex, trimmedText); - if (!(wholeMatches.length && wholeMatches[0].length === trimmedText.length)) { - wholeMatches = RegExpUtility.getMatches(this.config.simpleTimeOfTodayBeforeRegex, trimmedText); - } - - if (wholeMatches.length && wholeMatches[0].length === trimmedText.length) { - let hourStr = wholeMatches[0].groups("hour").value; - if (!hourStr) { - hourStr = wholeMatches[0].groups("hournum").value.toLowerCase(); - hour = this.config.numbers.get(hourStr); - } - else { - hour = parseInt(hourStr, 10); - } - timeStr = "T" + DateTimeFormatUtil.toString(hour, 2); - } - else { - let ers = this.config.timeExtractor.extract(trimmedText, referenceTime); - if (ers.length !== 1) { - ers = this.config.timeExtractor.extract(this.config.tokenBeforeTime + trimmedText, referenceTime); - if (ers.length === 1) { - ers[0].start -= this.config.tokenBeforeTime.length; - } - else { - return ret; - } - } - - let pr = this.config.timeParser.parse(ers[0], referenceTime); - if (pr.value === null) { - return ret; - } - - let time = pr.value.futureValue; - - hour = time.getHours(); - min = time.getMinutes(); - sec = time.getSeconds(); - timeStr = pr.timexStr; - } - - - let matches = RegExpUtility.getMatches(this.config.specificTimeOfDayRegex, trimmedText); - - if (matches.length) { - let matchStr = matches[0].value.toLowerCase(); - - // handle "last", "next" - let swift = this.config.getSwiftDay(matchStr); - - let date = new Date(referenceTime); - date.setDate(date.getDate() + swift); - - // handle "morning", "afternoon" - hour = this.config.getHour(matchStr, hour); - - // in this situation, luisStr cannot end up with "ampm", because we always have a "morning" or "night" - if (timeStr.endsWith("ampm")) { - timeStr = timeStr.substring(0, timeStr.length - 4); - } - timeStr = "T" + DateTimeFormatUtil.toString(hour, 2) + timeStr.substring(3); - - ret.timex = DateTimeFormatUtil.formatDate(date) + timeStr; - ret.futureValue = ret.pastValue = new Date(date.getFullYear(), date.getMonth(), date.getDate(), hour, min, sec); - ret.success = true; - return ret; - } - - return ret; - } - - private parseSpecialTimeOfDate(text: string, refDateTime: Date): DateTimeResolutionResult { - let ret = new DateTimeResolutionResult(); - ret = this.parseUnspecificTimeOfDate(text, refDateTime); - if (ret.success) { - return ret; - } - - let ers = this.config.dateExtractor.extract(text, refDateTime); - if (ers.length !== 1) { - return ret; - } - let beforeStr = text.substring(0, ers[0].start || 0); - if (RegExpUtility.getMatches(this.config.specificEndOfRegex, beforeStr).length) { - let pr = this.config.dateParser.parse(ers[0], refDateTime); - let futureDate = new Date(pr.value.futureValue); - let pastDate = new Date(pr.value.pastValue); - ret = this.resolveEndOfDay(pr.timexStr, futureDate, pastDate); - return ret; - } - - return ret; - } - - private parseUnspecificTimeOfDate(text: string, refDateTime: Date): DateTimeResolutionResult { - let ret = new DateTimeResolutionResult(); - let eod = RegExpUtility.getMatches(this.config.unspecificEndOfRegex, text); - if (eod.length) { - let futureDate = new Date(refDateTime); - let pastDate = new Date(refDateTime); - ret = this.resolveEndOfDay(DateTimeFormatUtil.formatDate(refDateTime), futureDate, pastDate); - } - - return ret; - } - - private resolveEndOfDay(timexPrefix: string, futureDate: Date, pastDate: Date): DateTimeResolutionResult { - let ret = new DateTimeResolutionResult(); - - ret.timex = timexPrefix + "T23:59:59"; - futureDate.setHours(23, 59, 59, 0); - ret.futureValue = futureDate; - pastDate.setHours(23, 59, 59, 0); - ret.pastValue = pastDate; - ret.success = true; - - return ret; - } - - // handle like "two hours ago" - protected parserDurationWithAgoAndLater(text: string, referenceTime: Date): DateTimeResolutionResult { - return AgoLaterUtil.parseDurationWithAgoAndLater( - text, - referenceTime, - this.config.durationExtractor, - this.config.durationParser, - this.config.unitMap, - this.config.unitRegex, - this.config.utilityConfiguration, - AgoLaterMode.DateTime - ); - } -} diff --git a/JavaScript/packages/recognizers-date-time/src/dateTime/baseDateTimePeriod.ts b/JavaScript/packages/recognizers-date-time/src/dateTime/baseDateTimePeriod.ts deleted file mode 100644 index 163799cce9..0000000000 --- a/JavaScript/packages/recognizers-date-time/src/dateTime/baseDateTimePeriod.ts +++ /dev/null @@ -1,886 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { IExtractor, ExtractResult, RegExpUtility, StringUtility } from "@microsoft/recognizers-text"; -import { Constants, TimeTypeConstants } from "./constants"; -import { BaseNumberExtractor } from "@microsoft/recognizers-text-number"; -import { BaseDateExtractor, BaseDateParser } from "./baseDate"; -import { BaseTimeExtractor, BaseTimeParser } from "./baseTime"; -import { BaseDateTimeExtractor, BaseDateTimeParser, IDateTimeExtractor } from "./baseDateTime"; -import { BaseDurationExtractor, BaseDurationParser } from "./baseDuration"; -import { IDateTimeParser, DateTimeParseResult } from "./parsers"; -import { DateTimeFormatUtil, DateUtils, Token, DateTimeResolutionResult, StringMap } from "./utilities"; - -export interface IDateTimePeriodExtractorConfiguration { - cardinalExtractor: BaseNumberExtractor - singleDateExtractor: IDateTimeExtractor - singleTimeExtractor: IDateTimeExtractor - singleDateTimeExtractor: IDateTimeExtractor - durationExtractor: IDateTimeExtractor - timePeriodExtractor: IDateTimeExtractor - simpleCasesRegexes: RegExp[] - prepositionRegex: RegExp - tillRegex: RegExp - specificTimeOfDayRegex: RegExp - timeOfDayRegex: RegExp - periodTimeOfDayWithDateRegex: RegExp - followedUnit: RegExp - numberCombinedWithUnit: RegExp - timeUnitRegex: RegExp - previousPrefixRegex: RegExp - nextPrefixRegex: RegExp - relativeTimeUnitRegex: RegExp - restOfDateTimeRegex: RegExp - generalEndingRegex: RegExp - middlePauseRegex: RegExp - getFromTokenIndex(source: string): { matched: boolean, index: number }; - getBetweenTokenIndex(source: string): { matched: boolean, index: number }; - hasConnectorToken(source: string): boolean; -} - -export class BaseDateTimePeriodExtractor implements IDateTimeExtractor { - protected readonly extractorName = Constants.SYS_DATETIME_DATETIMEPERIOD; - protected readonly config: IDateTimePeriodExtractorConfiguration; - - constructor(config: IDateTimePeriodExtractorConfiguration) { - this.config = config; - } - - extract(source: string, refDate: Date): ExtractResult[] { - if (!refDate) { - refDate = new Date(); - } - let referenceDate = refDate; - - let tokens: Token[] = new Array() - .concat(this.matchSimpleCases(source, referenceDate)) - .concat(this.mergeTwoTimePoints(source, referenceDate)) - .concat(this.matchDuration(source, referenceDate)) - .concat(this.matchNight(source, referenceDate)) - .concat(this.matchRelativeUnit(source)); - let result = Token.mergeAllTokens(tokens, source, this.extractorName); - return result; - } - - private matchSimpleCases(source: string, refDate: Date): Token[] { - let tokens: Token[] = new Array(); - this.config.simpleCasesRegexes.forEach(regexp => { - RegExpUtility.getMatches(regexp, source).forEach(match => { - // has a date before? - let hasBeforeDate = false; - let beforeStr = source.substr(0, match.index); - if (!StringUtility.isNullOrWhitespace(beforeStr)) { - let ers = this.config.singleDateExtractor.extract(beforeStr, refDate); - if (ers && ers.length > 0) { - let er = ers[ers.length - 1]; - let begin = er.start; - let end = er.start + er.length; - let middleStr = beforeStr.substr(begin + er.length).trim().toLowerCase(); - if (StringUtility.isNullOrWhitespace(middleStr) || RegExpUtility.getMatches(this.config.prepositionRegex, middleStr).length > 0) { - tokens.push(new Token(begin, match.index + match.length)); - hasBeforeDate = true; - } - } - } - let followedStr = source.substr(match.index + match.length); - if (!StringUtility.isNullOrWhitespace(followedStr) && !hasBeforeDate) { - let ers = this.config.singleDateExtractor.extract(followedStr, refDate); - if (ers && ers.length > 0) { - let er = ers[0]; - let begin = er.start; - let end = er.start + er.length; - let middleStr = followedStr.substr(0, begin).trim().toLowerCase(); - if (StringUtility.isNullOrWhitespace(middleStr) || RegExpUtility.getMatches(this.config.prepositionRegex, middleStr).length > 0) { - tokens.push(new Token(match.index, match.index + match.length + end)); - } - } - } - }); - }); - return tokens; - } - - protected mergeTwoTimePoints(source: string, refDate: Date): Token[] { - let tokens: Token[] = new Array(); - let ersDateTime = this.config.singleDateTimeExtractor.extract(source, refDate); - let ersTime = this.config.singleTimeExtractor.extract(source, refDate); - let innerMarks: ExtractResult[] = []; - let j = 0; - ersDateTime.forEach((erDateTime, index) => { - innerMarks.push(erDateTime); - while (j < ersTime.length && ersTime[j].start + ersTime[j].length < erDateTime.start) { - innerMarks.push(ersTime[j++]); - } - while (j < ersTime.length && ExtractResult.isOverlap(ersTime[j], erDateTime)) { - j++; - } - }); - while (j < ersTime.length) { - innerMarks.push(ersTime[j++]); - } - innerMarks = innerMarks.sort((erA, erB) => erA.start < erB.start ? -1 : erA.start === erB.start ? 0 : 1); - let idx = 0; - while (idx < innerMarks.length - 1) { - let currentMark = innerMarks[idx]; - let nextMark = innerMarks[idx + 1]; - if (currentMark.type === Constants.SYS_DATETIME_TIME && nextMark.type === Constants.SYS_DATETIME_TIME) { - idx++; - continue; - } - let middleBegin = currentMark.start + currentMark.length; - let middleEnd = nextMark.start; - - let middleStr = source.substr(middleBegin, middleEnd - middleBegin).trim().toLowerCase(); - let matches = RegExpUtility.getMatches(this.config.tillRegex, middleStr); - if (matches && matches.length > 0 && matches[0].index === 0 && matches[0].length === middleStr.length) { - let periodBegin = currentMark.start; - let periodEnd = nextMark.start + nextMark.length; - let beforeStr = source.substr(0, periodBegin).trim().toLowerCase(); - let matchFrom = this.config.getFromTokenIndex(beforeStr); - let fromTokenIndex = matchFrom.matched ? matchFrom : this.config.getBetweenTokenIndex(beforeStr); - if (fromTokenIndex.matched) { - periodBegin = fromTokenIndex.index; - } - tokens.push(new Token(periodBegin, periodEnd)); - idx += 2; - continue; - } - if (this.config.hasConnectorToken(middleStr)) { - let periodBegin = currentMark.start; - let periodEnd = nextMark.start + nextMark.length; - let beforeStr = source.substr(0, periodBegin).trim().toLowerCase(); - let betweenTokenIndex = this.config.getBetweenTokenIndex(beforeStr); - if (betweenTokenIndex.matched) { - periodBegin = betweenTokenIndex.index; - tokens.push(new Token(periodBegin, periodEnd)); - idx += 2; - continue; - } - } - idx++; - }; - return tokens; - } - - private matchDuration(source: string, refDate: Date): Token[] { - let tokens: Token[] = new Array(); - let durations: Token[] = new Array(); - this.config.durationExtractor.extract(source, refDate).forEach(duration => { - let match = RegExpUtility.getMatches(this.config.timeUnitRegex, duration.text).pop(); - if (match) { - durations.push(new Token(duration.start, duration.start + duration.length)); - } - }); - durations.forEach(duration => { - let beforeStr = source.substr(0, duration.start).toLowerCase(); - if (StringUtility.isNullOrWhitespace(beforeStr)) { - return; - } - let match = RegExpUtility.getMatches(this.config.previousPrefixRegex, beforeStr).pop(); - if (match && StringUtility.isNullOrWhitespace(beforeStr.substr(match.index + match.length))) { - tokens.push(new Token(match.index, duration.end)); - return; - } - match = RegExpUtility.getMatches(this.config.nextPrefixRegex, beforeStr).pop(); - if (match && StringUtility.isNullOrWhitespace(beforeStr.substr(match.index + match.length))) { - tokens.push(new Token(match.index, duration.end)); - } - }); - return tokens; - } - - protected matchNight(source: string, refDate: Date): Token[] { - let tokens: Token[] = new Array(); - RegExpUtility.getMatches(this.config.specificTimeOfDayRegex, source).forEach(match => { - tokens.push(new Token(match.index, match.index + match.length)); - }); - this.config.singleDateExtractor.extract(source, refDate).forEach(er => { - let afterStr = source.substr(er.start + er.length); - let match = RegExpUtility.getMatches(this.config.periodTimeOfDayWithDateRegex, afterStr).pop(); - if (match) { - if (StringUtility.isNullOrWhitespace(afterStr.substr(0, match.index))) { - tokens.push(new Token(er.start, er.start + er.length + match.index + match.length)); - } - else { - let pauseMatch = RegExpUtility.getMatches(this.config.middlePauseRegex, afterStr.substr(0, match.index)).pop(); - - if (pauseMatch) { - // TODO: should use trimStart() instead? - let suffix = afterStr.substr(match.index + match.length).trim(); - - let endingMatch = RegExpUtility.getMatches(this.config.generalEndingRegex, suffix).pop(); - if (endingMatch) { - tokens.push(new Token(er.start || 0, er.start + er.length + match.index + match.length || 0)); - } - } - } - } - - let beforeStr = source.substr(0, er.start); - match = RegExpUtility.getMatches(this.config.periodTimeOfDayWithDateRegex, beforeStr).pop(); - if (match) { - if (StringUtility.isNullOrWhitespace(beforeStr.substr(match.index + match.length))) { - let middleStr = source.substr(match.index + match.length, er.start - match.index - match.length); - if (StringUtility.isWhitespace(middleStr)) { - tokens.push(new Token(match.index, er.start + er.length)); - } - } - else { - let pauseMatch = RegExpUtility.getMatches(this.config.middlePauseRegex, beforeStr.substr(match.index + match.length)).pop(); - - if (pauseMatch) { - // TODO: should use trimStart() instead? - let suffix = source.substr(er.start + er.length || 0).trim(); - - let endingMatch = RegExpUtility.getMatches(this.config.generalEndingRegex, suffix).pop(); - if (endingMatch) { - tokens.push(new Token(match.index, er.start + er.length || 0)); - } - - } - } - } - - // check whether there are adjacent time period strings, before or after - for (let e of tokens) { - // try to extract a time period in before-string - if (e.start > 0) { - let beforeStr = source.substr(0, e.start); - if (!StringUtility.isNullOrWhitespace(beforeStr)) { - let timeErs = this.config.timePeriodExtractor.extract(beforeStr); - if (timeErs.length > 0) { - for (let tp of timeErs) { - let midStr = beforeStr.substr(tp.start + tp.length || 0); - if (StringUtility.isNullOrWhitespace(midStr)) { - tokens.push(new Token(tp.start || 0, tp.start + tp.length + midStr.length + e.length || 0)); - } - } - } - } - } - - // try to extract a time period in after-string - if (e.start + e.length <= source.length) { - let afterStr = source.substr(e.start + e.length); - if (!StringUtility.isNullOrWhitespace(afterStr)) { - let timeErs = this.config.timePeriodExtractor.extract(afterStr); - if (timeErs.length > 0) { - for (let tp of timeErs) { - let midStr = afterStr.substr(0, tp.start || 0); - if (StringUtility.isNullOrWhitespace(midStr)) { - tokens.push(new Token(e.start, e.start + e.length + midStr.length + tp.length || 0)); - } - } - } - } - } - } - }); - - return tokens; - } - - private matchRelativeUnit(source: string): Token[] { - let tokens: Token[] = new Array(); - let matches = RegExpUtility.getMatches(this.config.relativeTimeUnitRegex, source); - if (matches.length === 0) { - matches = RegExpUtility.getMatches(this.config.restOfDateTimeRegex, source); - } - matches.forEach(match => { - tokens.push(new Token(match.index, match.index + match.length)); - }); - return tokens; - } -} - -export interface IDateTimePeriodParserConfiguration { - pureNumberFromToRegex: RegExp - pureNumberBetweenAndRegex: RegExp - periodTimeOfDayWithDateRegex: RegExp - specificTimeOfDayRegex: RegExp - pastRegex: RegExp - futureRegex: RegExp - relativeTimeUnitRegex: RegExp - restOfDateTimeRegex: RegExp - numbers: ReadonlyMap - unitMap: ReadonlyMap - dateExtractor: IDateTimeExtractor - timeExtractor: IDateTimeExtractor - dateTimeExtractor: IDateTimeExtractor - timePeriodExtractor: IDateTimeExtractor - durationExtractor: IDateTimeExtractor - dateParser: BaseDateParser - timeParser: BaseTimeParser - dateTimeParser: BaseDateTimeParser - timePeriodParser: IDateTimeParser - durationParser: BaseDurationParser - getMatchedTimeRange(source: string): { timeStr: string, beginHour: number, endHour: number, endMin: number, success: boolean } - getSwiftPrefix(source: string): number -} - -export class BaseDateTimePeriodParser implements IDateTimeParser { - protected readonly parserName = Constants.SYS_DATETIME_DATETIMEPERIOD; - protected readonly config: IDateTimePeriodParserConfiguration; - - constructor(config: IDateTimePeriodParserConfiguration) { - this.config = config; - } - - parse(extractorResult: ExtractResult, referenceDate?: Date): DateTimeParseResult | null { - if (!referenceDate) { - referenceDate = new Date(); - } - let resultValue; - if (extractorResult.type === this.parserName) { - let source = extractorResult.text.trim().toLowerCase(); - let innerResult = this.mergeDateAndTimePeriods(source, referenceDate); - if (!innerResult.success) { - innerResult = this.mergeTwoTimePoints(source, referenceDate); - } - if (!innerResult.success) { - innerResult = this.parseSpecificTimeOfDay(source, referenceDate); - } - if (!innerResult.success) { - innerResult = this.parseDuration(source, referenceDate); - } - if (!innerResult.success) { - innerResult = this.parseRelativeUnit(source, referenceDate); - } - if (innerResult.success) { - innerResult.futureResolution = {}; - innerResult.futureResolution[TimeTypeConstants.START_DATETIME] = DateTimeFormatUtil.formatDateTime(innerResult.futureValue[0]); - innerResult.futureResolution[TimeTypeConstants.END_DATETIME] = DateTimeFormatUtil.formatDateTime(innerResult.futureValue[1]); - innerResult.pastResolution = {}; - innerResult.pastResolution[TimeTypeConstants.START_DATETIME] = DateTimeFormatUtil.formatDateTime(innerResult.pastValue[0]); - innerResult.pastResolution[TimeTypeConstants.END_DATETIME] = DateTimeFormatUtil.formatDateTime(innerResult.pastValue[1]); - resultValue = innerResult; - } - } - let result = new DateTimeParseResult(extractorResult); - result.value = resultValue; - result.timexStr = resultValue ? resultValue.timex : ''; - result.resolutionStr = ''; - - return result; - } - - protected mergeDateAndTimePeriods(text: string, referenceTime: Date): DateTimeResolutionResult { - let ret = new DateTimeResolutionResult(); - let trimedText = text.trim().toLowerCase(); - - let er = this.config.timePeriodExtractor.extract(trimedText, referenceTime); - if (er.length !== 1) { - return this.parseSimpleCases(text, referenceTime); - } - - let timePeriodParseResult = this.config.timePeriodParser.parse(er[0]); - let timePeriodResolutionResult = timePeriodParseResult.value; - - if (!timePeriodResolutionResult) { - return this.parseSimpleCases(text, referenceTime); - } - - let timePeriodTimex = timePeriodResolutionResult.timex; - // if it is a range type timex - if (!StringUtility.isNullOrEmpty(timePeriodTimex) - && timePeriodTimex.startsWith("(")) { - let dateResult = this.config.dateExtractor.extract(trimedText.replace(er[0].text, ""), referenceTime); - let dateStr = ""; - let futureTime: Date; - let pastTime: Date; - if (dateResult.length === 1 && trimedText.replace(er[0].text, "").trim() === dateResult[0].text) { - let pr = this.config.dateParser.parse(dateResult[0], referenceTime); - if (pr.value) { - futureTime = pr.value.futureValue; - pastTime = pr.value.pastValue; - - dateStr = pr.timexStr; - } - else { - return this.parseSimpleCases(text, referenceTime); - } - - timePeriodTimex = timePeriodTimex.replace("(", "").replace(")", ""); - let timePeriodTimexArray = timePeriodTimex.split(','); - let timePeriodFutureValue = timePeriodResolutionResult.futureValue; - let beginTime = timePeriodFutureValue.item1; - let endTime = timePeriodFutureValue.item2; - - if (timePeriodTimexArray.length === 3) { - let beginStr = dateStr + timePeriodTimexArray[0]; - let endStr = dateStr + timePeriodTimexArray[1]; - - ret.timex = `(${beginStr},${endStr},${timePeriodTimexArray[2]})`; - - ret.futureValue = [ - DateUtils.safeCreateFromMinValue(futureTime.getFullYear(), futureTime.getMonth(), futureTime.getDate(), - beginTime.getHours(), beginTime.getMinutes(), beginTime.getSeconds()), - DateUtils.safeCreateFromMinValue(futureTime.getFullYear(), futureTime.getMonth(), futureTime.getDate(), - endTime.getHours(), endTime.getMinutes(), endTime.getSeconds())]; - - ret.pastValue = [ - DateUtils.safeCreateFromMinValue(pastTime.getFullYear(), pastTime.getMonth(), pastTime.getDate(), - beginTime.getHours(), beginTime.getMinutes(), beginTime.getSeconds()), - DateUtils.safeCreateFromMinValue(pastTime.getFullYear(), pastTime.getMonth(), pastTime.getDate(), - endTime.getHours(), endTime.getMinutes(), endTime.getSeconds())]; - - if (!StringUtility.isNullOrEmpty(timePeriodResolutionResult.comment) - && timePeriodResolutionResult.comment === "ampm") { - ret.comment = "ampm"; - } - - ret.success = true; - ret.subDateTimeEntities = [pr, timePeriodParseResult]; - - return ret; - } - } - else { - return this.parseSimpleCases(text, referenceTime); - } - } - - return this.parseSimpleCases(text, referenceTime); - } - - private parseSimpleCases(source: string, referenceDate: Date): DateTimeResolutionResult { - let result = new DateTimeResolutionResult(); - let match = RegExpUtility.getMatches(this.config.pureNumberFromToRegex, source).pop(); - if (!match) { - match = RegExpUtility.getMatches(this.config.pureNumberBetweenAndRegex, source).pop(); - } - if (!match || (match.index !== 0 && match.index + match.length !== source.length)) { - return result; - } - - let hourGroup = match.groups('hour'); - let beginHour = this.config.numbers.get(hourGroup.captures[0]) || Number.parseInt(hourGroup.captures[0], 10) || 0; - let endHour = this.config.numbers.get(hourGroup.captures[1]) || Number.parseInt(hourGroup.captures[1], 10) || 0; - - let er = this.config.dateExtractor.extract(source.replace(match.value, ""), referenceDate).pop(); - if (!er) { - return result; - } - - let pr = this.config.dateParser.parse(er, referenceDate); - if (!pr) { - return result; - } - - let dateResult: DateTimeResolutionResult = pr.value; - let futureDate: Date = dateResult.futureValue; - let pastDate: Date = dateResult.pastValue; - let dateStr = pr.timexStr; - - let hasAm = false; - let hasPm = false; - let pmStr = match.groups('pm').value; - let amStr = match.groups('am').value; - let descStr = match.groups('desc').value; - - if (!StringUtility.isNullOrEmpty(amStr) || descStr.startsWith('a')) { - if (beginHour >= 12) { - beginHour -= 12; - } - if (endHour >= 12) { - endHour -= 12; - } - hasAm = true; - } - if (!StringUtility.isNullOrEmpty(pmStr) || descStr.startsWith('p')) { - if (beginHour < 12) { - beginHour += 12; - } - if (endHour < 12) { - endHour += 12; - } - hasPm = true; - } - if (!hasAm && !hasPm && beginHour <= 12 && endHour <= 12) { - result.comment = "ampm"; - } - - let beginStr = `${dateStr}T${DateTimeFormatUtil.toString(beginHour, 2)}`; - let endStr = `${dateStr}T${DateTimeFormatUtil.toString(endHour, 2)}`; - - result.timex = `(${beginStr},${endStr},PT${endHour - beginHour}H)`; - result.futureValue = [ - DateUtils.safeCreateFromMinValue(futureDate.getFullYear(), futureDate.getMonth(), futureDate.getDate(), beginHour, 0, 0), - DateUtils.safeCreateFromMinValue(futureDate.getFullYear(), futureDate.getMonth(), futureDate.getDate(), endHour, 0, 0) - ]; - result.pastValue = [ - DateUtils.safeCreateFromMinValue(pastDate.getFullYear(), pastDate.getMonth(), pastDate.getDate(), beginHour, 0, 0), - DateUtils.safeCreateFromMinValue(pastDate.getFullYear(), pastDate.getMonth(), pastDate.getDate(), endHour, 0, 0) - ]; - result.success = true; - return result; - } - - protected mergeTwoTimePoints(source: string, referenceDate: Date): DateTimeResolutionResult { - let result = new DateTimeResolutionResult(); - let prs: { begin: DateTimeParseResult, end: DateTimeParseResult }; - let timeErs = this.config.timeExtractor.extract(source, referenceDate); - let datetimeErs = this.config.dateTimeExtractor.extract(source, referenceDate); - let bothHasDate = false; - let beginHasDate = false; - let endHasDate = false; - - if (datetimeErs.length === 2) { - prs = this.getTwoPoints(datetimeErs[0], datetimeErs[1], this.config.dateTimeParser, this.config.dateTimeParser, referenceDate); - bothHasDate = true; - } - else if (datetimeErs.length === 1 && timeErs.length === 2) { - if (ExtractResult.isOverlap(datetimeErs[0], timeErs[0])) { - prs = this.getTwoPoints(datetimeErs[0], timeErs[1], this.config.dateTimeParser, this.config.timeParser, referenceDate); - beginHasDate = true; - } - else { - prs = this.getTwoPoints(timeErs[0], datetimeErs[0], this.config.timeParser, this.config.dateTimeParser, referenceDate); - endHasDate = true; - } - } - else if (datetimeErs.length === 1 && timeErs.length === 1) { - if (timeErs[0].start < datetimeErs[0].start) { - prs = this.getTwoPoints(timeErs[0], datetimeErs[0], this.config.timeParser, this.config.dateTimeParser, referenceDate); - endHasDate = true; - } - else if (timeErs[0].start >= datetimeErs[0].start + datetimeErs[0].length) { - prs = this.getTwoPoints(datetimeErs[0], timeErs[0], this.config.dateTimeParser, this.config.timeParser, referenceDate); - beginHasDate = true; - } - else { - return result; - } - } - if (!prs || !prs.begin.value || !prs.end.value) { - return result; - } - - let begin: DateTimeResolutionResult = prs.begin.value; - let end: DateTimeResolutionResult = prs.end.value; - - let futureBegin: Date = begin.futureValue; - let futureEnd: Date = end.futureValue; - let pastBegin: Date = begin.pastValue; - let pastEnd: Date = end.pastValue; - - if (bothHasDate) { - if (futureBegin > futureEnd) { - futureBegin = pastBegin; - } - if (pastEnd < pastBegin) { - pastEnd = futureEnd; - } - result.timex = `(${prs.begin.timexStr},${prs.end.timexStr},${DateTimeFormatUtil.luisTimeSpan(futureBegin, futureEnd)})`; - } - else if (beginHasDate) { - futureEnd = DateUtils.safeCreateFromMinValue(futureBegin.getFullYear(), futureBegin.getMonth(), futureBegin.getDate(), futureEnd.getHours(), futureEnd.getMinutes(), futureEnd.getSeconds()); - pastEnd = DateUtils.safeCreateFromMinValue(pastBegin.getFullYear(), pastBegin.getMonth(), pastBegin.getDate(), pastEnd.getHours(), pastEnd.getMinutes(), pastEnd.getSeconds()); - let dateStr = prs.begin.timexStr.split('T').pop(); - result.timex = `(${prs.begin.timexStr},${dateStr}${prs.end.timexStr},${DateTimeFormatUtil.luisTimeSpan(futureBegin, futureEnd)})`; - } - else if (endHasDate) { - futureBegin = DateUtils.safeCreateFromMinValue(futureEnd.getFullYear(), futureEnd.getMonth(), futureEnd.getDate(), futureBegin.getHours(), futureBegin.getMinutes(), futureBegin.getSeconds()); - pastBegin = DateUtils.safeCreateFromMinValue(pastEnd.getFullYear(), pastEnd.getMonth(), pastEnd.getDate(), pastBegin.getHours(), pastBegin.getMinutes(), pastBegin.getSeconds()); - let dateStr = prs.end.timexStr.split('T')[0]; - result.timex = `(${dateStr}${prs.begin.timexStr},${prs.end.timexStr},${DateTimeFormatUtil.luisTimeSpan(futureBegin, futureEnd)})`; - } - if (!StringUtility.isNullOrEmpty(begin.comment) && begin.comment.endsWith('ampm') && !StringUtility.isNullOrEmpty(end.comment) && end.comment.endsWith('ampm')) { - result.comment = 'ampm'; - } - - result.futureValue = [futureBegin, futureEnd]; - result.pastValue = [pastBegin, pastEnd]; - result.success = true; - result.subDateTimeEntities = [prs.begin, prs.end]; - return result; - } - - protected getTwoPoints(beginEr: ExtractResult, endEr: ExtractResult, beginParser: IDateTimeParser, endParser: IDateTimeParser, referenceDate: Date) - : { begin: DateTimeParseResult, end: DateTimeParseResult } { - let beginPr = beginParser.parse(beginEr, referenceDate); - let endPr = endParser.parse(endEr, referenceDate); - return { begin: beginPr, end: endPr }; - } - - protected parseSpecificTimeOfDay(source: string, referenceDate: Date): DateTimeResolutionResult { - let result = new DateTimeResolutionResult(); - let timeText = source; - let hasEarly = false; - let hasLate = false; - - let match = RegExpUtility.getMatches(this.config.periodTimeOfDayWithDateRegex, source).pop(); - if (match) { - timeText = match.groups('timeOfDay').value; - if (!StringUtility.isNullOrEmpty(match.groups('early').value)) { - hasEarly = true; - result.comment = 'early'; - result.mod = Constants.EARLY_MOD; - } - else if (!StringUtility.isNullOrEmpty(match.groups('late').value)) { - hasLate = true; - result.comment = 'late'; - result.mod = Constants.LATE_MOD; - } - } - - let matched = this.config.getMatchedTimeRange(timeText); - if (!matched || !matched.success) { - return result; - } - - if (hasEarly) { - matched.endHour = matched.beginHour + 2; - if (matched.endMin === 59) { - matched.endMin = 0; - } - } - else if (hasLate) { - matched.beginHour += 2; - } - - match = RegExpUtility.getMatches(this.config.specificTimeOfDayRegex, source).pop(); - if (match && match.index === 0 && match.length === source.length) { - let swift = this.config.getSwiftPrefix(source); - let date = DateUtils.addDays(referenceDate, swift); - result.timex = DateTimeFormatUtil.formatDate(date) + matched.timeStr; - result.futureValue = [ - DateUtils.safeCreateFromMinValue(date.getFullYear(), date.getMonth(), date.getDate(), matched.beginHour, 0, 0), - DateUtils.safeCreateFromMinValue(date.getFullYear(), date.getMonth(), date.getDate(), matched.endHour, matched.endMin, matched.endMin), - ]; - result.pastValue = [ - DateUtils.safeCreateFromMinValue(date.getFullYear(), date.getMonth(), date.getDate(), matched.beginHour, 0, 0), - DateUtils.safeCreateFromMinValue(date.getFullYear(), date.getMonth(), date.getDate(), matched.endHour, matched.endMin, matched.endMin), - ]; - result.success = true; - return result; - } - - match = RegExpUtility.getMatches(this.config.periodTimeOfDayWithDateRegex, source).pop(); - if (!match) { - return result; - } - - let beforeStr = source.substr(0, match.index).trim(); - let afterStr = source.substr(match.index + match.length).trim(); - let ers = this.config.dateExtractor.extract(beforeStr, referenceDate); - - // eliminate time period, if any - let timePeriodErs = this.config.timePeriodExtractor.extract(beforeStr); - if (timePeriodErs.length > 0) { - beforeStr = beforeStr.slice(timePeriodErs[0].start || 0, timePeriodErs[0].start + timePeriodErs[0].length || 0).trim(); - } - else { - timePeriodErs = this.config.timePeriodExtractor.extract(afterStr); - if (timePeriodErs.length > 0) { - afterStr = afterStr.slice(timePeriodErs[0].start || 0, timePeriodErs[0].start + timePeriodErs[0].length || 0).trim(); - } - } - - if (ers.length === 0 || ers[0].length !== beforeStr.length) { - let valid = false; - if (ers.length > 0 && ers[0].start === 0) { - let midStr = beforeStr.substr(ers[0].start + ers[0].length || 0); - if (StringUtility.isNullOrWhitespace(midStr.replace(',', ' '))) { - valid = true; - } - } - - if (!valid) { - ers = this.config.dateExtractor.extract(afterStr); - if (ers.length === 0 || ers[0].length !== afterStr.length) { - if (ers.length > 0 && ers[0].start + ers[0].length === afterStr.length) { - let midStr = afterStr.substr(0, ers[0].start || 0); - if (StringUtility.isNullOrWhitespace(midStr.replace(',', ' '))) { - valid = true; - } - } - } - else { - valid = true; - } - - if (!valid) { - return result; - } - } - } - - let hasSpecificTimePeriod = false; - if (timePeriodErs.length > 0) { - let TimePr = this.config.timePeriodParser.parse(timePeriodErs[0], referenceDate); - if (TimePr != null) { - let periodFuture = TimePr.value.futureValue; - let periodPast = TimePr.value.pastValue; - - if (periodFuture === periodPast) { - matched.beginHour = periodFuture.item1.getHours(); - matched.endHour = periodFuture.item2.getHours(); - } - else { - if (periodFuture.item1.Hour >= matched.beginHour || periodFuture.item2.Hour <= matched.endHour) { - matched.beginHour = periodFuture.item1.getHours(); - matched.endHour = periodFuture.item2.getHours(); - } - else { - matched.beginHour = periodPast.item1.getHours(); - matched.endHour = periodPast.item2.getHours(); - } - } - hasSpecificTimePeriod = true; - } - } - - let pr = this.config.dateParser.parse(ers[0], referenceDate); - if (!pr) { - return result; - } - - let futureDate: Date = pr.value.futureValue; - let pastDate: Date = pr.value.pastValue; - - - if (!hasSpecificTimePeriod) { - result.timex = pr.timexStr + matched.timeStr; - } - else { - result.timex = `(${pr.timexStr}T${matched.beginHour},${pr.timexStr}T${matched.endHour},PT${matched.endHour - matched.beginHour}H)`; - } - - result.futureValue = [ - DateUtils.safeCreateFromMinValue(futureDate.getFullYear(), futureDate.getMonth(), futureDate.getDate(), matched.beginHour, 0, 0), - DateUtils.safeCreateFromMinValue(futureDate.getFullYear(), futureDate.getMonth(), futureDate.getDate(), matched.endHour, matched.endMin, matched.endMin), - ]; - result.pastValue = [ - DateUtils.safeCreateFromMinValue(pastDate.getFullYear(), pastDate.getMonth(), pastDate.getDate(), matched.beginHour, 0, 0), - DateUtils.safeCreateFromMinValue(pastDate.getFullYear(), pastDate.getMonth(), pastDate.getDate(), matched.endHour, matched.endMin, matched.endMin), - ]; - result.success = true; - return result; - } - - protected parseDuration(source: string, referenceDate: Date): DateTimeResolutionResult { - let result = new DateTimeResolutionResult(); - - // for rest of datetime, it will be handled in next function - let restOfDateTimeMatch = RegExpUtility.getMatches(this.config.restOfDateTimeRegex, source); - if (restOfDateTimeMatch.length) { - return result; - } - - let ers = this.config.durationExtractor.extract(source, referenceDate); - if (!ers || ers.length !== 1) { - return result; - } - - let pr = this.config.durationParser.parse(ers[0], referenceDate); - if (!pr) { - return result; - } - - let beforeStr = source.substr(0, pr.start).trim(); - let durationResult: DateTimeResolutionResult = pr.value; - let swiftSecond = 0; - let mod: string; - if (Number.isFinite(durationResult.pastValue) && Number.isFinite(durationResult.futureValue)) { - swiftSecond = Math.round(durationResult.futureValue); - } - let beginTime = new Date(referenceDate); - let endTime = new Date(referenceDate); - let prefixMatch = RegExpUtility.getMatches(this.config.pastRegex, beforeStr).pop(); - if (prefixMatch && prefixMatch.length === beforeStr.length) { - mod = TimeTypeConstants.beforeMod; - beginTime.setSeconds(referenceDate.getSeconds() - swiftSecond); - } - prefixMatch = RegExpUtility.getMatches(this.config.futureRegex, beforeStr).pop(); - if (prefixMatch && prefixMatch.length === beforeStr.length) { - mod = TimeTypeConstants.afterMod; - endTime = new Date(beginTime); - endTime.setSeconds(beginTime.getSeconds() + swiftSecond); - } - - let luisDateBegin = DateTimeFormatUtil.luisDateFromDate(beginTime); - let luisTimeBegin = DateTimeFormatUtil.luisTimeFromDate(beginTime); - let luisDateEnd = DateTimeFormatUtil.luisDateFromDate(endTime); - let luisTimeEnd = DateTimeFormatUtil.luisTimeFromDate(endTime); - - result.timex = `(${luisDateBegin}T${luisTimeBegin},${luisDateEnd}T${luisTimeEnd},${durationResult.timex})`; - result.futureValue = [beginTime, endTime]; - result.pastValue = [beginTime, endTime]; - result.success = true; - - if (mod) { - pr.value.mod = mod; - } - result.subDateTimeEntities = [pr]; - - return result; - } - - private isFloat(value: any): boolean { - return Number.isFinite(value) && !Number.isInteger(value); - } - - private parseRelativeUnit(source: string, referenceDate: Date): DateTimeResolutionResult { - let result = new DateTimeResolutionResult(); - let match = RegExpUtility.getMatches(this.config.relativeTimeUnitRegex, source).pop(); - if (!match) { - match = RegExpUtility.getMatches(this.config.restOfDateTimeRegex, source).pop(); - } - if (!match) { - return result; - } - - let srcUnit = match.groups('unit').value; - let unitStr = this.config.unitMap.get(srcUnit); - - if (!unitStr) { - return result; - } - let swift = 1; - let prefixMatch = RegExpUtility.getMatches(this.config.pastRegex, source).pop(); - if (prefixMatch) { - swift = -1; - } - - let beginTime = new Date(referenceDate); - let endTime = new Date(referenceDate); - let ptTimex = ''; - - switch (unitStr) { - case 'D': - endTime = DateUtils.safeCreateFromMinValue(beginTime.getFullYear(), beginTime.getMonth(), beginTime.getDate()); - endTime.setDate(endTime.getDate() + 1); - endTime.setSeconds(endTime.getSeconds() - 1); - ptTimex = `PT${DateUtils.totalSeconds(endTime, beginTime)}S`; - break; - case 'H': - beginTime.setHours(beginTime.getHours() + (swift > 0 ? 0 : swift)); - endTime.setHours(endTime.getHours() + (swift > 0 ? swift : 0)); - ptTimex = `PT1H`; - break; - case 'M': - beginTime.setMinutes(beginTime.getMinutes() + (swift > 0 ? 0 : swift)); - endTime.setMinutes(endTime.getMinutes() + (swift > 0 ? swift : 0)); - ptTimex = `PT1M`; - break; - case 'S': - beginTime.setSeconds(beginTime.getSeconds() + (swift > 0 ? 0 : swift)); - endTime.setSeconds(endTime.getSeconds() + (swift > 0 ? swift : 0)); - ptTimex = `PT1S`; - break; - default: return result; - } - - let luisDateBegin = DateTimeFormatUtil.luisDateFromDate(beginTime); - let luisTimeBegin = DateTimeFormatUtil.luisTimeFromDate(beginTime); - let luisDateEnd = DateTimeFormatUtil.luisDateFromDate(endTime); - let luisTimeEnd = DateTimeFormatUtil.luisTimeFromDate(endTime); - - result.timex = `(${luisDateBegin}T${luisTimeBegin},${luisDateEnd}T${luisTimeEnd},${ptTimex})`; - result.futureValue = [beginTime, endTime]; - result.pastValue = [beginTime, endTime]; - result.success = true; - return result; - } -} diff --git a/JavaScript/packages/recognizers-date-time/src/dateTime/baseDuration.ts b/JavaScript/packages/recognizers-date-time/src/dateTime/baseDuration.ts deleted file mode 100644 index 16d0cf00c2..0000000000 --- a/JavaScript/packages/recognizers-date-time/src/dateTime/baseDuration.ts +++ /dev/null @@ -1,346 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { ExtractResult, RegExpUtility, StringUtility } from "@microsoft/recognizers-text"; -import { Constants, TimeTypeConstants } from "./constants"; -import { BaseNumberExtractor, BaseNumberParser } from "@microsoft/recognizers-text-number"; -import { IDateTimeParser, DateTimeParseResult } from "./parsers"; -import { Token, DateTimeResolutionResult } from "./utilities"; -import { IDateTimeExtractor } from "./baseDateTime"; - -export interface IDurationExtractorConfiguration { - allRegex: RegExp, - halfRegex: RegExp, - followedUnit: RegExp, - numberCombinedWithUnit: RegExp, - anUnitRegex: RegExp, - inexactNumberUnitRegex: RegExp, - suffixAndRegex: RegExp, - relativeDurationUnitRegex: RegExp, - moreThanRegex: RegExp, - lessThanRegex: RegExp, - cardinalExtractor: BaseNumberExtractor -} - -export class BaseDurationExtractor implements IDateTimeExtractor { - private readonly extractorName = Constants.SYS_DATETIME_DURATION; - private readonly config: IDurationExtractorConfiguration; - - constructor(config: IDurationExtractorConfiguration) { - this.config = config; - } - - extract(source: string, refDate: Date): ExtractResult[] { - if (!refDate) { - refDate = new Date(); - } - - let baseTokens = this.numberWithUnit(source); - let tokens: Token[] = new Array() - .concat(baseTokens) - .concat(this.numberWithUnitAndSuffix(source, baseTokens)) - .concat(this.implicitDuration(source)); - let result = Token.mergeAllTokens(tokens, source, this.extractorName); - - this.resolveMoreThanOrLessThanPrefix(source, result); - - return result; - } - - // handle cases look like: {more than | less than} {duration}? - private resolveMoreThanOrLessThanPrefix(text: string, ers: ExtractResult[]) { - for (let er of ers) { - let beforeString = text.substr(0, er.start); - let match = RegExpUtility.getMatches(this.config.moreThanRegex, beforeString); - if (match && match.length) { - er.data = TimeTypeConstants.moreThanMod; - } - - if (!match || match.length === 0) { - match = RegExpUtility.getMatches(this.config.lessThanRegex, beforeString); - if (match && match.length) { - er.data = TimeTypeConstants.lessThanMod; - } - } - - if (match && match.length) { - er.length += er.start - match[0].index; - er.start = match[0].index; - er.text = text.substr(er.start, er.length); - } - } - } - - private numberWithUnit(source: string): Token[] { - return this.config.cardinalExtractor.extract(source) - .map(o => { - let afterString = source.substring(o.start + o.length); - let match = RegExpUtility.getMatches(this.config.followedUnit, afterString)[0]; - if (match && match.index === 0) { - return new Token(o.start | 0, o.start + o.length + match.length); - } - }).filter(o => o !== undefined) - .concat(this.getTokensFromRegex(this.config.numberCombinedWithUnit, source)) - .concat(this.getTokensFromRegex(this.config.anUnitRegex, source)) - .concat(this.getTokensFromRegex(this.config.inexactNumberUnitRegex, source)); - } - - private numberWithUnitAndSuffix(source: string, ers: Token[]): Token[] { - return ers.map(o => { - let afterString = source.substring(o.start + o.length); - let match = RegExpUtility.getMatches(this.config.suffixAndRegex, afterString)[0]; - if (match && match.index === 0) { - return new Token(o.start | 0, o.start + o.length + match.length); - } - }); - } - - private implicitDuration(source: string): Token[] { - // handle "all day", "all year" - return this.getTokensFromRegex(this.config.allRegex, source) - // handle "half day", "half year" - .concat(this.getTokensFromRegex(this.config.halfRegex, source)) - // handle "next day", "last year" - .concat(this.getTokensFromRegex(this.config.relativeDurationUnitRegex, source)); - } - - private getTokensFromRegex(regexp: RegExp, source: string): Token[] { - return RegExpUtility.getMatches(regexp, source) - .map(o => new Token(o.index, o.index + o.length)); - } -} - -export interface IDurationParserConfiguration { - cardinalExtractor: BaseNumberExtractor - numberParser: BaseNumberParser - followedUnit: RegExp - suffixAndRegex: RegExp - numberCombinedWithUnit: RegExp - anUnitRegex: RegExp - allDateUnitRegex: RegExp - halfDateUnitRegex: RegExp - inexactNumberUnitRegex: RegExp - unitMap: ReadonlyMap - unitValueMap: ReadonlyMap - doubleNumbers: ReadonlyMap -} - -export class BaseDurationParser implements IDateTimeParser { - protected readonly parserName = Constants.SYS_DATETIME_DURATION; - protected readonly config: IDurationParserConfiguration; - - constructor(config: IDurationParserConfiguration) { - this.config = config; - } - - parse(extractorResult: ExtractResult, referenceDate?: Date): DateTimeParseResult | null { - if (!referenceDate) { - referenceDate = new Date(); - } - let resultValue; - if (extractorResult.type === this.parserName) { - let source = extractorResult.text.toLowerCase(); - let innerResult = this.parseNumberWithUnit(source, referenceDate); - if (!innerResult.success) { - innerResult = this.parseImplicitDuration(source, referenceDate); - } - if (innerResult.success) { - innerResult.futureResolution = {}; - innerResult.futureResolution[TimeTypeConstants.DURATION] = innerResult.futureValue.toString(); - innerResult.pastResolution = {}; - innerResult.pastResolution[TimeTypeConstants.DURATION] = innerResult.pastValue.toString(); - resultValue = innerResult; - } - } - - let value = resultValue as DateTimeResolutionResult; - - if (value && extractorResult.data) { - if (extractorResult.data === TimeTypeConstants.moreThanMod || - extractorResult.data === TimeTypeConstants.lessThanMod) { - value.mod = extractorResult.data; - } - } - - let result = new DateTimeParseResult(extractorResult); - result.value = resultValue; - result.timexStr = resultValue ? resultValue.timex : ''; - result.resolutionStr = ''; - - return result; - } - - private parseNumberWithUnit(source: string, referenceDate: Date): DateTimeResolutionResult { - let trimmedSource = source.trim(); - let result = this.parseNumberSpaceUnit(trimmedSource); - if (!result.success) { - result = this.parseNumberCombinedUnit(trimmedSource); - } - if (!result.success) { - result = this.parseAnUnit(trimmedSource); - } - if (!result.success) { - result = this.parseInexactNumberUnit(trimmedSource); - } - return result; - } - - private parseImplicitDuration(source: string, referenceDate: Date): DateTimeResolutionResult { - let trimmedSource = source.trim(); - // handle "all day" "all year" - let result = this.getResultFromRegex(this.config.allDateUnitRegex, trimmedSource, 1); - // handle "half day", "half year" - if (!result.success) { - result = this.getResultFromRegex(this.config.halfDateUnitRegex, trimmedSource, 0.5); - } - // handle single duration unit, it is filtered in the extraction that there is a relative word in advance - if (!result.success) { - result = this.getResultFromRegex(this.config.followedUnit, trimmedSource, 1); - } - return result; - } - - private getResultFromRegex(regex: RegExp, source: string, num: number): DateTimeResolutionResult { - let result = new DateTimeResolutionResult(); - let match = RegExpUtility.getMatches(regex, source).pop(); - if (!match) { - return result; - } - - let sourceUnit = match.groups('unit').value; - if (!this.config.unitMap.has(sourceUnit)) { - return result; - } - - let unitStr = this.config.unitMap.get(sourceUnit); - result.timex = `P${this.isLessThanDay(unitStr) ? 'T' : ''}${num}${unitStr[0]}`; - result.futureValue = num * this.config.unitValueMap.get(sourceUnit); - result.pastValue = result.futureValue; - result.success = true; - return result; - } - - private parseNumberSpaceUnit(source: string): DateTimeResolutionResult { - let result = new DateTimeResolutionResult(); - let suffixStr = source; - let ers = this.config.cardinalExtractor.extract(source); - if (ers && ers.length === 1) { - let er = ers[0]; - let sourceUnit = ''; - let pr = this.config.numberParser.parse(er); - let noNumStr = source.substr(er.start + er.length).trim().toLowerCase(); - let match = RegExpUtility.getMatches(this.config.followedUnit, noNumStr).pop(); - if (match) { - sourceUnit = match.groups('unit').value; - suffixStr = match.groups('suffix').value; - } - if (this.config.unitMap.has(sourceUnit)) { - let num = Number.parseFloat(pr.value) + this.parseNumberWithUnitAndSuffix(suffixStr); - let unitStr = this.config.unitMap.get(sourceUnit); - - result.timex = `P${this.isLessThanDay(unitStr) ? 'T' : ''}${num}${unitStr[0]}`; - result.futureValue = num * this.config.unitValueMap.get(sourceUnit); - result.pastValue = result.futureValue; - result.success = true; - return result; - } - } - return result; - } - - private parseNumberWithUnitAndSuffix(source: string): number { - let match = RegExpUtility.getMatches(this.config.suffixAndRegex, source).pop(); - if (match) { - let numStr = match.groups('suffix_num').value; - if (this.config.doubleNumbers.has(numStr)) { - return this.config.doubleNumbers.get(numStr); - } - } - return 0; - } - - private parseNumberCombinedUnit(source: string): DateTimeResolutionResult { - let result = new DateTimeResolutionResult(); - let match = RegExpUtility.getMatches(this.config.numberCombinedWithUnit, source).pop(); - if (!match) { - return result; - } - let num = Number.parseFloat(match.groups('num').value) + this.parseNumberWithUnitAndSuffix(source); - - let sourceUnit = match.groups('unit').value; - if (this.config.unitMap.has(sourceUnit)) { - let unitStr = this.config.unitMap.get(sourceUnit); - if (num > 1000 && (unitStr === 'Y' || unitStr === 'MON' || unitStr === 'W')) { - return result; - } - - result.timex = `P${this.isLessThanDay(unitStr) ? 'T' : ''}${num}${unitStr[0]}`; - result.futureValue = num * this.config.unitValueMap.get(sourceUnit); - result.pastValue = result.futureValue; - result.success = true; - return result; - } - return result; - } - - private parseAnUnit(source: string): DateTimeResolutionResult { - let result = new DateTimeResolutionResult(); - let match = RegExpUtility.getMatches(this.config.anUnitRegex, source).pop(); - if (!match) { - match = RegExpUtility.getMatches(this.config.halfDateUnitRegex, source).pop(); - } - if (!match) { - return result; - } - let num = StringUtility.isNullOrEmpty(match.groups('half').value) ? 1 : 0.5; - num += this.parseNumberWithUnitAndSuffix(source); - - let sourceUnit = match.groups('unit').value; - if (this.config.unitMap.has(sourceUnit)) { - let unitStr = this.config.unitMap.get(sourceUnit); - - result.timex = `P${this.isLessThanDay(unitStr) ? 'T' : ''}${num}${unitStr[0]}`; - result.futureValue = num * this.config.unitValueMap.get(sourceUnit); - result.pastValue = result.futureValue; - result.success = true; - return result; - } - return result; - } - - private parseInexactNumberUnit(source: string): DateTimeResolutionResult { - let result = new DateTimeResolutionResult(); - let match = RegExpUtility.getMatches(this.config.inexactNumberUnitRegex, source).pop(); - if (!match) { - return result; - } - - let num: number; - if (match.groups('NumTwoTerm').value) { - num = 2; - } - else { - // set the inexact number "few", "some" to 3 for now - num = 3; - } - - let sourceUnit = match.groups('unit').value; - if (this.config.unitMap.has(sourceUnit)) { - let unitStr = this.config.unitMap.get(sourceUnit); - if (num > 1000 && (unitStr === 'Y' || unitStr === 'MON' || unitStr === 'W')) { - return result; - } - - result.timex = `P${this.isLessThanDay(unitStr) ? 'T' : ''}${num}${unitStr[0]}`; - result.futureValue = num * this.config.unitValueMap.get(sourceUnit); - result.pastValue = result.futureValue; - result.success = true; - return result; - } - return result; - } - - protected isLessThanDay(source: string): boolean { - return (source === 'S') || (source === 'M') || (source === 'H'); - } -} diff --git a/JavaScript/packages/recognizers-date-time/src/dateTime/baseHoliday.ts b/JavaScript/packages/recognizers-date-time/src/dateTime/baseHoliday.ts deleted file mode 100644 index 7d8ae3c4ad..0000000000 --- a/JavaScript/packages/recognizers-date-time/src/dateTime/baseHoliday.ts +++ /dev/null @@ -1,299 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { IExtractor, ExtractResult, RegExpUtility, Match, MetaData } from "@microsoft/recognizers-text"; -import { Constants, TimeTypeConstants } from "./constants"; -import { Token, DateTimeFormatUtil, DateTimeResolutionResult, DayOfWeek, DateUtils, StringMap } from "./utilities"; -import { IDateTimeParser, DateTimeParseResult } from "./parsers"; -import { BaseDateTime } from "../resources/baseDateTime"; -import { IDateTimeExtractor } from "./baseDateTime"; - -export interface IHolidayExtractorConfiguration { - holidayRegexes: RegExp[] -} - -export class BaseHolidayExtractor implements IDateTimeExtractor { - private readonly extractorName = Constants.SYS_DATETIME_DATE - private readonly config: IHolidayExtractorConfiguration; - - constructor(config: IHolidayExtractorConfiguration) { - this.config = config; - } - - extract(source: string, refDate: Date): ExtractResult[] { - if (!refDate) { - refDate = new Date(); - } - let referenceDate = refDate; - - let tokens: Token[] = new Array() - .concat(this.holidayMatch(source)); - let results = Token.mergeAllTokens(tokens, source, this.extractorName); - results.forEach(result => { - let metaData = new MetaData(); - metaData.IsHoliday = true; - result.metaData = metaData; - }); - return results; - } - - private holidayMatch(source: string): Token[] { - let ret = []; - this.config.holidayRegexes.forEach(regex => { - RegExpUtility.getMatches(regex, source).forEach(match => { - ret.push(new Token(match.index, match.index + match.length)); - }); - }); - return ret; - } -} - -export interface IHolidayParserConfiguration { - variableHolidaysTimexDictionary: ReadonlyMap; - holidayFuncDictionary: ReadonlyMap Date>; - holidayNames: ReadonlyMap; - holidayRegexList: RegExp[]; - getSwiftYear(text: string): number; - sanitizeHolidayToken(holiday: string): string; -} - -export class BaseHolidayParser implements IDateTimeParser { - public static readonly ParserName = Constants.SYS_DATETIME_DATE; // "Date"; - protected readonly config: IHolidayParserConfiguration; - - constructor(config: IHolidayParserConfiguration) { - this.config = config; - } - - public parse(er: ExtractResult, referenceDate: Date): DateTimeParseResult { - if (!referenceDate) { - referenceDate = new Date(); - } - let value = null; - - if (er.type === BaseHolidayParser.ParserName) { - let innerResult = this.parseHolidayRegexMatch(er.text, referenceDate); - - if (innerResult.success) { - innerResult.futureResolution = {}; - innerResult.futureResolution[TimeTypeConstants.DATE] = DateTimeFormatUtil.formatDate(innerResult.futureValue); - innerResult.pastResolution = {}; - innerResult.pastResolution[TimeTypeConstants.DATE] = DateTimeFormatUtil.formatDate(innerResult.pastValue); - value = innerResult; - } - } - - let ret = new DateTimeParseResult(er); - ret.value = value; - ret.timexStr = value === null ? "" : value.timex; - ret.resolutionStr = ""; - - return ret; - } - - protected parseHolidayRegexMatch(text: string, referenceDate: Date): DateTimeResolutionResult { - let trimmedText = text.trim(); - for (let regex of this.config.holidayRegexList) { - let offset = 0; - let matches = RegExpUtility.getMatches(regex, trimmedText); - if (matches.length && matches[0].index === offset && matches[0].length === trimmedText.length) { - // LUIS value string will be set in Match2Date method - let ret = this.match2Date(matches[0], referenceDate); - return ret; - } - } - return new DateTimeResolutionResult(); - } - - protected match2Date(match: Match, referenceDate: Date): DateTimeResolutionResult { - let ret = new DateTimeResolutionResult(); - let holidayStr = this.config.sanitizeHolidayToken(match.groups("holiday").value.toLowerCase()); - - // get year (if exist) - let yearStr = match.groups("year").value.toLowerCase(); - let orderStr = match.groups("order").value.toLowerCase(); - let year: number; - let hasYear = false; - - if (yearStr) { - year = parseInt(yearStr, 10); - hasYear = true; - } - else if (orderStr) { - let swift = this.config.getSwiftYear(orderStr); - if (swift < -1) { - return ret; - } - year = referenceDate.getFullYear() + swift; - hasYear = true; - } - else { - year = referenceDate.getFullYear(); - } - - let holidayKey: string; - for (holidayKey of this.config.holidayNames.keys()) { - if (this.config.holidayNames.get(holidayKey).indexOf(holidayStr) > -1) { - break; - } - } - - if (holidayKey) { - let timexStr: string; - let value = referenceDate; - let func = this.config.holidayFuncDictionary.get(holidayKey); - if (func) { - value = func(year); - timexStr = this.config.variableHolidaysTimexDictionary.get(holidayKey); - if (!timexStr) { - timexStr = `-${DateTimeFormatUtil.toString(value.getMonth() + 1, 2)}-${DateTimeFormatUtil.toString(value.getDate(), 2)}`; - } - } - else { - return ret; - } - - if (value.getTime() === DateUtils.minValue().getTime()) { - ret.timex = ''; - ret.futureValue = DateUtils.minValue(); - ret.pastValue = DateUtils.minValue(); - ret.success = true; - return ret; - } - - if (hasYear) { - ret.timex = DateTimeFormatUtil.toString(year, 4) + timexStr; - ret.futureValue = ret.pastValue = new Date(year, value.getMonth(), value.getDate()); - ret.success = true; - return ret; - } - - ret.timex = "XXXX" + timexStr; - ret.futureValue = this.getFutureValue(value, referenceDate, holidayKey); - ret.pastValue = this.getPastValue(value, referenceDate, holidayKey); - ret.success = true; - - return ret; - } - - return ret; - } - - private getFutureValue(value: Date, referenceDate: Date, holiday: string): Date { - if (value < referenceDate) { - let func = this.config.holidayFuncDictionary.get(holiday); - if (func) { - return func(value.getFullYear() + 1); - } - } - return value; - } - - private getPastValue(value: Date, referenceDate: Date, holiday: string): Date { - if (value >= referenceDate) { - let func = this.config.holidayFuncDictionary.get(holiday); - if (func) { - return func(value.getFullYear() - 1); - } - } - return value; - } -} - -export abstract class BaseHolidayParserConfiguration implements IHolidayParserConfiguration { - variableHolidaysTimexDictionary: ReadonlyMap; - holidayFuncDictionary: ReadonlyMap Date>; - holidayNames: ReadonlyMap; - holidayRegexList: RegExp[]; - abstract getSwiftYear(text: string): number; - abstract sanitizeHolidayToken(holiday: string): string; - - constructor() { - this.variableHolidaysTimexDictionary = BaseDateTime.VariableHolidaysTimexDictionary; - this.holidayFuncDictionary = this.initHolidayFuncs(); - } - - // TODO auto-generate from YAML - protected initHolidayFuncs(): ReadonlyMap Date> { - return new Map Date>( - [ - ["fathers", BaseHolidayParserConfiguration.FathersDay], - ["mothers", BaseHolidayParserConfiguration.MothersDay], - ["thanksgivingday", BaseHolidayParserConfiguration.ThanksgivingDay], - ["thanksgiving", BaseHolidayParserConfiguration.ThanksgivingDay], - ["blackfriday", BaseHolidayParserConfiguration.BlackFriday], - ["martinlutherking", BaseHolidayParserConfiguration.MartinLutherKingDay], - ["washingtonsbirthday", BaseHolidayParserConfiguration.WashingtonsBirthday], - ["canberra", BaseHolidayParserConfiguration.CanberraDay], - ["labour", BaseHolidayParserConfiguration.LabourDay], - ["columbus", BaseHolidayParserConfiguration.ColumbusDay], - ["memorial", BaseHolidayParserConfiguration.MemorialDay] - ]); - } - - // All months are zero-based (-1) - // TODO auto-generate from YAML - protected static MothersDay(year: number): Date { - return new Date(year, 5 - 1, BaseHolidayParserConfiguration.getDay(year, 5 - 1, 1, DayOfWeek.Sunday)); - } - - protected static FathersDay(year: number): Date { - return new Date(year, 6 - 1, BaseHolidayParserConfiguration.getDay(year, 6 - 1, 2, DayOfWeek.Sunday)); - } - - private static MartinLutherKingDay(year: number): Date { - return new Date(year, 1 - 1, BaseHolidayParserConfiguration.getDay(year, 1 - 1, 2, DayOfWeek.Monday)); - } - - private static WashingtonsBirthday(year: number): Date { - return new Date(year, 2 - 1, BaseHolidayParserConfiguration.getDay(year, 2 - 1, 2, DayOfWeek.Monday)); - } - - private static CanberraDay(year: number): Date { - return new Date(year, 3 - 1, BaseHolidayParserConfiguration.getDay(year, 3 - 1, 0, DayOfWeek.Monday)); - } - - protected static MemorialDay(year: number): Date { - return new Date(year, 5 - 1, BaseHolidayParserConfiguration.getLastDay(year, 5 - 1, DayOfWeek.Monday)); - } - - protected static LabourDay(year: number): Date { - return new Date(year, 9 - 1, BaseHolidayParserConfiguration.getDay(year, 9 - 1, 0, DayOfWeek.Monday)); - } - - protected static InternationalWorkersDay(year: number): Date { - return new Date(year, 5 - 1, 1); - } - - protected static ColumbusDay(year: number): Date { - return new Date(year, 10 - 1, BaseHolidayParserConfiguration.getDay(year, 10 - 1, 1, DayOfWeek.Monday)); - } - - protected static ThanksgivingDay(year: number): Date { - return new Date(year, 11 - 1, BaseHolidayParserConfiguration.getDay(year, 11 - 1, 3, DayOfWeek.Thursday)); - } - - protected static BlackFriday(year: number): Date { - return new Date(year, 11 - 1, BaseHolidayParserConfiguration.getDay(year, 11 - 1, 3, DayOfWeek.Friday)); - } - - protected static getDay(year: number, month: number, week: number, dayOfWeek: DayOfWeek): number { - let days = Array.apply(null, new Array(new Date(year, month, 0).getDate())).map(function (x, i) { - return i + 1; - }); - days = days.filter(function (day) { - return new Date(year, month, day).getDay() === dayOfWeek; - }); - return days[week]; - } - - protected static getLastDay(year: number, month: number, dayOfWeek: DayOfWeek): number { - let days = Array.apply(null, new Array(new Date(year, month, 0).getDate())).map(function (x, i) { - return i + 1; - }); - days = days.filter(function (day) { - return new Date(year, month, day).getDay() === dayOfWeek; - }); - return days[days.length - 1]; - } -} diff --git a/JavaScript/packages/recognizers-date-time/src/dateTime/baseMerged.ts b/JavaScript/packages/recognizers-date-time/src/dateTime/baseMerged.ts deleted file mode 100644 index 68a6aac7e2..0000000000 --- a/JavaScript/packages/recognizers-date-time/src/dateTime/baseMerged.ts +++ /dev/null @@ -1,821 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { IExtractor, ExtractResult, MetaData } from "@microsoft/recognizers-text"; -import { Constants, TimeTypeConstants } from "./constants"; -import { RegExpUtility, StringUtility, BaseNumberExtractor } from "@microsoft/recognizers-text-number"; -import { IDateTimeParser, DateTimeParseResult } from "./parsers"; -import { DateTimeFormatUtil, DateUtils, DateTimeResolutionResult, Token, StringMap } from "./utilities"; -import { BaseDateExtractor, BaseDateParser } from "./baseDate"; -import { BaseTimeExtractor, BaseTimeParser } from "./baseTime"; -import { BaseDatePeriodExtractor, BaseDatePeriodParser } from "./baseDatePeriod"; -import { BaseTimePeriodExtractor, BaseTimePeriodParser } from "./baseTimePeriod"; -import { IDateTimeExtractor, BaseDateTimeExtractor, BaseDateTimeParser } from "./baseDateTime"; -import { BaseDateTimePeriodExtractor, BaseDateTimePeriodParser } from "./baseDateTimePeriod"; -import { BaseSetExtractor, BaseSetParser } from "./baseSet"; -import { BaseDurationExtractor, BaseDurationParser } from "./baseDuration"; -import { BaseHolidayExtractor, BaseHolidayParser } from "./baseHoliday"; -import isEqual = require('lodash.isequal'); -import { DateTimeOptions } from "./dateTimeRecognizer"; - -export interface IMergedExtractorConfiguration { - dateExtractor: IDateTimeExtractor - timeExtractor: IDateTimeExtractor - dateTimeExtractor: IDateTimeExtractor - datePeriodExtractor: IDateTimeExtractor - timePeriodExtractor: IDateTimeExtractor - dateTimePeriodExtractor: IDateTimeExtractor - holidayExtractor: IDateTimeExtractor - durationExtractor: IDateTimeExtractor - setExtractor: IDateTimeExtractor - integerExtractor: BaseNumberExtractor - afterRegex: RegExp - beforeRegex: RegExp - sinceRegex: RegExp - fromToRegex: RegExp - singleAmbiguousMonthRegex: RegExp - ambiguousRangeModifierPrefix: RegExp - potentialAmbiguousRangeRegex: RegExp - prepositionSuffixRegex: RegExp - numberEndingPattern: RegExp - unspecificDatePeriodRegex: RegExp - filterWordRegexList: RegExp[] - AmbiguityFiltersDict: Map -} - -export class BaseMergedExtractor implements IDateTimeExtractor { - protected readonly config: IMergedExtractorConfiguration; - protected readonly options: DateTimeOptions; - - private static readonly NumberOrConnectorRegex: RegExp = new RegExp('^[0-9-]+$'); - - constructor(config: IMergedExtractorConfiguration, options: DateTimeOptions) { - this.config = config; - this.options = options; - } - - extract(source: string, refDate: Date): ExtractResult[] { - if (!refDate) { - refDate = new Date(); - } - let referenceDate = refDate; - - let result: ExtractResult[] = new Array(); - this.addTo(result, this.config.dateExtractor.extract(source, referenceDate), source); - this.addTo(result, this.config.timeExtractor.extract(source, referenceDate), source); - this.addTo(result, this.config.datePeriodExtractor.extract(source, referenceDate), source); - this.addTo(result, this.config.durationExtractor.extract(source, referenceDate), source); - this.addTo(result, this.config.timePeriodExtractor.extract(source, referenceDate), source); - this.addTo(result, this.config.dateTimePeriodExtractor.extract(source, referenceDate), source); - this.addTo(result, this.config.dateTimeExtractor.extract(source, referenceDate), source); - this.addTo(result, this.config.setExtractor.extract(source, referenceDate), source); - this.addTo(result, this.config.holidayExtractor.extract(source, referenceDate), source); - - // this should be at the end since if need the extractor to determine the previous text contains time or not - this.addTo(result, this.numberEndingRegexMatch(source, result), source); - - result = this.filterUnspecificDatePeriod(result); - - // Remove common ambiguous cases - result = this.filterAmbiguity(result, source); - - this.addMod(result, source); - - // filtering - if ((this.options & DateTimeOptions.Calendar) !== 0) { - this.checkCalendarFilterList(result, source); - } - - result = result.sort((a, b) => a.start - b.start); - return result; - } - - private checkCalendarFilterList(ers: ExtractResult[], text: string) { - for (let er of ers.reverse()) { - for (let negRegex of this.config.filterWordRegexList) { - let match = RegExpUtility.getMatches(negRegex, er.text).pop(); - if (match) { - ers.splice(ers.indexOf(er)); - } - } - } - } - - // handle cases like "move 3pm appointment to 4" - private numberEndingRegexMatch(text: string, extractResults: ExtractResult[]): ExtractResult[] { - let tokens = new Array(); - - extractResults.forEach(extractResult => { - if (extractResult.type === Constants.SYS_DATETIME_TIME - || extractResult.type === Constants.SYS_DATETIME_DATETIME) { - let stringAfter = text.substring(extractResult.start + extractResult.length); - let match = RegExpUtility.getMatches(this.config.numberEndingPattern, stringAfter); - if (match != null && match.length) { - let newTime = match[0].groups("newTime"); - let numRes = this.config.integerExtractor.extract(newTime.value); - if (numRes.length === 0) { - return; - } - - let startPosition = extractResult.start + extractResult.length + newTime.index; - tokens.push(new Token(startPosition, startPosition + newTime.length)); - } - } - }); - - return Token.mergeAllTokens(tokens, text, Constants.SYS_DATETIME_TIME); - } - - protected addTo(destination: ExtractResult[], source: ExtractResult[], text: string) { - source.forEach(value => { - if (this.options === DateTimeOptions.SkipFromToMerge && this.shouldSkipFromMerge(value)) { - return; - } - - let isFound = false; - let overlapIndexes = new Array(); - let firstIndex = -1; - destination.forEach((dest, index) => { - if (ExtractResult.isOverlap(dest, value)) { - isFound = true; - if (ExtractResult.isCover(dest, value)) { - if (firstIndex === -1) { - firstIndex = index; - } - overlapIndexes.push(index); - } - else { - return; - } - } - }); - if (!isFound) { - destination.push(value); - } - else if (overlapIndexes.length) { - let tempDst = new Array(); - for (let i = 0; i < destination.length; i++) { - if (overlapIndexes.indexOf(i) === -1) { - tempDst.push(destination[i]); - } - } - - // insert at the first overlap occurrence to keep the order - tempDst.splice(firstIndex, 0, value); - destination.length = 0; - destination.push.apply(destination, tempDst); - } - }); - } - - private shouldSkipFromMerge(er: ExtractResult): boolean { - return RegExpUtility.getMatches(this.config.fromToRegex, er.text).length > 0; - } - - private filterUnspecificDatePeriod (ers: ExtractResult[]): ExtractResult[] { - ers = ers.filter(er => !RegExpUtility.isMatch(this.config.unspecificDatePeriodRegex, er.text)); - return ers; - } - - private filterAmbiguity(extractResults: ExtractResult[], text: string): ExtractResult[] { - if (this.config.AmbiguityFiltersDict != null) { - for (let [regexKey, regexValue] of this.config.AmbiguityFiltersDict) { - extractResults.forEach(extractResult => { - if (RegExpUtility.isMatch(regexKey, extractResult.text)) { - let matches = RegExpUtility.getMatches(regexValue, text); - extractResults = extractResults.filter(er => !matches.some(m => m.index < er.start + er.length && m.index + m.length > er.start)); - } - }); - } - } - - // @TODO: Refactor to remove this method and use the general ambiguity filter approach - extractResults = extractResults.filter(er => !(RegExpUtility.isMatch(BaseMergedExtractor.NumberOrConnectorRegex, er.text) && - (text.substring(0, er.start).trim().endsWith("-") || text.substring((er.start + er.length)).trim().startsWith("-")))); - - return extractResults; - } - - private filterAmbiguousSingleWord(er: ExtractResult, text: string): boolean { - let matches = RegExpUtility.getMatches(this.config.singleAmbiguousMonthRegex, er.text.toLowerCase()); - if (matches.length) { - let stringBefore = text.substring(0, er.start).replace(/\s+$/, ''); - matches = RegExpUtility.getMatches(this.config.prepositionSuffixRegex, stringBefore); - if (!matches.length) { - return true; - } - } - return false; - } - - protected addMod(ers: ExtractResult[], source: string) { - let lastEnd = 0; - ers.forEach(er => { - let success = this.tryMergeModifierToken(er, this.config.beforeRegex, source); - if (!success) { - success = this.tryMergeModifierToken(er, this.config.afterRegex, source); - } - - if (!success) { - // SinceRegex in English contains the term "from" which is potentially ambiguous with ranges in the form "from X to Y" - success = this.tryMergeModifierToken(er, this.config.sinceRegex, source, true); - } - }); - } - - protected tryMergeModifierToken(er:ExtractResult, regex: RegExp, source: string, potentialAmbiguity:boolean = false): boolean { - let beforeStr = source.substr(0, er.start).toLowerCase(); - - // Avoid adding mod for ambiguity cases, such as "from" in "from ... to ..." should not add mod - if (potentialAmbiguity && this.config.ambiguousRangeModifierPrefix && - RegExpUtility.isMatch(this.config.ambiguousRangeModifierPrefix, beforeStr)) { - let matches = RegExpUtility.getMatches(this.config.potentialAmbiguousRangeRegex, source); - if (matches.find(m => m.index < er.start + er.length && m.index + m.length > er.start)) { - return false - } - } - - let token = this.hasTokenIndex(beforeStr.trim(), regex); - if (token.matched) { - let modLength = beforeStr.length - token.index; - er.length += modLength; - er.start -= modLength; - er.text = source.substr(er.start, er.length); - - er.metaData = this.assignModMetadata(er.metaData); - - return true; - } - - return false; - } - - protected assignModMetadata(metadata: MetaData): MetaData { - - if (metadata === undefined || metadata === null) { - metadata = new MetaData(); - metadata.HasMod = true; - } else { - metadata.HasMod = true; - } - - return metadata - } - - protected hasTokenIndex(source: string, regex: RegExp): { matched: boolean, index: number } { - // This part is different from C# because no Regex RightToLeft option in JS - let result = { matched: false, index: -1 }; - let matchResult = RegExpUtility.getMatches(regex, source); - let match = matchResult[matchResult.length - 1]; - if (match && !source.substr(match.index + match.length).trim().length) { - result.matched = true; - result.index = match.index; - } - return result; - } -} - -export interface IMergedParserConfiguration { - beforeRegex: RegExp - afterRegex: RegExp - sinceRegex: RegExp - dateParser: BaseDateParser - holidayParser: BaseHolidayParser - timeParser: BaseTimeParser - dateTimeParser: BaseDateTimeParser - datePeriodParser: BaseDatePeriodParser - timePeriodParser: BaseTimePeriodParser - dateTimePeriodParser: BaseDateTimePeriodParser - durationParser: BaseDurationParser - setParser: BaseSetParser -} - -export class BaseMergedParser implements IDateTimeParser { - readonly parserTypeName = 'datetimeV2'; - - protected readonly config: IMergedParserConfiguration; - private readonly options: DateTimeOptions; - - private readonly dateDefaultValue = DateTimeFormatUtil.formatDate(new Date(1, 0, 1, 0, 0, 0, 0)); - private readonly dateMinValue = DateTimeFormatUtil.formatDate(DateUtils.minValue()); - private readonly dateTimeMinValue = DateTimeFormatUtil.formatDateTime(DateUtils.minValue()); - - constructor(config: IMergedParserConfiguration, options: DateTimeOptions) { - this.config = config; - this.options = options; - } - - parse(er: ExtractResult, refTime?: Date): DateTimeParseResult | null { - let referenceTime = refTime || new Date(); - let pr: DateTimeParseResult = null; - - // push, save teh MOD string - let hasBefore = false; - let hasAfter = false; - let hasSince = false; - let modStr = ""; - - if (er.metaData !== null && er.metaData !== undefined && er.metaData.HasMod) { - let beforeMatch = RegExpUtility.getMatches(this.config.beforeRegex, er.text).shift(); - let afterMatch = RegExpUtility.getMatches(this.config.afterRegex, er.text).shift(); - let sinceMatch = RegExpUtility.getMatches(this.config.sinceRegex, er.text).shift(); - if (beforeMatch && beforeMatch.index === 0) { - hasBefore = true; - er.start += beforeMatch.length; - er.length -= beforeMatch.length; - er.text = er.text.substring(beforeMatch.length); - modStr = beforeMatch.value; - } - else if (afterMatch && afterMatch.index === 0) { - hasAfter = true; - er.start += afterMatch.length; - er.length -= afterMatch.length; - er.text = er.text.substring(afterMatch.length); - modStr = afterMatch.value; - } - else if (sinceMatch && sinceMatch.index === 0) { - hasSince = true; - er.start += sinceMatch.length; - er.length -= sinceMatch.length; - er.text = er.text.substring(sinceMatch.length); - modStr = sinceMatch.value; - } - } - - if (er.type === Constants.SYS_DATETIME_DATE) { - if (er.metaData !== null && er.metaData !== undefined && er.metaData.IsHoliday) { - pr = this.config.holidayParser.parse(er, referenceTime); - } - else { - pr = this.config.dateParser.parse(er, referenceTime); - } - } - else if (er.type === Constants.SYS_DATETIME_TIME) { - pr = this.config.timeParser.parse(er, referenceTime); - } - else if (er.type === Constants.SYS_DATETIME_DATETIME) { - pr = this.config.dateTimeParser.parse(er, referenceTime); - } - else if (er.type === Constants.SYS_DATETIME_DATEPERIOD) { - pr = this.config.datePeriodParser.parse(er, referenceTime); - } - else if (er.type === Constants.SYS_DATETIME_TIMEPERIOD) { - pr = this.config.timePeriodParser.parse(er, referenceTime); - } - else if (er.type === Constants.SYS_DATETIME_DATETIMEPERIOD) { - pr = this.config.dateTimePeriodParser.parse(er, referenceTime); - } - else if (er.type === Constants.SYS_DATETIME_DURATION) { - pr = this.config.durationParser.parse(er, referenceTime); - } - else if (er.type === Constants.SYS_DATETIME_SET) { - pr = this.config.setParser.parse(er, referenceTime); - } - else { - return null; - } - - // pop, restore the MOD string - if (hasBefore && pr.value !== null) { - pr.length += modStr.length; - pr.start -= modStr.length; - pr.text = modStr + pr.text; - let val = pr.value; - val.mod = this.combineMod(val.mod, TimeTypeConstants.beforeMod); - pr.value = val; - } - - if (hasAfter && pr.value !== null) { - pr.length += modStr.length; - pr.start -= modStr.length; - pr.text = modStr + pr.text; - let val = pr.value; - val.mod = this.combineMod(val.mod, TimeTypeConstants.afterMod); - pr.value = val; - } - - if (hasSince && pr.value !== null) { - pr.length += modStr.length; - pr.start -= modStr.length; - pr.text = modStr + pr.text; - let val = pr.value; - val.mod = this.combineMod(val.mod, TimeTypeConstants.sinceMod); - pr.value = val; - } - - if ((this.options & DateTimeOptions.SplitDateAndTime) === DateTimeOptions.SplitDateAndTime - && pr.value && pr.value.subDateTimeEntities != null) { - pr.value = this.dateTimeResolutionForSplit(pr); - } - else { - pr = this.setParseResult(pr, hasBefore, hasAfter, hasSince); - } - - return pr; - } - - public setParseResult(slot: DateTimeParseResult, hasBefore: boolean, hasAfter: boolean, hasSince: boolean): DateTimeParseResult { - let hasRangeChangingMod = hasBefore || hasAfter || hasSince; - slot.value = this.dateTimeResolution(slot, hasBefore, hasAfter, hasSince); - // change the type at last for the after or before mode - slot.type = `${this.parserTypeName}.${this.determineDateTimeType(slot.type, hasRangeChangingMod)}`; - return slot; - } - - protected getParseResult(extractorResult: ExtractResult, referenceDate: Date): DateTimeParseResult | null { - let extractorType = extractorResult.type; - if (extractorType === Constants.SYS_DATETIME_DATE) { - if (extractorResult.metaData !== null && extractorResult.metaData !== undefined && extractorResult.metaData.IsHoliday) { - return this.config.holidayParser.parse(extractorResult, referenceDate); - } - else { - return this.config.dateParser.parse(extractorResult, referenceDate); - } - } - if (extractorType === Constants.SYS_DATETIME_TIME) { - return this.config.timeParser.parse(extractorResult, referenceDate); - } - if (extractorType === Constants.SYS_DATETIME_DATETIME) { - return this.config.dateTimeParser.parse(extractorResult, referenceDate); - } - if (extractorType === Constants.SYS_DATETIME_DATEPERIOD) { - return this.config.datePeriodParser.parse(extractorResult, referenceDate); - } - if (extractorType === Constants.SYS_DATETIME_TIMEPERIOD) { - return this.config.timePeriodParser.parse(extractorResult, referenceDate); - } - if (extractorType === Constants.SYS_DATETIME_DATETIMEPERIOD) { - return this.config.dateTimePeriodParser.parse(extractorResult, referenceDate); - } - if (extractorType === Constants.SYS_DATETIME_DURATION) { - return this.config.durationParser.parse(extractorResult, referenceDate); - } - if (extractorType === Constants.SYS_DATETIME_SET) { - return this.config.setParser.parse(extractorResult, referenceDate); - } - return null; - } - - protected combineMod(originalMod: string, newMod: string): string { - let combinedMod = newMod; - if (originalMod) { - combinedMod = newMod + "-" + originalMod; - } - - return combinedMod; - } - - protected determineDateTimeType(type: string, hasMod: boolean): string { - if ((this.options & DateTimeOptions.SplitDateAndTime) === DateTimeOptions.SplitDateAndTime) { - if (type === Constants.SYS_DATETIME_DATETIME) { - return Constants.SYS_DATETIME_TIME; - } - } - else { - if (hasMod) { - if (type === Constants.SYS_DATETIME_DATE) { - return Constants.SYS_DATETIME_DATEPERIOD; - } - if (type === Constants.SYS_DATETIME_TIME) { - return Constants.SYS_DATETIME_TIMEPERIOD; - } - if (type === Constants.SYS_DATETIME_DATETIME) { - return Constants.SYS_DATETIME_DATETIMEPERIOD; - } - } - } - return type; - } - - protected determineSourceEntityType(sourceType: string, newType: string, hasMod: boolean): string | null { - if (!hasMod) { - return null; - } - - if (newType !== sourceType) { - return Constants.SYS_DATETIME_DATETIMEPOINT; - } - - if (newType === Constants.SYS_DATETIME_DATEPERIOD) { - return Constants.SYS_DATETIME_DATETIMEPERIOD; - } - } - - public dateTimeResolutionForSplit(slot: DateTimeParseResult): DateTimeParseResult[] { - let results = new Array(); - if (slot.value.subDateTimeEntities != null) { - let subEntities = slot.value.subDateTimeEntities; - for (let subEntity of subEntities) { - let result = subEntity; - result.start += slot.start; - results.push(...this.dateTimeResolutionForSplit(result)); - } - } - else { - slot.value = this.dateTimeResolution(slot, false, false, false); - slot.type = `${this.parserTypeName}.${this.determineDateTimeType(slot.type, false)}`; - results.push(slot); - } - return results; - } - - protected dateTimeResolution(slot: DateTimeParseResult, hasBefore: boolean, hasAfter: boolean, hasSince: boolean): { [s: string]: StringMap[]; } { - if (!slot) { - return null; - } - - let result = new Map(); - let resolutions = new Array(); - - let type = slot.type; - let outputType = this.determineDateTimeType(type, hasBefore || hasAfter || hasSince); - let sourceEntity = this.determineSourceEntityType(type, outputType, hasBefore || hasAfter || hasSince); - let timex = slot.timexStr; - - let value: DateTimeResolutionResult = slot.value; - if (!value) { - return null; - } - - let isLunar = value.isLunar; - let mod = value.mod; - let comment = value.comment; - - // the following should added to res first since the ResolveAmPm is using these fields - this.addResolutionFieldsAny(result, Constants.TimexKey, timex); - this.addResolutionFieldsAny(result, Constants.CommentKey, comment); - this.addResolutionFieldsAny(result, Constants.ModKey, mod); - this.addResolutionFieldsAny(result, Constants.TypeKey, outputType); - this.addResolutionFieldsAny(result, Constants.IsLunarKey, isLunar ? String(isLunar) : ""); - - let futureResolution = value.futureResolution; - let pastResolution = value.pastResolution; - - let future = this.generateFromResolution(type, futureResolution, mod); - let past = this.generateFromResolution(type, pastResolution, mod); - - let futureValues = Array.from(this.getValues(future)).sort(); - let pastValues = Array.from(this.getValues(past)).sort(); - if (isEqual(futureValues, pastValues)) { - if (pastValues.length > 0) { - this.addResolutionFieldsAny(result, Constants.ResolveKey, past); - } - } - else { - if (pastValues.length > 0) { - this.addResolutionFieldsAny(result, Constants.ResolveToPastKey, past); - } - if (futureValues.length > 0) { - this.addResolutionFieldsAny(result, Constants.ResolveToFutureKey, future); - } - } - - if (comment && comment === 'ampm') { - if (result.has('resolve')) { - this.resolveAMPM(result, 'resolve'); - } - else { - this.resolveAMPM(result, 'resolveToPast'); - this.resolveAMPM(result, 'resolveToFuture'); - } - } - - if (comment && this.HasDoubleTimex(comment)) { - this.processDoubleTimex(result, Constants.ResolveToFutureKey, Constants.ResolveToPastKey, timex); - } - - result.forEach((value, key) => { - if (this.isObject(value)) { - // is "StringMap" - let newValues = {}; - - this.addResolutionFields(newValues, Constants.TimexKey, timex); - this.addResolutionFields(newValues, Constants.ModKey, mod); - this.addResolutionFields(newValues, Constants.TypeKey, outputType); - this.addResolutionFields(newValues, Constants.IsLunarKey, isLunar ? String(isLunar) : ""); - this.addResolutionFields(newValues, Constants.SourceEntity, sourceEntity); - - Object.keys(value).forEach((innerKey) => { - newValues[innerKey] = value[innerKey]; - }); - - resolutions.push(newValues); - } - }); - - if (Object.keys(past).length === 0 && Object.keys(future).length === 0) { - let o = {}; - o['timex'] = timex; - o['type'] = outputType; - o['value'] = 'not resolved'; - resolutions.push(o); - } - return { - values: resolutions - }; - } - - protected isObject(o: any) { - return (!!o) && (o.constructor === Object); - } - - protected addResolutionFieldsAny(dic: Map, key: string, value: any) { - if (value instanceof String) { - if (!StringUtility.isNullOrEmpty(value as string)) { - dic.set(key, value); - } - } - else { - dic.set(key, value); - } - } - - protected addResolutionFields(dic: StringMap, key: string, value: string) { - if (!StringUtility.isNullOrEmpty(value)) { - dic[key] = value; - } - } - - protected generateFromResolution(type: string, resolutions: StringMap, mod: string): StringMap { - let result = {}; - switch (type) { - case Constants.SYS_DATETIME_DATETIME: - this.addSingleDateTimeToResolution(resolutions, TimeTypeConstants.DATETIME, mod, result); - break; - - case Constants.SYS_DATETIME_TIME: - this.addSingleDateTimeToResolution(resolutions, TimeTypeConstants.TIME, mod, result); - break; - - case Constants.SYS_DATETIME_DATE: - this.addSingleDateTimeToResolution(resolutions, TimeTypeConstants.DATE, mod, result); - break; - - case Constants.SYS_DATETIME_DURATION: - if (resolutions.hasOwnProperty(TimeTypeConstants.DURATION)) { - result[TimeTypeConstants.VALUE] = resolutions[TimeTypeConstants.DURATION]; - } - - break; - - case Constants.SYS_DATETIME_TIMEPERIOD: - this.addPeriodToResolution(resolutions, TimeTypeConstants.START_TIME, TimeTypeConstants.END_TIME, mod, result); - break; - - case Constants.SYS_DATETIME_DATEPERIOD: - this.addPeriodToResolution(resolutions, TimeTypeConstants.START_DATE, TimeTypeConstants.END_DATE, mod, result); - break; - - case Constants.SYS_DATETIME_DATETIMEPERIOD: - this.addPeriodToResolution(resolutions, TimeTypeConstants.START_DATETIME, TimeTypeConstants.END_DATETIME, mod, result); - break; - } - return result; - } - - private addSingleDateTimeToResolution(resolutions: StringMap, type: string, mod: string, result: StringMap) { - let key = TimeTypeConstants.VALUE; - let value = resolutions[type]; - if (!value || this.dateMinValue === value || this.dateTimeMinValue === value || value.startsWith(this.dateDefaultValue)) { - return; - } - - if (!StringUtility.isNullOrEmpty(mod)) { - if (mod === TimeTypeConstants.beforeMod) { - key = TimeTypeConstants.END; - } - else if (mod === TimeTypeConstants.afterMod) { - key = TimeTypeConstants.START; - } - else if (mod === TimeTypeConstants.sinceMod) { - key = TimeTypeConstants.START; - } - } - - result[key] = value; - } - - private addPeriodToResolution(resolutions: StringMap, startType: string, endType: string, mod: string, result: StringMap) { - let start = resolutions[startType]; - let end = resolutions[endType]; - if (start === Constants.InvalidDateString || end === Constants.InvalidDateString) { - return; - } - - if (!StringUtility.isNullOrEmpty(mod)) { - // For the 'before' mod - // 1. Cases like "Before December", the start of the period should be the end of the new period, not the start - // 2. Cases like "More than 3 days before today", the date point should be the end of the new period - if (mod.startsWith(TimeTypeConstants.beforeMod)) { - if (!StringUtility.isNullOrEmpty(start) && !StringUtility.isNullOrEmpty(end) && !mod.endsWith(Constants.LATE_MOD)) { - result[TimeTypeConstants.END] = start; - } - else { - result[TimeTypeConstants.END] = end; - } - return; - } - - // For the 'after' mod - // 1. Cases like "After January". the end of the period should be the start of the new period, not the end - // 2. Cases like "More than 3 days after today", the date point should be the start of the new period - if (mod.startsWith(TimeTypeConstants.afterMod)) { - if (!StringUtility.isNullOrEmpty(start) && !StringUtility.isNullOrEmpty(end) && !mod.endsWith(Constants.EARLY_MOD)) { - result[TimeTypeConstants.START] = end; - } - else { - result[TimeTypeConstants.START] = start; - } - return; - } - if (mod === TimeTypeConstants.sinceMod) { - result[TimeTypeConstants.START] = start; - return; - } - } - - if (StringUtility.isNullOrEmpty(start) || StringUtility.isNullOrEmpty(end)) { - return; - } - - result[TimeTypeConstants.START] = start; - result[TimeTypeConstants.END] = end; - } - - protected getValues(obj: any): any[] { - return Object.keys(obj).map(key => obj[key]); - } - - protected processDoubleTimex(resolutionDic: Map, futureKey: string, pastKey: string, originTimex: string) { - let timexes = originTimex.split(Constants.CompositeTimexDelimiter); - - if (!resolutionDic.has(futureKey) || !resolutionDic.has(pastKey) || timexes.length != 2) - { - return; - } - - let futureResolution: StringMap = resolutionDic.get(futureKey); - let pastResolution: StringMap = resolutionDic.get(pastKey); - futureResolution[Constants.TimexKey] = timexes[0]; - pastResolution[Constants.TimexKey] = timexes[1]; - } - - private HasDoubleTimex(comment: string): boolean { - return comment === Constants.Comment_DoubleTimex; - } - - protected resolveAMPM(valuesMap: Map, keyName: string) { - if (!valuesMap.has(keyName)) { - return; - } - - let resolution: StringMap = valuesMap.get(keyName); - if (!valuesMap.has('timex')) { - return; - } - - let timex = valuesMap.get('timex'); - valuesMap.delete(keyName); - valuesMap.set(keyName + 'Am', resolution); - - let resolutionPm: StringMap = {}; - switch (valuesMap.get('type')) { - case Constants.SYS_DATETIME_TIME: - resolutionPm[TimeTypeConstants.VALUE] = DateTimeFormatUtil.toPm(resolution[TimeTypeConstants.VALUE]); - resolutionPm['timex'] = DateTimeFormatUtil.toPm(timex); - break; - - case Constants.SYS_DATETIME_DATETIME: - let splitValue = resolution[TimeTypeConstants.VALUE].split(' '); - resolutionPm[TimeTypeConstants.VALUE] = `${splitValue[0]} ${DateTimeFormatUtil.toPm(splitValue[1])}`; - resolutionPm['timex'] = DateTimeFormatUtil.allStringToPm(timex); - break; - - case Constants.SYS_DATETIME_TIMEPERIOD: - if (resolution.hasOwnProperty(TimeTypeConstants.START)) { - resolutionPm[TimeTypeConstants.START] = DateTimeFormatUtil.toPm(resolution[TimeTypeConstants.START]); - } - if (resolution.hasOwnProperty(TimeTypeConstants.END)) { - resolutionPm[TimeTypeConstants.END] = DateTimeFormatUtil.toPm(resolution[TimeTypeConstants.END]); - } - resolutionPm['timex'] = DateTimeFormatUtil.allStringToPm(timex); - break; - - case Constants.SYS_DATETIME_DATETIMEPERIOD: - if (resolution.hasOwnProperty(TimeTypeConstants.START)) { - let splitValue = resolution[TimeTypeConstants.START].split(' '); - resolutionPm[TimeTypeConstants.START] = `${splitValue[0]} ${DateTimeFormatUtil.toPm(splitValue[1])}`; - } - - if (resolution.hasOwnProperty(TimeTypeConstants.END)) { - let splitValue = resolution[TimeTypeConstants.END].split(' '); - resolutionPm[TimeTypeConstants.END] = `${splitValue[0]} ${DateTimeFormatUtil.toPm(splitValue[1])}`; - } - - resolutionPm['timex'] = DateTimeFormatUtil.allStringToPm(timex); - break; - } - - valuesMap.set(keyName + 'Pm', resolutionPm); - } -} diff --git a/JavaScript/packages/recognizers-date-time/src/dateTime/baseSet.ts b/JavaScript/packages/recognizers-date-time/src/dateTime/baseSet.ts deleted file mode 100644 index 8be6d41ff2..0000000000 --- a/JavaScript/packages/recognizers-date-time/src/dateTime/baseSet.ts +++ /dev/null @@ -1,345 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { IExtractor, ExtractResult, RegExpUtility, StringUtility } from "@microsoft/recognizers-text"; -import { Constants, TimeTypeConstants } from "./constants"; -import { IDateTimeParser, DateTimeParseResult } from "./parsers"; -import { BaseDurationExtractor, BaseDurationParser } from "./baseDuration"; -import { BaseTimeExtractor, BaseTimeParser } from "./baseTime"; -import { BaseDateExtractor, BaseDateParser } from "./baseDate"; -import { BaseDatePeriodExtractor, BaseDatePeriodParser } from "./baseDatePeriod"; -import { BaseTimePeriodExtractor, BaseTimePeriodParser } from "./baseTimePeriod"; -import { IDateTimeExtractor, BaseDateTimeExtractor, BaseDateTimeParser } from "./baseDateTime"; -import { BaseDateTimePeriodExtractor, BaseDateTimePeriodParser } from "./baseDateTimePeriod"; -import { Token, DateTimeResolutionResult, StringMap } from "./utilities"; - -export interface ISetExtractorConfiguration { - lastRegex: RegExp; - eachPrefixRegex: RegExp; - periodicRegex: RegExp; - eachUnitRegex: RegExp; - eachDayRegex: RegExp; - beforeEachDayRegex: RegExp; - setWeekDayRegex: RegExp; - setEachRegex: RegExp; - durationExtractor: IDateTimeExtractor; - timeExtractor: IDateTimeExtractor; - dateExtractor: IDateTimeExtractor; - dateTimeExtractor: IDateTimeExtractor; - datePeriodExtractor: IDateTimeExtractor; - timePeriodExtractor: IDateTimeExtractor; - dateTimePeriodExtractor: IDateTimeExtractor; -} - -export class BaseSetExtractor implements IDateTimeExtractor { - protected readonly extractorName = Constants.SYS_DATETIME_SET - protected readonly config: ISetExtractorConfiguration; - - constructor(config: ISetExtractorConfiguration) { - this.config = config; - } - - extract(source: string, refDate: Date): ExtractResult[] { - if (!refDate) { - refDate = new Date(); - } - let referenceDate = refDate; - - let tokens: Token[] = new Array() - .concat(this.matchEachUnit(source)) - .concat(this.matchPeriodic(source)) - .concat(this.matchEachDuration(source, referenceDate)) - .concat(this.timeEveryday(source, referenceDate)) - .concat(this.matchEach(this.config.dateExtractor, source, referenceDate)) - .concat(this.matchEach(this.config.timeExtractor, source, referenceDate)) - .concat(this.matchEach(this.config.dateTimeExtractor, source, referenceDate)) - .concat(this.matchEach(this.config.datePeriodExtractor, source, referenceDate)) - .concat(this.matchEach(this.config.timePeriodExtractor, source, referenceDate)) - .concat(this.matchEach(this.config.dateTimePeriodExtractor, source, referenceDate)); - let result = Token.mergeAllTokens(tokens, source, this.extractorName); - return result; - } - - protected matchEachUnit(source: string): Token[] { - let ret = []; - RegExpUtility.getMatches(this.config.eachUnitRegex, source).forEach(match => { - ret.push(new Token(match.index, match.index + match.length)); - }); - return ret; - } - - protected matchPeriodic(source: string): Token[] { - let ret = []; - RegExpUtility.getMatches(this.config.periodicRegex, source).forEach(match => { - ret.push(new Token(match.index, match.index + match.length)); - }); - return ret; - } - - protected matchEachDuration(source: string, refDate: Date): Token[] { - let ret = []; - this.config.durationExtractor.extract(source, refDate).forEach(er => { - if (RegExpUtility.getMatches(this.config.lastRegex, er.text).length > 0) { - return; - } - let beforeStr = source.substr(0, er.start); - let matches = RegExpUtility.getMatches(this.config.eachPrefixRegex, beforeStr); - if (matches && matches.length > 0) { - ret.push(new Token(matches[0].index, er.start + er.length)); - } - }); - return ret; - } - - protected timeEveryday(source: string, refDate: Date): Token[] { - let ret = []; - this.config.timeExtractor.extract(source, refDate).forEach(er => { - let afterStr = source.substr(er.start + er.length); - if (StringUtility.isNullOrWhitespace(afterStr) && this.config.beforeEachDayRegex) { - let beforeStr = source.substr(0, er.start); - let beforeMatches = RegExpUtility.getMatches(this.config.beforeEachDayRegex, beforeStr); - if (beforeMatches && beforeMatches.length > 0) { - ret.push(new Token(beforeMatches[0].index, er.start + er.length)); - } - } - else { - let afterMatches = RegExpUtility.getMatches(this.config.eachDayRegex, afterStr); - if (afterMatches && afterMatches.length > 0) { - ret.push(new Token(er.start, er.start + er.length + afterMatches[0].length)); - } - } - }); - return ret; - } - - private matchEach(extractor: IDateTimeExtractor, source: string, refDate: Date): Token[] { - let ret = []; - RegExpUtility.getMatches(this.config.setEachRegex, source).forEach(match => { - let trimmedSource = source.substr(0, match.index) + source.substr(match.index + match.length); - extractor.extract(trimmedSource, refDate).forEach(er => { - if (er.start <= match.index && (er.start + er.length) > match.index) { - ret.push(new Token(er.start, er.start + match.length + er.length)); - } - }); - }); - RegExpUtility.getMatches(this.config.setWeekDayRegex, source).forEach(match => { - let trimmedSource = source.substr(0, match.index) + match.groups('weekday').value + source.substr(match.index + match.length); - extractor.extract(trimmedSource, refDate).forEach(er => { - if (er.start <= match.index && er.text.includes(match.groups('weekday').value)) { - let length = er.length + 1; - if (!StringUtility.isNullOrEmpty(match.groups('prefix').value)) { - length += match.groups('prefix').value.length; - } - ret.push(new Token(er.start, er.start + length)); - } - }); - }); - return ret; - } -} - -export interface ISetParserConfiguration { - durationExtractor: IDateTimeExtractor; - durationParser: BaseDurationParser; - timeExtractor: IDateTimeExtractor; - timeParser: BaseTimeParser; - dateExtractor: IDateTimeExtractor; - dateParser: BaseDateParser; - dateTimeExtractor: IDateTimeExtractor; - dateTimeParser: BaseDateTimeParser; - datePeriodExtractor: IDateTimeExtractor; - datePeriodParser: BaseDatePeriodParser; - timePeriodExtractor: IDateTimeExtractor; - timePeriodParser: BaseTimePeriodParser; - dateTimePeriodExtractor: IDateTimeExtractor; - dateTimePeriodParser: BaseDateTimePeriodParser; - unitMap: ReadonlyMap; - eachPrefixRegex: RegExp; - periodicRegex: RegExp; - eachUnitRegex: RegExp; - eachDayRegex: RegExp; - setWeekDayRegex: RegExp; - setEachRegex: RegExp; - getMatchedDailyTimex(text: string): { matched: boolean, timex: string }; - getMatchedUnitTimex(text: string): { matched: boolean, timex: string }; -} - -export class BaseSetParser implements IDateTimeParser { - public static readonly ParserName = Constants.SYS_DATETIME_SET; - protected readonly config: ISetParserConfiguration; - - constructor(configuration: ISetParserConfiguration) { - this.config = configuration; - } - - parse(er: ExtractResult, referenceDate?: Date): DateTimeParseResult | null { - if (!referenceDate) { - referenceDate = new Date(); - } - let value = null; - if (er.type === BaseSetParser.ParserName) { - let innerResult = this.parseEachUnit(er.text); - if (!innerResult.success) { - innerResult = this.parseEachDuration(er.text, referenceDate); - } - - if (!innerResult.success) { - innerResult = this.parserTimeEveryday(er.text, referenceDate); - } - - // NOTE: Please do not change the order of following function - // datetimeperiod>dateperiod>timeperiod>datetime>date>time - if (!innerResult.success) { - innerResult = this.parseEach(this.config.dateTimePeriodExtractor, this.config.dateTimePeriodParser, er.text, referenceDate); - } - - if (!innerResult.success) { - innerResult = this.parseEach(this.config.datePeriodExtractor, this.config.datePeriodParser, er.text, referenceDate); - } - - if (!innerResult.success) { - innerResult = this.parseEach(this.config.timePeriodExtractor, this.config.timePeriodParser, er.text, referenceDate); - } - - if (!innerResult.success) { - innerResult = this.parseEach(this.config.dateTimeExtractor, this.config.dateTimeParser, er.text, referenceDate); - } - - if (!innerResult.success) { - innerResult = this.parseEach(this.config.dateExtractor, this.config.dateParser, er.text, referenceDate); - } - - if (!innerResult.success) { - innerResult = this.parseEach(this.config.timeExtractor, this.config.timeParser, er.text, referenceDate); - } - - if (innerResult.success) { - innerResult.futureResolution = {}; - innerResult.futureResolution[TimeTypeConstants.SET] = innerResult.futureValue; - innerResult.pastResolution = {}; - innerResult.pastResolution[TimeTypeConstants.SET] = innerResult.pastValue; - - value = innerResult; - } - } - - let ret = new DateTimeParseResult(er); - ret.value = value, - ret.timexStr = value === null ? "" : value.timex, - ret.resolutionStr = ""; - - return ret; - } - - protected parseEachDuration(text: string, refDate: Date): DateTimeResolutionResult { - let ret = new DateTimeResolutionResult(); - let ers = this.config.durationExtractor.extract(text, refDate); - if (ers.length !== 1 || text.substring(ers[0].start + ers[0].length || 0)) { - return ret; - } - - let beforeStr = text.substring(0, ers[0].start || 0); - let matches = RegExpUtility.getMatches(this.config.eachPrefixRegex, beforeStr); - if (matches.length) { - let pr = this.config.durationParser.parse(ers[0], new Date()); - ret.timex = pr.timexStr; - ret.futureValue = ret.pastValue = "Set: " + pr.timexStr; - ret.success = true; - return ret; - } - - return ret; - } - - protected parseEachUnit(text: string): DateTimeResolutionResult { - let ret = new DateTimeResolutionResult(); - // handle "daily", "weekly" - let matches = RegExpUtility.getMatches(this.config.periodicRegex, text); - if (matches.length) { - let getMatchedDailyTimex = this.config.getMatchedDailyTimex(text); - if (!getMatchedDailyTimex.matched) { - return ret; - } - - ret.timex = getMatchedDailyTimex.timex; - ret.futureValue = ret.pastValue = "Set: " + ret.timex; - ret.success = true; - - return ret; - } - - // handle "each month" - matches = RegExpUtility.getMatches(this.config.eachUnitRegex, text); - if (matches.length && matches[0].length === text.length) { - let sourceUnit = matches[0].groups("unit").value; - if (sourceUnit && this.config.unitMap.has(sourceUnit)) { - let getMatchedUnitTimex = this.config.getMatchedUnitTimex(sourceUnit); - if (!getMatchedUnitTimex.matched) { - return ret; - } - - if (!StringUtility.isNullOrEmpty(matches[0].groups('other').value)) { - getMatchedUnitTimex.timex = getMatchedUnitTimex.timex.replace('1', '2'); - } - - ret.timex = getMatchedUnitTimex.timex; - ret.futureValue = ret.pastValue = "Set: " + ret.timex; - ret.success = true; - return ret; - } - } - - return ret; - } - - protected parserTimeEveryday(text: string, refDate: Date): DateTimeResolutionResult { - let ret = new DateTimeResolutionResult(); - let ers = this.config.timeExtractor.extract(text, refDate); - if (ers.length !== 1) { - return ret; - } - - let afterStr = text.replace(ers[0].text, ""); - let matches = RegExpUtility.getMatches(this.config.eachDayRegex, afterStr); - if (matches.length) { - let pr = this.config.timeParser.parse(ers[0], new Date()); - ret.timex = pr.timexStr; - ret.futureValue = ret.pastValue = "Set: " + ret.timex; - ret.success = true; - return ret; - } - - return ret; - } - - protected parseEach(extractor: IDateTimeExtractor, parser: IDateTimeParser, text: string, refDate: Date): DateTimeResolutionResult { - let ret = new DateTimeResolutionResult(); - let success = false; - let er: ExtractResult[]; - let match = RegExpUtility.getMatches(this.config.setEachRegex, text).pop(); - if (match) { - let trimmedText = text.substr(0, match.index) + text.substr(match.index + match.length); - er = extractor.extract(trimmedText, refDate); - if (er.length === 1 && er[0].length === trimmedText.length) { - success = true; - } - } - match = RegExpUtility.getMatches(this.config.setWeekDayRegex, text).pop(); - if (match) { - let trimmedText = text.substr(0, match.index) + match.groups('weekday').value + text.substr(match.index + match.length); - er = extractor.extract(trimmedText, refDate); - if (er.length === 1 && er[0].length === trimmedText.length) { - success = true; - } - } - if (success) { - let pr = parser.parse(er[0]); - ret.timex = pr.timexStr; - ret.futureValue = `Set: ${pr.timexStr}`; - ret.pastValue = `Set: ${pr.timexStr}`; - ret.success = true; - return ret; - } - return ret; - } -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-date-time/src/dateTime/baseTime.ts b/JavaScript/packages/recognizers-date-time/src/dateTime/baseTime.ts deleted file mode 100644 index d52cf1ff72..0000000000 --- a/JavaScript/packages/recognizers-date-time/src/dateTime/baseTime.ts +++ /dev/null @@ -1,351 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { IExtractor, ExtractResult } from "@microsoft/recognizers-text"; -import { Constants, TimeTypeConstants } from "./constants"; -import { RegExpUtility, Match, StringUtility } from "@microsoft/recognizers-text-number"; -import { Token, DateTimeFormatUtil, DateTimeResolutionResult, IDateTimeUtilityConfiguration, DateUtils, StringMap } from "./utilities"; -import { IDateTimeParser, DateTimeParseResult } from "./parsers"; -import { IDateTimeExtractor } from "./baseDateTime"; - -export interface ITimeExtractorConfiguration { - timeRegexList: RegExp[] - atRegex: RegExp - ishRegex: RegExp -} - -export class BaseTimeExtractor implements IDateTimeExtractor { - private readonly extractorName = Constants.SYS_DATETIME_TIME; // "Time"; - private readonly config: ITimeExtractorConfiguration; - - constructor(config: ITimeExtractorConfiguration) { - this.config = config; - } - - extract(text: string, refDate: Date): ExtractResult[] { - if (!refDate) { - refDate = new Date(); - } - let referenceDate = refDate; - - let tokens: Token[] = new Array() - .concat(this.basicRegexMatch(text)) - .concat(this.atRegexMatch(text)) - .concat(this.specialsRegexMatch(text, referenceDate)); - - let result = Token.mergeAllTokens(tokens, text, this.extractorName); - return result; - } - - basicRegexMatch(text: string): Token[] { - - let ret = []; - - this.config.timeRegexList.forEach(regexp => { - let matches = RegExpUtility.getMatches(regexp, text); - matches.forEach(match => { - - // @TODO Workaround to avoid incorrect partial-only matches. Remove after time regex reviews across languages. - let lth = match.groups("lth").value; - - if (!lth || - (lth.length != match.length && !(match.length == lth.length + 1 && match.value.endsWith(" ")))) - { - ret.push(new Token(match.index, match.index + match.length)); - } - }); - }); - - return ret; - } - - atRegexMatch(text: string): Token[] { - let ret = []; - // handle "at 5", "at seven" - let matches = RegExpUtility.getMatches(this.config.atRegex, text); - matches.forEach(match => { - if (match.index + match.length < text.length && - text.charAt(match.index + match.length) === '%') { - return; - } - ret.push(new Token(match.index, match.index + match.length)); - }); - return ret; - } - - specialsRegexMatch(text: string, refDate: Date): Token[] { - let ret = []; - // handle "ish" - if (this.config.ishRegex !== null) { - let matches = RegExpUtility.getMatches(this.config.ishRegex, text); - matches.forEach(match => { - ret.push(new Token(match.index, match.index + match.length)); - }); - } - return ret; - } -} - -export interface ITimeParserConfiguration { - timeTokenPrefix: string; - atRegex: RegExp - timeRegexes: RegExp[]; - numbers: ReadonlyMap; - utilityConfiguration: IDateTimeUtilityConfiguration; - adjustByPrefix(prefix: string, adjust: { hour: number, min: number, hasMin: boolean }); - adjustBySuffix(suffix: string, adjust: { hour: number, min: number, hasMin: boolean, hasAm: boolean, hasPm: boolean }); -} - -export class BaseTimeParser implements IDateTimeParser { - readonly ParserName = Constants.SYS_DATETIME_TIME; // "Time"; - readonly config: ITimeParserConfiguration; - - constructor(configuration: ITimeParserConfiguration) { - this.config = configuration; - } - - public parse(er: ExtractResult, referenceTime?: Date): DateTimeParseResult | null { - if (!referenceTime) { - referenceTime = new Date(); - } - let value = null; - if (er.type === this.ParserName) { - let innerResult = this.internalParse(er.text, referenceTime); - if (innerResult.success) { - innerResult.futureResolution = {}; - innerResult.futureResolution[TimeTypeConstants.TIME] = DateTimeFormatUtil.formatTime(innerResult.futureValue); - innerResult.pastResolution = {}; - innerResult.pastResolution[TimeTypeConstants.TIME] = DateTimeFormatUtil.formatTime(innerResult.pastValue); - value = innerResult; - } - } - - let ret = new DateTimeParseResult(er); - ret.value = value, - ret.timexStr = value === null ? "" : value.timex, - ret.resolutionStr = ""; - - return ret; - } - - internalParse(text: string, referenceTime: Date): DateTimeResolutionResult { - let innerResult = this.parseBasicRegexMatch(text, referenceTime); - return innerResult; - } - - // parse basic patterns in TimeRegexList - private parseBasicRegexMatch(text: string, referenceTime: Date): DateTimeResolutionResult { - let trimmedText = text.trim().toLowerCase(); - let offset = 0; - - let matches = RegExpUtility.getMatches(this.config.atRegex, trimmedText); - if (matches.length === 0) { - matches = RegExpUtility.getMatches(this.config.atRegex, this.config.timeTokenPrefix + trimmedText); - offset = this.config.timeTokenPrefix.length; - } - - if (matches.length > 0 && matches[0].index === offset && matches[0].length === trimmedText.length) { - return this.match2Time(matches[0], referenceTime); - } - - // parse hour pattern, like "twenty one", "16" - // create a extract result which content the pass-in text - let hour = this.config.numbers.get(text) || Number(text); - if (hour) { - if (hour >= 0 && hour <= 24) { - let ret = new DateTimeResolutionResult(); - - if (hour === 24) { - hour = 0; - } - - if (hour <= 12 && hour !== 0) { - ret.comment = "ampm"; - } - - ret.timex = "T" + DateTimeFormatUtil.toString(hour, 2); - ret.futureValue = ret.pastValue = - DateUtils.safeCreateFromMinValue(referenceTime.getFullYear(), referenceTime.getMonth(), referenceTime.getDate(), hour, 0, 0); - ret.success = true; - return ret; - } - } - - for (let regex of this.config.timeRegexes) { - offset = 0; - matches = RegExpUtility.getMatches(regex, trimmedText); - - if (matches.length && matches[0].index === offset && matches[0].length === trimmedText.length) { - return this.match2Time(matches[0], referenceTime); - } - } - - return new DateTimeResolutionResult(); - } - - private match2Time(match: Match, referenceTime: Date): DateTimeResolutionResult { - let ret = new DateTimeResolutionResult(); - let hour = 0; - let min = 0; - let second = 0; - let day = referenceTime.getDate(); - let month = referenceTime.getMonth(); - let year = referenceTime.getFullYear(); - let hasMin = false; - let hasSec = false; - let hasAm = false; - let hasPm = false; - let hasMid = false; - - let engTimeStr = match.groups('engtime').value; - if (!StringUtility.isNullOrWhitespace(engTimeStr)) { - // get hour - let hourStr = match.groups('hournum').value.toLowerCase(); - hour = this.config.numbers.get(hourStr); - - // get minute - let minStr = match.groups('minnum').value; - let tensStr = match.groups('tens').value; - - if (!StringUtility.isNullOrWhitespace(minStr)) { - min = this.config.numbers.get(minStr); - if (tensStr) { - min += this.config.numbers.get(tensStr); - } - hasMin = true; - } - } - else if (!StringUtility.isNullOrWhitespace(match.groups('mid').value)) { - hasMid = true; - if (!StringUtility.isNullOrWhitespace(match.groups('midnight').value)) { - hour = 0; - min = 0; - second = 0; - } - else if (!StringUtility.isNullOrWhitespace(match.groups('midmorning').value)) { - hour = 10; - min = 0; - second = 0; - } - else if (!StringUtility.isNullOrWhitespace(match.groups('midafternoon').value)) { - hour = 14; - min = 0; - second = 0; - } - else if (!StringUtility.isNullOrWhitespace(match.groups('midday').value)) { - hour = 12; - min = 0; - second = 0; - } - } - else { - // get hour - let hourStr = match.groups('hour').value; - if (StringUtility.isNullOrWhitespace(hourStr)) { - hourStr = match.groups('hournum').value.toLowerCase(); - hour = this.config.numbers.get(hourStr); - if (!hour) { - return ret; - } - } - else { - hour = Number.parseInt(hourStr, 10); - if (!hour) { - hour = this.config.numbers.get(hourStr); - if (!hour) { - return ret; - } - } - } - - // get minute - let minStr = match.groups('min').value.toLowerCase(); - if (StringUtility.isNullOrWhitespace(minStr)) { - minStr = match.groups('minnum').value; - if (!StringUtility.isNullOrWhitespace(minStr)) { - min = this.config.numbers.get(minStr); - hasMin = true; - } - - let tensStr = match.groups('tens').value; - if (!StringUtility.isNullOrWhitespace(tensStr)) { - min += this.config.numbers.get(tensStr); - hasMin = true; - } - } - else { - min = Number.parseInt(minStr, 10); - hasMin = true; - } - - // get second - let secStr = match.groups('sec').value.toLowerCase(); - if (!StringUtility.isNullOrWhitespace(secStr)) { - second = Number.parseInt(secStr, 10); - hasSec = true; - } - } - - // adjust by desc string - let descStr = match.groups('desc').value.toLowerCase(); - if (RegExpUtility.getMatches(this.config.utilityConfiguration.amDescRegex, descStr).length > 0 - || RegExpUtility.getMatches(this.config.utilityConfiguration.amPmDescRegex, descStr).length > 0 - || !StringUtility.isNullOrEmpty(match.groups('iam').value)) { - - if (hour >= 12) { - hour -= 12; - } - - if (RegExpUtility.getMatches(this.config.utilityConfiguration.amPmDescRegex, descStr).length === 0) { - hasAm = true; - } - } - else if (RegExpUtility.getMatches(this.config.utilityConfiguration.pmDescRegex, descStr).length > 0 - || !StringUtility.isNullOrEmpty(match.groups('ipm').value)) { - - if (hour < 12) { - hour += 12; - } - - hasPm = true; - } - - // adjust min by prefix - let timePrefix = match.groups('prefix').value.toLowerCase(); - if (!StringUtility.isNullOrWhitespace(timePrefix)) { - let adjust = { hour: hour, min: min, hasMin: hasMin }; - this.config.adjustByPrefix(timePrefix, adjust); - hour = adjust.hour; min = adjust.min; hasMin = adjust.hasMin; - } - - // adjust hour by suffix - let timeSuffix = match.groups('suffix').value.toLowerCase(); - if (!StringUtility.isNullOrWhitespace(timeSuffix)) { - let adjust = { hour: hour, min: min, hasMin: hasMin, hasAm: hasAm, hasPm: hasPm }; - this.config.adjustBySuffix(timeSuffix, adjust); - hour = adjust.hour; min = adjust.min; hasMin = adjust.hasMin; hasAm = adjust.hasAm; hasPm = adjust.hasPm; - } - - if (hour === 24) { - hour = 0; - } - - ret.timex = "T" + DateTimeFormatUtil.toString(hour, 2); - if (hasMin) { - ret.timex += ":" + DateTimeFormatUtil.toString(min, 2); - } - - if (hasSec) { - ret.timex += ":" + DateTimeFormatUtil.toString(second, 2); - } - - if (hour <= 12 && !hasPm && !hasAm && !hasMid) { - ret.comment = "ampm"; - } - - ret.futureValue = ret.pastValue = new Date(year, month, day, hour, min, second); - ret.success = true; - - return ret; - } -} diff --git a/JavaScript/packages/recognizers-date-time/src/dateTime/baseTimePeriod.ts b/JavaScript/packages/recognizers-date-time/src/dateTime/baseTimePeriod.ts deleted file mode 100644 index 8820255501..0000000000 --- a/JavaScript/packages/recognizers-date-time/src/dateTime/baseTimePeriod.ts +++ /dev/null @@ -1,777 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { IExtractor, ExtractResult, RegExpUtility, StringUtility } from "@microsoft/recognizers-text"; -import { Constants, TimeTypeConstants } from "./constants"; -import { Token, DateTimeFormatUtil, DateTimeResolutionResult, IDateTimeUtilityConfiguration, DateUtils, StringMap } from "./utilities"; -import { IDateTimeParser, DateTimeParseResult } from "./parsers"; -import { BaseTimeExtractor, BaseTimeParser } from "./baseTime"; -import { IDateTimeExtractor } from "./baseDateTime"; - -export interface ITimePeriodExtractorConfiguration { - simpleCasesRegex: RegExp[]; - tillRegex: RegExp; - timeOfDayRegex: RegExp; - generalEndingRegex: RegExp; - singleTimeExtractor: IDateTimeExtractor; - integerExtractor: IExtractor; - getFromTokenIndex(text: string): { matched: boolean, index: number }; - hasConnectorToken(text: string): boolean; - getBetweenTokenIndex(text: string): { matched: boolean, index: number }; -} - -export class BaseTimePeriodExtractor implements IDateTimeExtractor { - readonly extractorName = Constants.SYS_DATETIME_TIMEPERIOD; // "TimePeriod"; - readonly config: ITimePeriodExtractorConfiguration; - - constructor(config: ITimePeriodExtractorConfiguration) { - this.config = config; - } - - extract(source: string, refDate: Date): ExtractResult[] { - if (!refDate) { - refDate = new Date(); - } - let referenceDate = refDate; - - let tokens: Token[] = new Array() - .concat(this.matchSimpleCases(source)) - .concat(this.mergeTwoTimePoints(source, referenceDate)) - .concat(this.matchNight(source)); - let result = Token.mergeAllTokens(tokens, source, this.extractorName); - return result; - } - - private matchSimpleCases(text: string): Token[] { - let ret = []; - this.config.simpleCasesRegex.forEach(regex => { - let matches = RegExpUtility.getMatches(regex, text); - matches.forEach(match => { - // is there "pm" or "am" ? - let pmStr = match.groups("pm").value; - let amStr = match.groups("am").value; - let descStr = match.groups("desc").value; - // check "pm", "am" - if (pmStr || amStr || descStr) { - ret.push(new Token(match.index, match.index + match.length)); - } - }); - }); - return ret; - } - - private mergeTwoTimePoints(text: string, refDate: Date): Token[] { - let ret = []; - let ers = this.config.singleTimeExtractor.extract(text, refDate); - let numErs = this.config.integerExtractor.extract(text); - - // Check if it is an ending number - if (numErs.length > 0) { - let timeNumbers: ExtractResult[] = []; - - // check if it is a ending number - let endingNumber = false; - let num = numErs[numErs.length - 1]; - if (num.start + num.length === text.length) { - endingNumber = true; - } - else { - let afterStr = text.substr(num.start + num.length); - let endingMatch = afterStr.match(this.config.generalEndingRegex); - if (endingMatch) { - endingNumber = true; - } - } - - if (endingNumber) { - timeNumbers.push(num); - } - - let i = 0; - let j = 0; - while (i < numErs.length) { - // find subsequent time point - let numEndPoint = numErs[i].start + numErs[i].length; - while (j < ers.length && ers[j].start <= numEndPoint) { - j++; - } - - if (j >= ers.length) { - break; - } - - // check connector string - let midStr = text.substr(numEndPoint, ers[j].start - numEndPoint); - let match = midStr.match(this.config.tillRegex); - if (match && match[0].length === midStr.trim().length) { - timeNumbers.push(numErs[i]); - } - i++; - } - - // check overlap - for (let timeNum of timeNumbers) { - let overlap = false; - for (let er of ers) { - if (er.start <= timeNum.start && er.start + er.length >= timeNum.start) { - overlap = true; - } - } - - if (!overlap) { - ers.push(timeNum); - } - } - - ers = ers.sort((x, y) => (x.start - y.start)); - } - - // merge "{TimePoint} to {TimePoint}", "between {TimePoint} and {TimePoint}" - let idx = 0; - while (idx < ers.length - 1) { - let middleBegin = ers[idx].start + ers[idx].length || 0; - let middleEnd = ers[idx + 1].start || 0; - - let middleStr = text.substring(middleBegin, middleEnd).trim().toLowerCase(); - let matches = RegExpUtility.getMatches(this.config.tillRegex, middleStr); - // handle "{TimePoint} to {TimePoint}" - if (matches.length > 0 && matches[0].index === 0 && matches[0].length === middleStr.length) { - let periodBegin = ers[idx].start || 0; - let periodEnd = (ers[idx + 1].start || 0) + (ers[idx + 1].length || 0); - - // handle "from" - let beforeStr = text.substring(0, periodBegin).trim().toLowerCase(); - let fromIndex = this.config.getFromTokenIndex(beforeStr); - if (fromIndex.matched) { - periodBegin = fromIndex.index; - } - - // handle "between" - let betweenIndex = this.config.getBetweenTokenIndex(beforeStr); - if (betweenIndex.matched) { - periodBegin = betweenIndex.index; - } - - ret.push(new Token(periodBegin, periodEnd)); - idx += 2; - continue; - } - // handle "between {TimePoint} and {TimePoint}" - if (this.config.hasConnectorToken(middleStr)) { - let periodBegin = ers[idx].start || 0; - let periodEnd = (ers[idx + 1].start || 0) + (ers[idx + 1].length || 0); - - // handle "between" - let beforeStr = text.substring(0, periodBegin).trim().toLowerCase(); - let betweenIndex = this.config.getBetweenTokenIndex(beforeStr); - if (betweenIndex.matched) { - periodBegin = betweenIndex.index; - ret.push(new Token(periodBegin, periodEnd)); - idx += 2; - continue; - } - } - - idx++; - } - - return ret; - } - - private matchNight(source: string): Token[] { - let ret = []; - let matches = RegExpUtility.getMatches(this.config.timeOfDayRegex, source); - matches.forEach(match => { - ret.push(new Token(match.index, match.index + match.length)); - }); - return ret; - } -} - -export interface ITimePeriodParserConfiguration { - timeExtractor: IDateTimeExtractor; - timeParser: BaseTimeParser; - integerExtractor: IExtractor; - pureNumberFromToRegex: RegExp; - pureNumberBetweenAndRegex: RegExp; - timeOfDayRegex: RegExp; - tillRegex: RegExp; - numbers: ReadonlyMap; - utilityConfiguration: IDateTimeUtilityConfiguration; - specificTimeFromToRegex: RegExp; - specificTimeBetweenAndRegex: RegExp; - getMatchedTimexRange(text: string): { - matched: boolean, timex: string, beginHour: number, endHour: number, endMin: number - }; -} - -export class BaseTimePeriodParser implements IDateTimeParser { - public static readonly ParserName = Constants.SYS_DATETIME_TIMEPERIOD; // "TimePeriod"; - protected readonly config: ITimePeriodParserConfiguration; - - constructor(configuration: ITimePeriodParserConfiguration) { - this.config = configuration; - } - - public parse(er: ExtractResult, refTime?: Date): DateTimeParseResult { - let referenceTime = refTime || new Date(); - let value = null; - if (er.type === BaseTimePeriodParser.ParserName) { - let innerResult = this.parseSimpleCases(er.text, referenceTime); - if (!innerResult.success) { - innerResult = this.mergeTwoTimePoints(er.text, referenceTime); - } - if (!innerResult.success) { - innerResult = this.parseTimeOfDay(er.text, referenceTime); - } - if (innerResult.success) { - innerResult.futureResolution = {}; - innerResult.futureResolution[TimeTypeConstants.START_TIME] = DateTimeFormatUtil.formatTime(innerResult.futureValue.item1); - innerResult.futureResolution[TimeTypeConstants.END_TIME] = DateTimeFormatUtil.formatTime(innerResult.futureValue.item2); - innerResult.pastResolution = {}; - innerResult.pastResolution[TimeTypeConstants.START_TIME] = DateTimeFormatUtil.formatTime(innerResult.pastValue.item1); - innerResult.pastResolution[TimeTypeConstants.END_TIME] = DateTimeFormatUtil.formatTime(innerResult.pastValue.item2); - value = innerResult; - } - } - - let ret = new DateTimeParseResult(er); - ret.value = value; - ret.timexStr = value === null ? "" : value.timex; - ret.resolutionStr = ""; - - return ret; - } - - private parseSimpleCases(source: string, reference: Date): DateTimeResolutionResult { - // Cases like "from 3 to 5pm" or "between 4 and 6am", time point is pure number without colon - let result = this.parsePureNumCases(source, reference); - - if (!result.success) { - // Cases like "from 3:30 to 5" or "between 3:30am to 6pm", at least one of the time point contains colon - result = this.parseSpecificTimeCases(source, reference); - } - - return result; - } - - private parsePureNumCases(text: string, referenceTime: Date): DateTimeResolutionResult { - let ret = new DateTimeResolutionResult(); - let year = referenceTime.getFullYear(); - let month = referenceTime.getMonth(); - let day = referenceTime.getDate(); - let trimmedText = text.trim().toLowerCase(); - - let matches = RegExpUtility.getMatches(this.config.pureNumberFromToRegex, trimmedText); - if (!matches.length) { - matches = RegExpUtility.getMatches(this.config.pureNumberBetweenAndRegex, trimmedText); - } - - if (matches.length && matches[0].index === 0) { - // this "from .. to .." pattern is valid if followed by a Date OR "pm" - let isValid = false; - - // get hours - let hourGroup = matches[0].groups('hour'); - let hourStr = hourGroup.captures[0]; - let afterHourIndex = hourGroup.index + hourGroup.length; - - // hard to integrate this part into the regex - if (afterHourIndex === trimmedText.length || !trimmedText.substr(afterHourIndex).trim().startsWith(':')) { - let beginHour = this.config.numbers.get(hourStr); - if (!beginHour) { - beginHour = Number.parseInt(hourStr, 10); - } - - hourStr = hourGroup.captures[1]; - afterHourIndex = trimmedText.indexOf(hourStr, hourGroup.index + 1) + hourStr.length; - - if (afterHourIndex === trimmedText.length || !trimmedText.substr(afterHourIndex).trim().startsWith(':')) { - let endHour = this.config.numbers.get(hourStr); - if (!endHour) { - endHour = Number.parseInt(hourStr, 10); - } - - // parse "pm" - let leftDesc = matches[0].groups("leftDesc").value; - let rightDesc = matches[0].groups("rightDesc").value; - let pmStr = matches[0].groups("pm").value; - let amStr = matches[0].groups("am").value; - - // The "ampm" only occurs in time, don't have to consider it here - if (StringUtility.isNullOrWhitespace(leftDesc)) { - let rightAmValid = !StringUtility.isNullOrEmpty(rightDesc) && - RegExpUtility.getMatches(this.config.utilityConfiguration.amDescRegex, rightDesc.toLowerCase()).length; - let rightPmValid = !StringUtility.isNullOrEmpty(rightDesc) && - RegExpUtility.getMatches(this.config.utilityConfiguration.pmDescRegex, rightDesc.toLowerCase()).length; - if (!StringUtility.isNullOrEmpty(amStr) || rightAmValid) { - - if (endHour >= 12) { - endHour -= 12; - } - - if (beginHour >= 12 && beginHour - 12 < endHour) { - beginHour -= 12; - } - - // Resolve case like "11 to 3am" - if (beginHour < 12 && beginHour > endHour) { - beginHour += 12; - } - - isValid = true; - } - else if (!StringUtility.isNullOrEmpty(pmStr) || rightPmValid) { - - if (endHour < 12) { - endHour += 12; - } - - // Resolve case like "11 to 3pm" - if (beginHour + 12 < endHour) { - beginHour += 12; - } - - isValid = true; - } - } - - if (isValid) { - let beginStr = "T" + DateTimeFormatUtil.toString(beginHour, 2); - let endStr = "T" + DateTimeFormatUtil.toString(endHour, 2); - - if (beginHour >= endHour) { - endHour += 24; - } - - ret.timex = `(${beginStr},${endStr},PT${endHour - beginHour}H)`; - - ret.futureValue = ret.pastValue = { - item1: new Date(year, month, day, beginHour, 0, 0), - item2: new Date(year, month, day, endHour, 0, 0) - }; - - ret.success = true; - - return ret; - } - } - } - } - return ret; - } - - private parseSpecificTimeCases(source: string, reference: Date): DateTimeResolutionResult { - let result = new DateTimeResolutionResult(); - let year = reference.getFullYear(); - let month = reference.getMonth(); - let day = reference.getDate(); - let trimmedText = source.trim().toLowerCase(); - - // Handle cases like "from 4:30 to 5" - let match = RegExpUtility.getMatches(this.config.specificTimeFromToRegex, source).pop(); - if (!match) { - // Handle cases like "between 5:10 and 7" - match = RegExpUtility.getMatches(this.config.specificTimeBetweenAndRegex, source).pop(); - } - - if (match && match.index === 0 && match.index + match.length === trimmedText.length) { - // Cases like "half past seven" are not handled here - if (match.groups('prefix').value !== '') { - return result; - } - - // Cases like "4" is different with "4:00" as the Timex is different "T04H" vs "T04H00M" - // Uses this invalidFlag to differentiate - let beginHour: number; - let invalidFlag = -1; - let beginMinute = invalidFlag; - let beginSecond = invalidFlag; - let endHour: number; - let endMinute = invalidFlag; - let endSecond = invalidFlag; - - // Get time1 and time2 - let hourGroup = match.groups('hour'); - let hourStr = hourGroup.captures[0]; - - if (this.config.numbers.has(hourStr)) { - beginHour = this.config.numbers.get(hourStr); - } - else { - beginHour = parseInt(hourStr, 10); - } - - hourStr = hourGroup.captures[1]; - - if (this.config.numbers.has(hourStr)) { - endHour = this.config.numbers.get(hourStr); - } - else { - endHour = parseInt(hourStr, 10); - } - - let time1StartIndex = match.groups('time1').index; - let time1EndIndex = time1StartIndex + match.groups('time1').length; - let time2StartIndex = match.groups('time2').index; - let time2EndIndex = time2StartIndex + match.groups('time2').length; - - // Get beginMinute (if exists) and endMinute (if exists) - let lastGroupIndex = 0; - for (let i = 0; i < match.groups('min').captures.length; i++) { - let minuteCapture = match.groups('min').captures[i]; - - let minuteCaptureIndex = source.indexOf(minuteCapture, lastGroupIndex); - - if (minuteCaptureIndex >= time1StartIndex && minuteCaptureIndex + minuteCapture.length <= time1EndIndex) { - beginMinute = parseInt(minuteCapture, 10); - } - else if (minuteCaptureIndex >= time2StartIndex && minuteCaptureIndex + minuteCapture.length <= time2EndIndex) { - endMinute = parseInt(minuteCapture, 10); - } - lastGroupIndex = minuteCaptureIndex + 1; - } - - lastGroupIndex = 0; - - // Get beginSecond (if exists) and endSecond (if exists) - for (let i = 0; i < match.groups('sec').captures.length; i++) { - let secondCapture = match.groups('sec').captures[i]; - - let secondCaptureIndex = source.indexOf(secondCapture, lastGroupIndex); - - if (secondCaptureIndex >= time1StartIndex && secondCaptureIndex + secondCapture.length <= time1EndIndex) { - beginSecond = parseInt(secondCapture, 10); - } - else if (secondCaptureIndex >= time2StartIndex && secondCaptureIndex + secondCapture.length <= time2EndIndex) { - endSecond = parseInt(secondCapture, 10); - } - lastGroupIndex = secondCaptureIndex + 1; - } - - lastGroupIndex = 0; - // Desc here means descriptions like "am / pm / o'clock" - // Get leftDesc (if exists) and rightDesc (if exists) - let leftDesc = match.groups('leftDesc').value; - let rightDesc = match.groups('rightDesc').value; - - for (let i = 0; i < match.groups('desc').captures.length; i++) { - let descCapture = match.groups('desc').captures[i]; - - let descCaptureIndex = source.indexOf(descCapture, lastGroupIndex); - - if (descCaptureIndex >= time1StartIndex && descCaptureIndex + descCapture.length <= time1EndIndex && StringUtility.isNullOrEmpty(leftDesc)) { - leftDesc = descCapture; - } - else if (descCaptureIndex >= time2StartIndex && descCaptureIndex + descCapture.length <= time2EndIndex && StringUtility.isNullOrEmpty(rightDesc)) { - rightDesc = descCapture; - } - - lastGroupIndex = descCaptureIndex + 1; - } - - let beginDateTime = DateUtils.safeCreateFromMinValue(year, month, day, beginHour, beginMinute >= 0 ? beginMinute : 0, beginSecond >= 0 ? beginSecond : 0); - let endDateTime = DateUtils.safeCreateFromMinValue(year, month, day, endHour, endMinute >= 0 ? endMinute : 0, endSecond >= 0 ? endSecond : 0); - - let hasLeftAm = !StringUtility.isNullOrEmpty(leftDesc) && leftDesc.toLowerCase().startsWith('a'); - let hasLeftPm = !StringUtility.isNullOrEmpty(leftDesc) && leftDesc.toLowerCase().startsWith('p'); - let hasRightAm = !StringUtility.isNullOrEmpty(rightDesc) && rightDesc.toLowerCase().startsWith('a'); - let hasRightPm = !StringUtility.isNullOrEmpty(rightDesc) && rightDesc.toLowerCase().startsWith('p'); - let hasLeft = hasLeftAm || hasLeftPm; - let hasRight = hasRightAm || hasRightPm; - - // Both timepoint has description like 'am' or 'pm' - if (hasLeft && hasRight) { - if (hasLeftAm) { - if (beginHour >= 12) { - beginDateTime = DateUtils.addHours(beginDateTime, -12); - } - } - else if (hasLeftPm) { - if (beginHour < 12) { - beginDateTime = DateUtils.addHours(beginDateTime, 12); - } - } - - if (hasRightAm) { - if (endHour >= 12) { - endDateTime = DateUtils.addHours(endDateTime, -12); - } - } - else if (hasRightPm) { - if (endHour < 12) { - endDateTime = DateUtils.addHours(endDateTime, 12); - } - } - } - else if (hasLeft || hasRight) { - if (hasLeftAm) { - if (beginHour >= 12) { - beginDateTime = DateUtils.addHours(beginDateTime, -12); - } - - if (endHour < 12) { - if (endDateTime < beginDateTime) { - endDateTime = DateUtils.addHours(endDateTime, 12); - } - } - } - else if (hasLeftPm) { - if (beginHour < 12) { - beginDateTime = DateUtils.addHours(beginDateTime, 12); - } - - if (endHour < 12) { - if (endDateTime.getTime() < beginDateTime.getTime()) { - let span = DateUtils.totalHoursFloor(beginDateTime, endDateTime); - if (span >= 12) { - endDateTime = DateUtils.addHours(endDateTime, 24); - } - else { - endDateTime = DateUtils.addHours(endDateTime, 12); - } - } - } - } - - if (hasRightAm) { - if (endHour >= 12) { - endDateTime = DateUtils.addHours(endDateTime, -12); - } - - if (beginHour < 12) { - if (endDateTime.getTime() < beginDateTime.getTime()) { - beginDateTime = DateUtils.addHours(beginDateTime, -12); - } - } - } - else if (hasRightPm) { - if (endHour < 12) { - endDateTime = DateUtils.addHours(endDateTime, 12); - } - - if (beginHour < 12) { - if (endDateTime.getTime() < beginDateTime.getTime()) { - beginDateTime = DateUtils.addHours(beginDateTime, -12); - } - else { - let span = DateUtils.totalHoursFloor(endDateTime, beginDateTime); - if (span > 12) { - beginDateTime = DateUtils.addHours(beginDateTime, 12); - } - } - } - } - } - else if (!hasLeft && !hasRight && beginHour <= 12 && endHour <= 12) { - if (beginHour > endHour) { - if (beginHour === 12) { - beginDateTime = DateUtils.addHours(beginDateTime, -12); - } - else { - endDateTime = DateUtils.addHours(endDateTime, 12); - } - } - result.comment = Constants.CommentAmPm; - } - - if (endDateTime.getTime() < beginDateTime.getTime()) { - endDateTime = DateUtils.addHours(endDateTime, 24); - } - - let beginStr = DateTimeFormatUtil.shortTime(beginDateTime.getHours(), beginMinute, beginSecond); - let endStr = DateTimeFormatUtil.shortTime(endDateTime.getHours(), endMinute, endSecond); - - result.success = true; - result.timex = `(${beginStr},${endStr},${DateTimeFormatUtil.luisTimeSpan(endDateTime, beginDateTime)})`; - - result.futureValue = result.pastValue = { item1: beginDateTime, item2: endDateTime }; - - result.subDateTimeEntities = []; - - // In SplitDateAndTime mode, time points will be get from these SubDateTimeEntities - // Cases like "from 4 to 5pm", "4" should not be treated as SubDateTimeEntity - if (hasLeft || beginMinute !== invalidFlag || beginSecond !== invalidFlag) { - let er = { - start: time1StartIndex, - length: time1EndIndex - time1StartIndex, - text: source.substring(time1StartIndex, time1EndIndex), - type: Constants.SYS_DATETIME_TIME - } as ExtractResult; - let pr = this.config.timeParser.parse(er, reference); - result.subDateTimeEntities.push(pr); - } - - // Cases like "from 4am to 5", "5" should not be treated as SubDateTimeEntity - if (hasRight || endMinute !== invalidFlag || endSecond !== invalidFlag) { - let er = { - start: time2StartIndex, - length: time2EndIndex - time2StartIndex, - text: source.substring(time2StartIndex, time2EndIndex), - type: Constants.SYS_DATETIME_TIME - } as ExtractResult; - let pr = this.config.timeParser.parse(er, reference); - result.subDateTimeEntities.push(pr); - } - } - return result; - } - - private mergeTwoTimePoints(text: string, referenceTime: Date): DateTimeResolutionResult { - let ret = new DateTimeResolutionResult(); - let ers = this.config.timeExtractor.extract(text, referenceTime); - let pr1: DateTimeParseResult = null; - let pr2: DateTimeParseResult = null; - - let validTimeNumber = false; - - if (ers.length !== 2) { - if (ers.length === 1) { - let numErs = this.config.integerExtractor.extract(text); - - for (let num of numErs) { - let midStrBegin = 0; - let midStrEnd = 0; - // ending number - if (num.start > ers[0].start + ers[0].length) { - midStrBegin = ers[0].start + ers[0].length; - midStrEnd = num.start - midStrBegin; - } - else if (num.start + num.length < ers[0].start) { - midStrBegin = num.start + num.length; - midStrEnd = ers[0].start - midStrBegin; - } - - // check if the middle string between the time point and the valid number is a connect string. - let middleStr = text.substr(midStrBegin, midStrEnd); - let tillMatch = middleStr.match(this.config.tillRegex); - if (tillMatch) { - num.type = Constants.SYS_DATETIME_TIME; - ers.push(num); - validTimeNumber = true; - break; - } - } - - ers = ers.sort((x, y) => (x.start - y.start)); - } - - if (!validTimeNumber) { - return ret; - } - } - - if (ers.length !== 2) { - return ret; - } - - pr1 = this.config.timeParser.parse(ers[0], referenceTime); - pr2 = this.config.timeParser.parse(ers[1], referenceTime); - - if (pr1.value === null || pr2.value === null) { - return ret; - } - - let ampmStr1 = pr1.value.comment; - let ampmStr2 = pr2.value.comment; - let beginTime: Date = pr1.value.futureValue; - let endTime: Date = pr2.value.futureValue; - - if (!StringUtility.isNullOrEmpty(ampmStr2) && ampmStr2.endsWith("ampm") - && endTime <= beginTime && DateUtils.addHours(endTime, 12) > beginTime) { - endTime = DateUtils.addHours(endTime, 12); - pr2.value.futureValue = endTime; - pr2.timexStr = `T${endTime.getHours()}`; - if (endTime.getMinutes() > 0) { - pr2.timexStr = `${pr2.timexStr}:${endTime.getMinutes()}`; - } - } - - if (!StringUtility.isNullOrEmpty(ampmStr1) && ampmStr1.endsWith("ampm") - && endTime > DateUtils.addHours(beginTime, 12)) { - beginTime = DateUtils.addHours(beginTime, 12); - pr1.value.futureValue = beginTime; - pr1.timexStr = `T${beginTime.getHours()}`; - if (beginTime.getMinutes() > 0) { - pr1.timexStr = `${pr1.timexStr}:${beginTime.getMinutes()}`; - } - } - - if (endTime < beginTime) { - endTime = DateUtils.addDays(endTime, 1); - } - - let hours = DateUtils.totalHoursFloor(endTime, beginTime); - let minutes = DateUtils.totalMinutesFloor(endTime, beginTime) % 60; - ret.timex = `(${pr1.timexStr},${pr2.timexStr},PT` + - (hours > 0 ? `${hours}H` : '') + - (minutes > 0 ? `${minutes}M` : '') + - ')'; - ret.futureValue = ret.pastValue = { item1: beginTime, item2: endTime }; - ret.success = true; - - if (ampmStr1 && ampmStr1.endsWith("ampm") && ampmStr2 && ampmStr2.endsWith("ampm")) { - ret.comment = "ampm"; - } - - ret.subDateTimeEntities = [pr1, pr2]; - return ret; - } - - // parse "morning", "afternoon", "night" - private parseTimeOfDay(text: string, referenceTime: Date): DateTimeResolutionResult { - let day = referenceTime.getDate(); - let month = referenceTime.getMonth(); - let year = referenceTime.getFullYear(); - let ret = new DateTimeResolutionResult(); - - // extract early/late prefix from text - let matches = RegExpUtility.getMatches(this.config.timeOfDayRegex, text); - let hasEarly = false; - let hasLate = false; - if (matches.length) { - if (!StringUtility.isNullOrEmpty(matches[0].groups("early").value)) { - let early = matches[0].groups("early").value; - text = text.replace(early, ""); - hasEarly = true; - ret.comment = "early"; - ret.mod = Constants.EARLY_MOD; - } - if (!hasEarly && !StringUtility.isNullOrEmpty(matches[0].groups("late").value)) { - let late = matches[0].groups("late").value; - text = text.replace(late, ""); - hasLate = true; - ret.comment = "late"; - ret.mod = Constants.LATE_MOD; - } - } - - let timexRange = this.config.getMatchedTimexRange(text); - if (!timexRange.matched) { - return new DateTimeResolutionResult(); - } - - // modify time period if "early" or "late" is existed - if (hasEarly) { - timexRange.endHour = timexRange.beginHour + 2; - // handling case: night end with 23:59 - if (timexRange.endMin === 59) { - timexRange.endMin = 0; - } - } - else if (hasLate) { - timexRange.beginHour = timexRange.beginHour + 2; - } - - ret.timex = timexRange.timex; - - ret.futureValue = ret.pastValue = { - item1: new Date(year, month, day, timexRange.beginHour, 0, 0), - item2: new Date(year, month, day, timexRange.endHour, timexRange.endMin, timexRange.endMin) - }; - - ret.success = true; - - return ret; - } -} diff --git a/JavaScript/packages/recognizers-date-time/src/dateTime/chinese/baseDateTime.ts b/JavaScript/packages/recognizers-date-time/src/dateTime/chinese/baseDateTime.ts deleted file mode 100644 index 80989d6860..0000000000 --- a/JavaScript/packages/recognizers-date-time/src/dateTime/chinese/baseDateTime.ts +++ /dev/null @@ -1,150 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { IExtractor, ExtractResult } from "@microsoft/recognizers-text"; -import { StringUtility, Match, RegExpUtility } from "@microsoft/recognizers-text-number"; -import { IDateTimeExtractor } from "../baseDateTime"; -import { Constants, TimeTypeConstants } from "../constants"; -import { Token } from "../utilities"; - -export interface DateTimeExtra { - dataType: T; - namedEntity(key: string): { value: string, index: number, length: number, captures: string[] } -} - -export class TimeResult { - hour: number; - minute: number; - second: number; - lowBound: number; - - constructor(hour: number, minute: number, second: number, lowBound?: number) { - this.hour = hour; - this.minute = minute; - this.second = second; - this.lowBound = lowBound ? lowBound : -1; - } -} - -export abstract class BaseDateTimeExtractor implements IDateTimeExtractor { - protected abstract readonly extractorName: string; - private readonly regexesDictionary: Map; - - constructor(regexesDictionary: Map) { - this.regexesDictionary = regexesDictionary; - } - - extract(source: string, refDate: Date): ExtractResult[] { - if (!refDate) { - refDate = new Date(); - } - let referenceDate = refDate; - - let results = new Array(); - if (StringUtility.isNullOrEmpty(source)) { - return results; - } - - let matchSource = new Map(); - let matched = new Array(source.length); - for (let i = 0; i < source.length; i++) { - matched[i] = false; - } - - let collections: { matches: Match[], value: T }[] = []; - this.regexesDictionary.forEach((value, regex) => { - let matches = RegExpUtility.getMatches(regex, source); - if (matches.length > 0) { - collections.push({ matches: matches, value: value }); - } - }); - - collections.forEach(collection => { - collection.matches.forEach(m => { - for (let j = 0; j < m.length; j++) { - matched[m.index + j] = true; - } - - // Keep Source Data for extra information - matchSource.set(m, collection.value); - }); - }); - - let last = -1; - for (let i = 0; i < source.length; i++) { - if (matched[i]) { - if (i + 1 === source.length || !matched[i + 1]) { - let start = last + 1; - let length = i - last; - let substr = source.substring(start, start + length).trim(); - let srcMatch = Array.from(matchSource.keys()).find(m => m.index === start && m.length === length); - if (srcMatch) { - results.push({ - start: start, - length: length, - text: substr, - type: this.extractorName, - data: matchSource.has(srcMatch) - ? { dataType: matchSource.get(srcMatch), namedEntity: (key: string) => srcMatch.groups(key) } as DateTimeExtra - : null - }); - } - } - } - else { - last = i; - } - } - - return results; - } -} - -export class TimeResolutionUtils { - static addDescription(lowBoundMap: ReadonlyMap, timeResult: TimeResult, description: string) { - description = TimeResolutionUtils.normalizeDesc(description); - if (lowBoundMap.has(description) && timeResult.hour < lowBoundMap.get(description)) { - timeResult.hour += 12; - timeResult.lowBound = lowBoundMap.get(description); - } - else { - timeResult.lowBound = 0; - } - } - - static normalizeDesc(description: string): string { - description = description.replace(/\s/g, ''); - description = description.replace(/\./g, ''); - return description; - } - - static matchToValue(onlyDigitMatch: RegExp, numbersMap: ReadonlyMap, source: string): number { - if (StringUtility.isNullOrEmpty(source)) { - return -1; - } - - if (RegExpUtility.isMatch(onlyDigitMatch, source)) { - return Number.parseInt(source); - } - - if (source.length === 1) { - return numbersMap.get(source); - } - - let value = 1; - for (let index = 0; index < source.length; index++) { - let char = source.charAt(index); - if (char === '十') { - value *= 10; - } - else if (index === 0) { - value *= numbersMap.get(char); - } - else { - value += numbersMap.get(char); - } - } - - return value; - } -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-date-time/src/dateTime/chinese/dateConfiguration.ts b/JavaScript/packages/recognizers-date-time/src/dateTime/chinese/dateConfiguration.ts deleted file mode 100644 index 8f7906e5a0..0000000000 --- a/JavaScript/packages/recognizers-date-time/src/dateTime/chinese/dateConfiguration.ts +++ /dev/null @@ -1,693 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { IExtractor, ExtractResult, StringUtility, Match, RegExpUtility, MetaData } from "@microsoft/recognizers-text"; -import { ChineseIntegerExtractor, AgnosticNumberParserFactory, ChineseNumberParserConfiguration, AgnosticNumberParserType, BaseNumberParser, BaseNumberExtractor } from "@microsoft/recognizers-text-number"; -import { Constants as NumberConstants } from "@microsoft/recognizers-text-number"; -import { IDateExtractorConfiguration, IDateParserConfiguration, BaseDateExtractor, BaseDateParser } from "../baseDate"; -import { BaseDurationExtractor, BaseDurationParser } from "../baseDuration"; -import { Constants, TimeTypeConstants } from "../constants"; -import { ChineseDurationExtractor } from "./durationConfiguration"; -import { Token, DateTimeFormatUtil, DateUtils, DateTimeResolutionResult, IDateTimeUtilityConfiguration, StringMap } from "../utilities"; -import { ChineseDateTime } from "../../resources/chineseDateTime"; -import { IDateTimeParser, DateTimeParseResult } from "../parsers"; - -class ChineseDateExtractorConfiguration implements IDateExtractorConfiguration { - readonly dateRegexList: RegExp[]; - readonly implicitDateList: RegExp[]; - readonly monthEnd: RegExp; - readonly ofMonth: RegExp; - readonly dateUnitRegex: RegExp; - readonly forTheRegex: RegExp; - readonly weekDayAndDayOfMonthRegex: RegExp; - readonly relativeMonthRegex: RegExp; - readonly strictRelativeRegex: RegExp; - readonly weekDayRegex: RegExp; - readonly dayOfWeek: ReadonlyMap; - readonly ordinalExtractor: BaseNumberExtractor; - readonly integerExtractor: BaseNumberExtractor; - readonly numberParser: BaseNumberParser; - readonly durationExtractor: BaseDurationExtractor; - readonly utilityConfiguration: IDateTimeUtilityConfiguration; - readonly rangeConnectorSymbolRegex : RegExp; - - constructor(dmyDateFormat: boolean) { - - let enableDmy = dmyDateFormat || ChineseDateTime.DefaultLanguageFallback === Constants.DefaultLanguageFallback_DMY; - let enableYmd= ChineseDateTime.DefaultLanguageFallback === Constants.DefaultLanguageFallback_YMD; - - this.dateRegexList = [ - RegExpUtility.getSafeRegExp(ChineseDateTime.DateRegexList1), - RegExpUtility.getSafeRegExp(ChineseDateTime.DateRegexList2), - RegExpUtility.getSafeRegExp(ChineseDateTime.DateRegexList3), - // 2015-12-23 - This regex represents the standard format in Chinese dates (YMD) and has precedence over other orderings - RegExpUtility.getSafeRegExp(ChineseDateTime.DateRegexList8), - - // Regex precedence where the order between D and M varies is controlled by DefaultLanguageFallback - enableDmy ? - RegExpUtility.getSafeRegExp(ChineseDateTime.DateRegexList5) : - RegExpUtility.getSafeRegExp(ChineseDateTime.DateRegexList4), - - enableDmy ? - RegExpUtility.getSafeRegExp(ChineseDateTime.DateRegexList4) : - RegExpUtility.getSafeRegExp(ChineseDateTime.DateRegexList5), - - enableDmy ? - RegExpUtility.getSafeRegExp(ChineseDateTime.DateRegexList7) : - (enableYmd ? - RegExpUtility.getSafeRegExp(ChineseDateTime.DateRegexList7) : - RegExpUtility.getSafeRegExp(ChineseDateTime.DateRegexList6)), - - enableDmy ? - RegExpUtility.getSafeRegExp(ChineseDateTime.DateRegexList6) : - (enableYmd ? - RegExpUtility.getSafeRegExp(ChineseDateTime.DateRegexList6) : - RegExpUtility.getSafeRegExp(ChineseDateTime.DateRegexList7)), - ]; - this.implicitDateList = [ - RegExpUtility.getSafeRegExp(ChineseDateTime.LunarRegex), - RegExpUtility.getSafeRegExp(ChineseDateTime.SpecialDayRegex), - RegExpUtility.getSafeRegExp(ChineseDateTime.DateThisRegex), - RegExpUtility.getSafeRegExp(ChineseDateTime.DateLastRegex), - RegExpUtility.getSafeRegExp(ChineseDateTime.DateNextRegex), - RegExpUtility.getSafeRegExp(ChineseDateTime.WeekDayRegex), - RegExpUtility.getSafeRegExp(ChineseDateTime.WeekDayOfMonthRegex), - RegExpUtility.getSafeRegExp(ChineseDateTime.SpecialDate) - ]; - } -} - -export class ChineseDateExtractor extends BaseDateExtractor { - static beforeRegex: RegExp = RegExpUtility.getSafeRegExp(ChineseDateTime.BeforeRegex); - static afterRegex: RegExp = RegExpUtility.getSafeRegExp(ChineseDateTime.AfterRegex); - static dateTimePeriodUnitRegex: RegExp = RegExpUtility.getSafeRegExp(ChineseDateTime.DateTimePeriodUnitRegex); - private readonly durationExtractor: ChineseDurationExtractor; - - constructor(dmyDateFormat: boolean) { - super(new ChineseDateExtractorConfiguration(dmyDateFormat)); - this.durationExtractor = new ChineseDurationExtractor(); - } - - extract(source: string, refDate: Date): ExtractResult[] { - if (!refDate) { - refDate = new Date(); - } - let referenceDate = refDate; - - let tokens: Token[] = new Array() - .concat(super.basicRegexMatch(source)) - .concat(super.implicitDate(source)) - .concat(this.durationWithAgoAndLater(source, referenceDate)); - let result = Token.mergeAllTokens(tokens, source, this.extractorName); - return result; - } - - protected durationWithAgoAndLater(source: string, refDate: Date): Token[] { - let ret = []; - let durationEr = this.durationExtractor.extract(source, refDate); - durationEr.forEach(er => { - if (!RegExpUtility.isMatch(ChineseDateExtractor.dateTimePeriodUnitRegex, er.text)) { - let pos = er.start + er.length; - if (pos < source.length) { - let suffix = source.substr(pos, 1); - let beforeMatch = RegExpUtility.getMatches(ChineseDateExtractor.beforeRegex, suffix).pop(); - let afterMatch = RegExpUtility.getMatches(ChineseDateExtractor.afterRegex, suffix).pop(); - - if (beforeMatch && suffix.startsWith(beforeMatch.value) || afterMatch && suffix.startsWith(afterMatch.value)) { - let metadata = new MetaData(); - metadata.IsDurationWithAgoAndLater = true; - ret.push(new Token(er.start, pos + 1, metadata)); - } - } - } - }); - return ret; - } -} - -class ChineseDateParserConfiguration implements IDateParserConfiguration { - readonly ordinalExtractor: BaseNumberExtractor - readonly integerExtractor: BaseNumberExtractor - readonly cardinalExtractor: BaseNumberExtractor - readonly durationExtractor: BaseDurationExtractor - readonly numberParser: BaseNumberParser - readonly durationParser: IDateTimeParser - readonly monthOfYear: ReadonlyMap - readonly dayOfMonth: ReadonlyMap - readonly dayOfWeek: ReadonlyMap - readonly unitMap: ReadonlyMap - readonly cardinalMap: ReadonlyMap - readonly dateRegex: RegExp[] - readonly onRegex: RegExp - readonly specialDayRegex: RegExp - readonly specialDayWithNumRegex: RegExp - readonly nextRegex: RegExp - readonly unitRegex: RegExp - readonly monthRegex: RegExp - readonly weekDayRegex: RegExp - readonly lastRegex: RegExp - readonly thisRegex: RegExp - readonly weekDayOfMonthRegex: RegExp - readonly forTheRegex: RegExp; - readonly weekDayAndDayOfMonthRegex: RegExp; - readonly relativeMonthRegex: RegExp; - readonly strictRelativeRegex: RegExp; - readonly relativeWeekDayRegex: RegExp; - readonly utilityConfiguration: IDateTimeUtilityConfiguration - readonly dateTokenPrefix: string - - getSwiftDay(source: string): number { - let trimmedSource = source.trim().toLowerCase(); - let swift = 0; - if (trimmedSource === '今天' || trimmedSource === '今日' || trimmedSource === '最近') { - swift = 0; - } - else if (trimmedSource.startsWith('明')) { - swift = 1; - } - else if (trimmedSource.startsWith('昨')) { - swift = -1; - } - else if (trimmedSource === '大后天' || trimmedSource === '大後天') { - swift = 3; - } - else if (trimmedSource === '大前天') { - swift = -3; - } - else if (trimmedSource === '后天' || trimmedSource === '後天') { - swift = 2; - } - else if (trimmedSource === '前天') { - swift = -2; - } - return swift; - } - - getSwiftMonthOrYear(source: string): number { - let trimmedSource = source.trim().toLowerCase(); - let swift = 0; - if (trimmedSource.startsWith(ChineseDateTime.ParserConfigurationNextMonthRegex)) { - swift = 1; - } - else if (trimmedSource.startsWith(ChineseDateTime.ParserConfigurationLastMonthRegex)) { - swift = -1; - } - return swift; - } - - getSwift(source: string): number { - return null; - } - - isCardinalLast(source: string): boolean { - return source === ChineseDateTime.ParserConfigurationLastWeekDayRegex; - } - - constructor(dmyDateFormat: boolean) { - this.dateRegex = new ChineseDateExtractorConfiguration(dmyDateFormat).dateRegexList; - this.monthOfYear = ChineseDateTime.ParserConfigurationMonthOfYear; - this.dayOfMonth = ChineseDateTime.ParserConfigurationDayOfMonth; - this.dayOfWeek = ChineseDateTime.ParserConfigurationDayOfWeek; - this.specialDayRegex = RegExpUtility.getSafeRegExp(ChineseDateTime.SpecialDayRegex); - this.specialDayWithNumRegex = RegExpUtility.getSafeRegExp(ChineseDateTime.SpecialDayWithNumRegex); - this.thisRegex = RegExpUtility.getSafeRegExp(ChineseDateTime.DateThisRegex); - this.nextRegex = RegExpUtility.getSafeRegExp(ChineseDateTime.DateNextRegex); - this.lastRegex = RegExpUtility.getSafeRegExp(ChineseDateTime.DateLastRegex); - this.unitRegex = RegExpUtility.getSafeRegExp(ChineseDateTime.DateUnitRegex); - this.unitMap = ChineseDateTime.ParserConfigurationUnitMap; - this.weekDayRegex = RegExpUtility.getSafeRegExp(ChineseDateTime.WeekDayRegex); - this.integerExtractor = new ChineseIntegerExtractor(); - this.numberParser = AgnosticNumberParserFactory.getParser(AgnosticNumberParserType.Number, new ChineseNumberParserConfiguration()); - } -} - -export class ChineseDateParser extends BaseDateParser { - private readonly lunarRegex: RegExp - private readonly specialDateRegex: RegExp - private readonly tokenNextRegex: RegExp - private readonly tokenLastRegex: RegExp - private readonly monthMaxDays: number[]; - private readonly durationExtractor: ChineseDurationExtractor; - readonly dynastyStartYear: string; - readonly dynastyYearRegex: RegExp; - readonly dynastyYearMap: ReadonlyMap; - - constructor(dmyDateFormat: boolean) { - let config = new ChineseDateParserConfiguration(dmyDateFormat); - super(config); - this.lunarRegex = RegExpUtility.getSafeRegExp(ChineseDateTime.LunarRegex); - this.specialDateRegex = RegExpUtility.getSafeRegExp(ChineseDateTime.SpecialDate); - this.tokenNextRegex = RegExpUtility.getSafeRegExp(ChineseDateTime.NextPrefixRegex); - this.tokenLastRegex = RegExpUtility.getSafeRegExp(ChineseDateTime.LastPrefixRegex); - this.monthMaxDays = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; - this.durationExtractor = new ChineseDurationExtractor(); - this.dynastyStartYear = ChineseDateTime.DynastyStartYear; - this.dynastyYearRegex = RegExpUtility.getSafeRegExp(ChineseDateTime.DynastyYearRegex); - this.dynastyYearMap = ChineseDateTime.DynastyYearMap; - } - - parse(extractorResult: ExtractResult, referenceDate?: Date): DateTimeParseResult | null { - if (!referenceDate) { - referenceDate = new Date(); - } - let resultValue; - if (extractorResult.type === this.parserName) { - let source = extractorResult.text.toLowerCase(); - let innerResult = this.parseBasicRegexMatch(source, referenceDate); - if (!innerResult.success) { - innerResult = this.parseImplicitDate(source, referenceDate); - } - if (!innerResult.success) { - innerResult = this.parseWeekdayOfMonth(source, referenceDate); - } - if (!innerResult.success) { - // TODO create test - innerResult = this.parserDurationWithAgoAndLater(source, referenceDate); - } - if (innerResult.success) { - innerResult.futureResolution = {}; - innerResult.futureResolution[TimeTypeConstants.DATE] = DateTimeFormatUtil.formatDate(innerResult.futureValue); - innerResult.pastResolution = {}; - innerResult.pastResolution[TimeTypeConstants.DATE] = DateTimeFormatUtil.formatDate(innerResult.pastValue); - innerResult.isLunar = this.parseLunarCalendar(source); - resultValue = innerResult; - } - } - let result = new DateTimeParseResult(extractorResult); - result.value = resultValue; - result.timexStr = resultValue ? resultValue.timex : ''; - result.resolutionStr = ''; - - return result; - } - - private parseLunarCalendar(source: string): boolean { - return RegExpUtility.isMatch(this.lunarRegex, source.trim()); - } - - protected parseBasicRegexMatch(source: string, referenceDate: Date): DateTimeResolutionResult { - let trimmedSource = source.trim(); - let result = new DateTimeResolutionResult(); - this.config.dateRegex.some(regex => { - let match = RegExpUtility.getMatches(regex, trimmedSource).pop(); - if (match && match.index === 0 && match.length === trimmedSource.length) { - result = this.matchToDate(match, referenceDate); - return true; - } - }); - return result; - } - - protected parseImplicitDate(source: string, referenceDate: Date): DateTimeResolutionResult { - let trimmedSource = source.trim(); - let result = new DateTimeResolutionResult(); - // handle "on 12" - let match = RegExpUtility.getMatches(this.specialDateRegex, trimmedSource).pop(); - if (match && match.length === trimmedSource.length) { - let day = 0; - let month = referenceDate.getMonth(); - let year = referenceDate.getFullYear(); - let yearStr = match.groups('thisyear').value; - let monthStr = match.groups('thismonth').value; - let dayStr = match.groups('day').value; - day = this.config.dayOfMonth.get(dayStr); - - let hasYear = !StringUtility.isNullOrEmpty(yearStr); - let hasMonth = !StringUtility.isNullOrEmpty(monthStr); - - if (hasMonth) { - if (RegExpUtility.isMatch(this.tokenNextRegex, monthStr)) { - month++; - if (month === Constants.MaxMonth + 1) { - month = Constants.MinMonth; - year++; - } - } - else if (RegExpUtility.isMatch(this.tokenLastRegex, monthStr)) { - month--; - if (month === Constants.MinMonth - 1) { - month = Constants.MaxMonth; - year--; - } - } - if (hasYear) { - if (RegExpUtility.isMatch(this.tokenNextRegex, yearStr)) { - year++; - } - else if (RegExpUtility.isMatch(this.tokenLastRegex, yearStr)) { - year--; - } - } - } - - result.timex = DateTimeFormatUtil.luisDate(hasYear ? year : -1, hasMonth ? month : -1, day); - let futureDate: Date; - let pastDate: Date; - - if (day > this.getMonthMaxDay(year, month)) { - let futureMonth = month + 1; - let pastMonth = month - 1; - let futureYear = year; - let pastYear = year; - - if (futureMonth === Constants.MaxMonth + 1) { - futureMonth = Constants.MinMonth; - futureYear = year++; - } - if (pastMonth === Constants.MinMonth - 1) { - pastMonth = Constants.MaxMonth; - pastYear = year--; - } - - let isFutureValid = DateUtils.isValidDate(futureYear, futureMonth, day); - let isPastValid = DateUtils.isValidDate(pastYear, pastMonth, day); - - if (isFutureValid && isPastValid) { - futureDate = DateUtils.safeCreateFromMinValue(futureYear, futureMonth, day); - pastDate = DateUtils.safeCreateFromMinValue(pastYear, pastMonth, day); - } - else if (isFutureValid && !isPastValid) { - futureDate = pastDate = DateUtils.safeCreateFromMinValue(futureYear, futureMonth, day); - } - else if (!isFutureValid && !isPastValid) { - futureDate = pastDate = DateUtils.safeCreateFromMinValue(pastYear, pastMonth, day); - } - else { - futureDate = pastDate = DateUtils.safeCreateFromMinValue(year, month, day); - } - } - else { - futureDate = DateUtils.safeCreateFromMinValue(year, month, day); - pastDate = DateUtils.safeCreateFromMinValue(year, month, day); - - if (!hasMonth) { - if (futureDate < referenceDate) { - if (this.isValidDate(year, month + 1, day)) { - futureDate = DateUtils.addMonths(futureDate, 1); - } - } - if (pastDate >= referenceDate) { - if (this.isValidDate(year, month - 1, day)) { - pastDate = DateUtils.addMonths(pastDate, -1); - } - else if (DateUtils.isFeb29th(year, month - 1, day)) { - pastDate = DateUtils.addMonths(pastDate, -2); - } - } - } - else if (hasMonth && !hasYear) { - if (futureDate < referenceDate) { - if (DateUtils.isValidDate(year + 1, month, day)) { - futureDate = DateUtils.addYears(futureDate, 1); - } - } - if (pastDate >= referenceDate) { - if (DateUtils.isValidDate(year - 1, month, day)) { - pastDate = DateUtils.addYears(pastDate, -1); - } - } - } - } - - result.futureValue = futureDate; - result.pastValue = pastDate; - result.success = true; - return result; - } - - // handle cases like "昨日", "明日", "大后天" - match = RegExpUtility.getMatches(this.config.specialDayRegex, trimmedSource).pop(); - if (match && match.index === 0 && match.length === trimmedSource.length) { - let swift = this.config.getSwiftDay(match.value); - let value = DateUtils.addDays(referenceDate, swift); - - result.timex = DateTimeFormatUtil.luisDateFromDate(value); - result.futureValue = value; - result.pastValue = value; - result.success = true; - return result; - } - - // handle "this Friday" - match = RegExpUtility.getMatches(this.config.thisRegex, trimmedSource).pop(); - if (match && match.index === 0 && match.length === trimmedSource.length) { - let weekdayStr = match.groups('weekday').value; - let value = DateUtils.this(referenceDate, this.config.dayOfWeek.get(weekdayStr)); - - result.timex = DateTimeFormatUtil.luisDateFromDate(value); - result.futureValue = value; - result.pastValue = value; - result.success = true; - return result; - } - - // handle "next Sunday" - match = RegExpUtility.getMatches(this.config.nextRegex, trimmedSource).pop(); - if (match && match.index === 0 && match.length === trimmedSource.length) { - let weekdayStr = match.groups('weekday').value; - let value = DateUtils.next(referenceDate, this.config.dayOfWeek.get(weekdayStr)); - - result.timex = DateTimeFormatUtil.luisDateFromDate(value); - result.futureValue = value; - result.pastValue = value; - result.success = true; - return result; - } - - // handle "last Friday", "last mon" - match = RegExpUtility.getMatches(this.config.lastRegex, trimmedSource).pop(); - if (match && match.index === 0 && match.length === trimmedSource.length) { - let weekdayStr = match.groups('weekday').value; - let value = DateUtils.last(referenceDate, this.config.dayOfWeek.get(weekdayStr)); - - result.timex = DateTimeFormatUtil.luisDateFromDate(value); - result.futureValue = value; - result.pastValue = value; - result.success = true; - return result; - } - - // handle "Friday" - match = RegExpUtility.getMatches(this.config.weekDayRegex, trimmedSource).pop(); - if (match && match.index === 0 && match.length === trimmedSource.length) { - let weekdayStr = match.groups('weekday').value; - let weekday = this.config.dayOfWeek.get(weekdayStr); - let value = DateUtils.this(referenceDate, weekday); - - if (weekday === 0) { - weekday = 7; - } - if (weekday < referenceDate.getDay()) { - value = DateUtils.next(referenceDate, weekday); - } - result.timex = 'XXXX-WXX-' + weekday; - let futureDate = new Date(value); - let pastDate = new Date(value); - if (futureDate < referenceDate) { - futureDate = DateUtils.addDays(futureDate, 7); - } - if (pastDate >= referenceDate) { - pastDate = DateUtils.addDays(pastDate, -7); - } - - result.futureValue = futureDate; - result.pastValue = pastDate; - result.success = true; - return result; - } - - return result; - } - - protected matchToDate(match: Match, referenceDate: Date): DateTimeResolutionResult { - let result = new DateTimeResolutionResult(); - let yearStr = match.groups('year').value; - let yearCJK = match.groups(Constants.yearCJK).value; - let monthStr = match.groups('month').value; - let dayStr = match.groups('day').value; - let month = 0; - let day = 0; - let year = 0; - let yearTemp = this.convertChineseYearToNumber(yearCJK); - year = yearTemp === -1 ? 0 : yearTemp; - - if (this.config.monthOfYear.has(monthStr) && this.config.dayOfMonth.has(dayStr)) { - month = this.getMonthOfYear(monthStr); - day = this.getDayOfMonth(dayStr); - if (!StringUtility.isNullOrEmpty(yearStr)) { - year = Number.parseInt(yearStr, 10); - if (year < 100 && year >= Constants.MinTwoDigitYearPastNum) { - year += 1900; - } - else if (year >= 0 && year < Constants.MaxTwoDigitYearFutureNum) { - year += 2000; - } - } - } - let noYear = false; - if (year === 0) { - year = referenceDate.getFullYear(); - result.timex = DateTimeFormatUtil.luisDate(-1, month, day); - noYear = true; - } - else { - result.timex = DateTimeFormatUtil.luisDate(year, month, day); - } - - let futurePastDates = DateUtils.generateDates(noYear, referenceDate, year, month, day); - - result.futureValue = futurePastDates.future; - result.pastValue = futurePastDates.past; - result.success = true; - return result; - } - - // convert Chinese Number to Integer - private parseChineseWrittenNumberToValue(source: string): number { - let num = -1; - let er = this.config.integerExtractor.extract(source); - if (er && er[0].type === NumberConstants.SYS_NUM_INTEGER) { - num = Number.parseInt(this.config.numberParser.parse(er[0]).value); - } - - return num; - } - - private convertChineseYearToNumber(source: string): number { - let year = 0; - - let dynastyYear = DateUtils.parseChineseDynastyYear(source, this.dynastyYearRegex, this.dynastyYearMap, this.dynastyStartYear, this.config.integerExtractor, this.config.numberParser); - if (dynastyYear > 0) { - return dynastyYear; - } - - let er = this.config.integerExtractor.extract(source).pop(); - if (er && er.type === NumberConstants.SYS_NUM_INTEGER) { - year = Number.parseInt(this.config.numberParser.parse(er).value); - } - if (year < 10) { - year = 0; - for (let i = 0; i < source.length; i++) { - let char = source.charAt(i); - year *= 10; - let er = this.config.integerExtractor.extract(char).pop(); - if (er && er.type === NumberConstants.SYS_NUM_INTEGER) { - year += Number.parseInt(this.config.numberParser.parse(er).value); - } - } - } - return year < 10 ? -1 : year; - } - - private getMonthOfYear(source: string): number { - let month = this.config.monthOfYear.get(source) > 12 - ? this.config.monthOfYear.get(source) % 12 - : this.config.monthOfYear.get(source); - return month - 1; - } - - private getDayOfMonth(source: string): number { - return this.config.dayOfMonth.get(source) > 31 - ? this.config.dayOfMonth.get(source) % 31 - : this.config.dayOfMonth.get(source); - } - - private getMonthMaxDay(year: number, month: number): number { - let maxDay = this.monthMaxDays[month]; - - if (!DateUtils.isLeapYear(year) && month === 1) { - maxDay -= 1; - } - - return maxDay; - } - - private isValidDate(year: number, month: number, day: number): boolean { - if (month < Constants.MinMonth) { - year--; - month = Constants.MaxMonth; - } - - if (month > Constants.MaxMonth) { - year++; - month = Constants.MinMonth; - } - return DateUtils.isValidDate(year, month, day); - } - - // Handle cases like "三天前" - protected parserDurationWithAgoAndLater(source: string, referenceDate: Date): DateTimeResolutionResult { - let result = new DateTimeResolutionResult(); - let durationRes = this.durationExtractor.extract(source, referenceDate); - - if (durationRes) { - let match = RegExpUtility.getMatches(this.config.unitRegex, source).pop(); - if (match) { - let suffix = source.substring(durationRes[0].start + durationRes[0].length); - let srcUnit = match.groups('unit').value; - - let numberStr = source.substring(durationRes[0].start, match.index - durationRes[0].start); - let number = this.parseChineseWrittenNumberToValue(numberStr); - - if (this.config.unitMap.has(srcUnit)) { - let unitStr = this.config.unitMap.get(srcUnit); - - let beforeMatch = RegExpUtility.getMatches(ChineseDateExtractor.beforeRegex, suffix).pop(); - if (beforeMatch && suffix.startsWith(beforeMatch.value)) { - let date : Date; - switch (unitStr) { - case Constants.TimexDay: - date = DateUtils.addDays(referenceDate, -number); - break; - case Constants.TimexWeek: - date = DateUtils.addDays(referenceDate, -7 * number); - break; - case Constants.TimexMonthFull: - date = DateUtils.addMonths(referenceDate, -number); - break; - case Constants.TimexYear: - date = DateUtils.addYears(referenceDate, -number); - break; - default: - return result; - } - - result.timex = DateTimeFormatUtil.luisDateFromDate(date); - result.futureValue = result.pastValue = date; - result.success = true; - return result; - } - - let afterMatch = RegExpUtility.getMatches(ChineseDateExtractor.afterRegex, suffix).pop(); - if (afterMatch && suffix.startsWith(afterMatch.value)) { - let date: Date; - switch (unitStr) { - case Constants.TimexDay: - date = DateUtils.addDays(referenceDate, number); - break; - case Constants.TimexWeek: - date = DateUtils.addDays(referenceDate, 7 * number); - break; - case Constants.TimexMonthFull: - date = DateUtils.addMonths(referenceDate, number); - break; - case Constants.TimexYear: - date = DateUtils.addYears(referenceDate, number); - break; - default: - return result; - } - - result.timex = DateTimeFormatUtil.luisDateFromDate(date); - result.futureValue = result.pastValue = date; - result.success = true; - return result; - } - } - - } - } - - return result; - } -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-date-time/src/dateTime/chinese/datePeriodConfiguration.ts b/JavaScript/packages/recognizers-date-time/src/dateTime/chinese/datePeriodConfiguration.ts deleted file mode 100644 index 4fc76b5fba..0000000000 --- a/JavaScript/packages/recognizers-date-time/src/dateTime/chinese/datePeriodConfiguration.ts +++ /dev/null @@ -1,984 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { IExtractor, IParser, ExtractResult, RegExpUtility, StringUtility, Match } from "@microsoft/recognizers-text"; -import { AgnosticNumberParserFactory, AgnosticNumberParserType, ChineseNumberParserConfiguration, BaseNumberExtractor, ChineseIntegerExtractor, BaseNumberParser } from "@microsoft/recognizers-text-number"; -import { Constants as NumberConstants } from "@microsoft/recognizers-text-number"; -import { IDatePeriodExtractorConfiguration, BaseDatePeriodExtractor, IDatePeriodParserConfiguration, BaseDatePeriodParser } from "../baseDatePeriod"; -import { ChineseDateExtractor, ChineseDateParser } from "./dateConfiguration"; -import { BaseDurationExtractor, BaseDurationParser } from "../baseDuration"; -import { BaseDateExtractor, BaseDateParser } from "../baseDate"; -import { ChineseDurationExtractor } from "./durationConfiguration"; -import { Token, IDateTimeUtilityConfiguration, DateTimeResolutionResult, DateUtils, DateTimeFormatUtil, StringMap, TimexUtil } from "../utilities"; -import { BaseDateTime } from "../../resources/baseDateTime"; -import { ChineseDateTime } from "../../resources/chineseDateTime"; -import { IDateTimeParser, DateTimeParseResult } from "../parsers"; -import { Constants, TimeTypeConstants } from "../constants"; - -class ChineseDatePeriodExtractorConfiguration implements IDatePeriodExtractorConfiguration { - readonly simpleCasesRegexes: RegExp[] - readonly illegalYearRegex: RegExp - readonly YearRegex: RegExp - readonly tillRegex: RegExp - readonly followedUnit: RegExp - readonly numberCombinedWithUnit: RegExp - readonly pastRegex: RegExp - readonly futureRegex: RegExp - readonly weekOfRegex: RegExp - readonly monthOfRegex: RegExp - readonly dateUnitRegex: RegExp - readonly inConnectorRegex: RegExp - readonly rangeUnitRegex: RegExp - readonly datePointExtractor: ChineseDateExtractor - readonly integerExtractor: BaseNumberExtractor - readonly numberParser: BaseNumberParser - readonly durationExtractor: BaseDurationExtractor - readonly rangeConnectorRegex: RegExp - readonly nowRegex: RegExp - - constructor(dmyDateFormat: boolean) { - this.simpleCasesRegexes = [ - RegExpUtility.getSafeRegExp(ChineseDateTime.SimpleCasesRegex), - RegExpUtility.getSafeRegExp(ChineseDateTime.OneWordPeriodRegex), - RegExpUtility.getSafeRegExp(ChineseDateTime.StrictYearRegex), - RegExpUtility.getSafeRegExp(ChineseDateTime.YearToYear), - RegExpUtility.getSafeRegExp(ChineseDateTime.YearToYearSuffixRequired), - RegExpUtility.getSafeRegExp(ChineseDateTime.YearAndMonth), - RegExpUtility.getSafeRegExp(ChineseDateTime.PureNumYearAndMonth), - RegExpUtility.getSafeRegExp(ChineseDateTime.DatePeriodYearInCJKRegex), - RegExpUtility.getSafeRegExp(ChineseDateTime.WeekOfMonthRegex), - RegExpUtility.getSafeRegExp(ChineseDateTime.SeasonWithYear), - RegExpUtility.getSafeRegExp(ChineseDateTime.QuarterRegex), - RegExpUtility.getSafeRegExp(ChineseDateTime.DecadeRegex), - ]; - this.datePointExtractor = new ChineseDateExtractor(dmyDateFormat); - this.integerExtractor = new ChineseIntegerExtractor(); - this.numberParser = new BaseNumberParser(new ChineseNumberParserConfiguration()); - this.illegalYearRegex = RegExpUtility.getSafeRegExp(BaseDateTime.IllegalYearRegex); - this.tillRegex = RegExpUtility.getSafeRegExp(ChineseDateTime.DatePeriodTillRegex); - this.followedUnit = RegExpUtility.getSafeRegExp(ChineseDateTime.FollowedUnit); - this.numberCombinedWithUnit = RegExpUtility.getSafeRegExp(ChineseDateTime.NumberCombinedWithUnit); - this.pastRegex = RegExpUtility.getSafeRegExp(ChineseDateTime.PastRegex); - this.futureRegex = RegExpUtility.getSafeRegExp(ChineseDateTime.FutureRegex); - this.nowRegex = RegExpUtility.getSafeRegExp(ChineseDateTime.NowRegex); - } - - getFromTokenIndex(source: string) { - let result = { matched: false, index: -1 }; - if (source.endsWith("从")) { - result.index = source.lastIndexOf("从"); - result.matched = true; - } - return result; - }; - - getBetweenTokenIndex(source: string) { - return { matched: false, index: -1 }; - }; - - hasConnectorToken(source: string) { - return false; - } -} - -export class ChineseDatePeriodExtractor extends BaseDatePeriodExtractor { - constructor(dmyDateFormat: boolean) { - super(new ChineseDatePeriodExtractorConfiguration(dmyDateFormat)); - } - - extract(source: string, refDate: Date): ExtractResult[] { - if (!refDate) { - refDate = new Date(); - } - let referenceDate = refDate; - - let tokens: Token[] = new Array() - .concat(super.matchSimpleCases(source)) - .concat(super.mergeTwoTimePoints(source, refDate)) - .concat(this.matchNumberWithUnit(source)); - let result = Token.mergeAllTokens(tokens, source, this.extractorName); - return result; - } - - private matchNumberWithUnit(source: string): Token[] { - let tokens: Token[] = new Array(); - let durations = new Array(); - this.config.integerExtractor.extract(source).forEach(er => { - let afterStr = source.substr(er.start + er.length); - let followedUnitMatch = RegExpUtility.getMatches(this.config.followedUnit, afterStr).pop(); - if (followedUnitMatch && followedUnitMatch.index === 0) { - durations.push(new Token(er.start, er.start + er.length + followedUnitMatch.length)); - } - }); - - RegExpUtility.getMatches(this.config.numberCombinedWithUnit, source).forEach(match => { - durations.push(new Token(match.index, match.index + match.length)); - }); - - durations.forEach(duration => { - let beforeStr = source.substr(0, duration.start).toLowerCase(); - if (StringUtility.isNullOrWhitespace(beforeStr)) { - return; - } - - let match = RegExpUtility.getMatches(this.config.pastRegex, beforeStr).pop(); - if (match && StringUtility.isNullOrWhitespace(beforeStr.substr(match.index + match.length))) { - tokens.push(new Token(match.index, duration.end)); - return; - } - - match = RegExpUtility.getMatches(this.config.futureRegex, beforeStr).pop(); - if (match && StringUtility.isNullOrWhitespace(beforeStr.substr(match.index + match.length))) { - tokens.push(new Token(match.index, duration.end)); - return; - } - }); - - return tokens; - } -} - -class ChineseDatePeriodParserConfiguration implements IDatePeriodParserConfiguration { - readonly dateExtractor: BaseDateExtractor - readonly dateParser: BaseDateParser - readonly durationExtractor: ChineseDurationExtractor - readonly durationParser: BaseDurationParser - readonly integerExtractor: BaseNumberExtractor - readonly numberParser: BaseNumberParser - readonly monthFrontBetweenRegex: RegExp - readonly betweenRegex: RegExp - readonly monthFrontSimpleCasesRegex: RegExp - readonly simpleCasesRegex: RegExp - readonly oneWordPeriodRegex: RegExp - readonly monthWithYear: RegExp - readonly monthNumWithYear: RegExp - readonly yearRegex: RegExp - readonly relativeRegex: RegExp - readonly pastRegex: RegExp - readonly futureRegex: RegExp - readonly inConnectorRegex: RegExp - readonly weekOfMonthRegex: RegExp - readonly weekOfYearRegex: RegExp - readonly quarterRegex: RegExp - readonly quarterRegexYearFront: RegExp - readonly allHalfYearRegex: RegExp - readonly seasonRegex: RegExp - readonly weekOfRegex: RegExp - readonly monthOfRegex: RegExp - readonly whichWeekRegex: RegExp - readonly nextPrefixRegex: RegExp - readonly previousPrefixRegex: RegExp - readonly thisPrefixRegex: RegExp - readonly restOfDateRegex: RegExp - readonly laterEarlyPeriodRegex: RegExp - readonly weekWithWeekDayRangeRegex: RegExp - readonly unspecificEndOfRangeRegex: RegExp - readonly tokenBeforeDate: string - readonly dayOfMonth: ReadonlyMap - readonly monthOfYear: ReadonlyMap - readonly cardinalMap: ReadonlyMap - readonly seasonMap: ReadonlyMap - readonly unitMap: ReadonlyMap - readonly nowRegex: RegExp - - constructor(dmyDateFormat: boolean) { - this.simpleCasesRegex = RegExpUtility.getSafeRegExp(ChineseDateTime.SimpleCasesRegex); - this.yearRegex = RegExpUtility.getSafeRegExp(ChineseDateTime.YearRegex); - this.relativeRegex = RegExpUtility.getSafeRegExp(ChineseDateTime.RelativeRegex); - this.seasonRegex = RegExpUtility.getSafeRegExp(ChineseDateTime.SeasonRegex); - this.seasonMap = ChineseDateTime.ParserConfigurationSeasonMap; - this.quarterRegex = RegExpUtility.getSafeRegExp(ChineseDateTime.QuarterRegex); - this.cardinalMap = ChineseDateTime.ParserConfigurationCardinalMap; - this.unitMap = ChineseDateTime.ParserConfigurationUnitMap; - this.durationExtractor = new ChineseDurationExtractor(); - this.pastRegex = RegExpUtility.getSafeRegExp(ChineseDateTime.PastRegex); - this.futureRegex = RegExpUtility.getSafeRegExp(ChineseDateTime.FutureRegex); - this.monthOfYear = ChineseDateTime.ParserConfigurationMonthOfYear; - this.dayOfMonth = ChineseDateTime.ParserConfigurationDayOfMonth; - this.monthOfYear = ChineseDateTime.ParserConfigurationMonthOfYear; - this.oneWordPeriodRegex = RegExpUtility.getSafeRegExp(ChineseDateTime.OneWordPeriodRegex); - this.dateExtractor = new ChineseDateExtractor(dmyDateFormat); - this.dateParser = new ChineseDateParser(dmyDateFormat); - this.tokenBeforeDate = 'on '; - this.weekOfMonthRegex = RegExpUtility.getSafeRegExp(ChineseDateTime.WeekOfMonthRegex); - this.thisPrefixRegex = RegExpUtility.getSafeRegExp(ChineseDateTime.DatePeriodThisRegex); - this.nextPrefixRegex = RegExpUtility.getSafeRegExp(ChineseDateTime.DatePeriodNextRegex); - this.previousPrefixRegex = RegExpUtility.getSafeRegExp(ChineseDateTime.DatePeriodLastRegex); - this.nowRegex = RegExpUtility.getSafeRegExp(ChineseDateTime.NowRegex); - } - - getSwiftDayOrMonth(source: string): number { - let trimmedSource = source.trim().toLowerCase(); - if (trimmedSource.endsWith('去年')) { - return -1; - } - if (trimmedSource.endsWith('明年')) { - return 1; - } - if (trimmedSource.endsWith('前年')) { - return -2; - } - if (trimmedSource.endsWith('后年')) { - return 2; - } - if (trimmedSource.startsWith('下个')) { - return 1; - } - if (trimmedSource.startsWith('上个')) { - return -1; - } - if (RegExpUtility.isMatch(this.thisPrefixRegex, trimmedSource)) { - return 0; - } - if (RegExpUtility.isMatch(this.nextPrefixRegex, trimmedSource)) { - return 1; - } - if (RegExpUtility.isMatch(this.previousPrefixRegex, trimmedSource)) { - return -1; - } - return 0; - } - - getSwiftYear(source: string): number { - let trimmedSource = source.trim().toLowerCase(); - let swift = -10; - if (trimmedSource.startsWith('明年')) { - swift = 1; - } - else if (trimmedSource.startsWith('去年')) { - swift = -1; - } - else if (trimmedSource.startsWith('今年')) { - swift = 0; - } - return swift; - } - - isFuture(source: string): boolean { - return (RegExpUtility.isMatch(this.thisPrefixRegex, source) - || RegExpUtility.isMatch(this.nextPrefixRegex, source)); - } - - isYearToDate(source: string): boolean { - let trimmedSource = source.trim().toLowerCase(); - return trimmedSource === '今年'; - } - - isMonthToDate(source: string): boolean { - return false; - } - - isWeekOnly(source: string): boolean { - let trimmedSource = source.trim().toLowerCase(); - return trimmedSource.endsWith('周') || trimmedSource.endsWith('星期'); - } - - isWeekend(source: string): boolean { - let trimmedSource = source.trim().toLowerCase(); - return trimmedSource.endsWith('周末'); - } - - isMonthOnly(source: string): boolean { - let trimmedSource = source.trim().toLowerCase(); - return trimmedSource.endsWith('月'); - } - - isYearOnly(source: string): boolean { - let trimmedSource = source.trim().toLowerCase(); - return trimmedSource.endsWith('年'); - } - - isLastCardinal(source: string): boolean { - return source === '最后一'; - } -} - -export class ChineseDatePeriodParser extends BaseDatePeriodParser { - private readonly integerExtractor: IExtractor; - private readonly numberParser: IParser; - private readonly yearInChineseRegex: RegExp; - private readonly numberCombinedWithUnitRegex: RegExp; - private readonly unitRegex: RegExp; - private readonly yearAndMonthRegex: RegExp; - private readonly pureNumberYearAndMonthRegex: RegExp; - private readonly yearToYearRegex: RegExp; - private readonly YearToYearSuffixRequired: RegExp; - private readonly chineseYearRegex: RegExp; - private readonly seasonWithYearRegex: RegExp; - readonly dynastyStartYear: string; - readonly dynastyYearRegex: RegExp; - readonly dynastyYearMap: ReadonlyMap; - readonly decadeRegex: RegExp - readonly thisRegex: RegExp - readonly nextRegex: RegExp - readonly lastRegex: RegExp - - constructor(dmyDateFormat: boolean) { - let config = new ChineseDatePeriodParserConfiguration(dmyDateFormat); - super(config, false); - this.integerExtractor = new ChineseIntegerExtractor(); - this.numberParser = AgnosticNumberParserFactory.getParser(AgnosticNumberParserType.Integer, new ChineseNumberParserConfiguration()); - this.yearInChineseRegex = RegExpUtility.getSafeRegExp(ChineseDateTime.DatePeriodYearInCJKRegex); - this.numberCombinedWithUnitRegex = RegExpUtility.getSafeRegExp(ChineseDateTime.NumberCombinedWithUnit); - this.unitRegex = RegExpUtility.getSafeRegExp(ChineseDateTime.UnitRegex); - this.yearAndMonthRegex = RegExpUtility.getSafeRegExp(ChineseDateTime.YearAndMonth); - this.pureNumberYearAndMonthRegex = RegExpUtility.getSafeRegExp(ChineseDateTime.PureNumYearAndMonth); - this.yearToYearRegex = RegExpUtility.getSafeRegExp(ChineseDateTime.YearToYear); - this.YearToYearSuffixRequired = RegExpUtility.getSafeRegExp(ChineseDateTime.YearToYearSuffixRequired); - this.chineseYearRegex = RegExpUtility.getSafeRegExp(ChineseDateTime.DatePeriodYearInCJKRegex); - this.seasonWithYearRegex = RegExpUtility.getSafeRegExp(ChineseDateTime.SeasonWithYear); - this.dynastyStartYear = ChineseDateTime.DynastyStartYear; - this.dynastyYearRegex = RegExpUtility.getSafeRegExp(ChineseDateTime.DynastyYearRegex); - this.dynastyYearMap = ChineseDateTime.DynastyYearMap; - this.decadeRegex = RegExpUtility.getSafeRegExp(ChineseDateTime.DecadeRegex); - this.thisRegex = RegExpUtility.getSafeRegExp(ChineseDateTime.DatePeriodThisRegex); - this.nextRegex = RegExpUtility.getSafeRegExp(ChineseDateTime.DatePeriodNextRegex); - this.lastRegex = RegExpUtility.getSafeRegExp(ChineseDateTime.DatePeriodLastRegex); - } - - parse(extractorResult: ExtractResult, referenceDate?: Date): DateTimeParseResult | null { - if (!referenceDate) { - referenceDate = new Date(); - } - let resultValue; - if (extractorResult.type === this.parserName) { - let source = extractorResult.text.trim().toLowerCase(); - let innerResult = this.parseSimpleCases(source, referenceDate); - if (!innerResult.success) { - innerResult = this.parseOneWordPeriod(source, referenceDate); - } - if (!innerResult.success) { - innerResult = this.mergeTwoTimePoints(source, referenceDate); - } - if (!innerResult.success) { - innerResult = this.parseNumberWithUnit(source, referenceDate); - } - if (!innerResult.success) { - innerResult = this.parseDuration(source, referenceDate); - } - if (!innerResult.success) { - innerResult = this.parseYearAndMonth(source, referenceDate); - } - if (!innerResult.success) { - innerResult = this.parseYearToYear(source, referenceDate); - } - if (!innerResult.success) { - innerResult = this.parseYear(source, referenceDate); - } - if (!innerResult.success) { - innerResult = this.parseWeekOfMonth(source, referenceDate); - } - if (!innerResult.success) { - innerResult = this.parseSeason(source, referenceDate); - } - if (!innerResult.success) { - innerResult = this.parseQuarter(source, referenceDate); - } - if (!innerResult.success){ - innerResult = this.parseDecade(source, referenceDate); - } - - if (innerResult.success) { - if (innerResult.futureValue && innerResult.pastValue) { - innerResult.futureResolution = {}; - innerResult.futureResolution[TimeTypeConstants.START_DATE] = DateTimeFormatUtil.formatDate(innerResult.futureValue[0]); - innerResult.futureResolution[TimeTypeConstants.END_DATE] = DateTimeFormatUtil.formatDate(innerResult.futureValue[1]); - innerResult.pastResolution = {}; - innerResult.pastResolution[TimeTypeConstants.START_DATE] = DateTimeFormatUtil.formatDate(innerResult.pastValue[0]); - innerResult.pastResolution[TimeTypeConstants.END_DATE] = DateTimeFormatUtil.formatDate(innerResult.pastValue[1]); - } - else { - innerResult.futureResolution = {}; - innerResult.pastResolution = {}; - } - resultValue = innerResult; - } - } - let result = new DateTimeParseResult(extractorResult); - result.value = resultValue; - result.timexStr = resultValue ? resultValue.timex : ''; - result.resolutionStr = ''; - - return result; - } - - protected getMatchSimpleCase(source: string): Match { - return RegExpUtility.getMatches(this.config.simpleCasesRegex, source).pop(); - } - - protected parseSimpleCases(source: string, referenceDate: Date): DateTimeResolutionResult { - let result = new DateTimeResolutionResult(); - let year = referenceDate.getFullYear(); - let month = referenceDate.getMonth(); - let noYear = false; - let inputYear = false; - - let match = this.getMatchSimpleCase(source); - - if (!match || match.index !== 0 || match.length !== source.length) { - return result; - } - let days = match.groups('day'); - let beginDay = this.config.dayOfMonth.get(days.captures[0]); - let endDay = this.config.dayOfMonth.get(days.captures[1]); - let monthStr = match.groups('month').value; - if (!StringUtility.isNullOrEmpty(monthStr)) { - month = this.config.monthOfYear.get(monthStr) - 1; - } - else { - monthStr = match.groups('relmonth').value; - month += this.config.getSwiftDayOrMonth(monthStr); - if (month < 0) { - month = 0; - year--; - } - else if (month > 11) { - month = 11; - year++; - } - } - - let yearStr = match.groups('year').value; - if (!StringUtility.isNullOrEmpty(yearStr)) { - year = Number.parseInt(yearStr, 10); - inputYear = true; - } - else { - noYear = true; - } - - let beginDateLuis = DateTimeFormatUtil.luisDate(inputYear || this.config.isFuture(monthStr) ? year : -1, month, beginDay); - let endDateLuis = DateTimeFormatUtil.luisDate(inputYear || this.config.isFuture(monthStr) ? year : -1, month, endDay); - - let futureYear = year; - let pastYear = year; - let startDate = DateUtils.safeCreateFromValue(DateUtils.minValue(), year, month, beginDay); - if (noYear && startDate < referenceDate) { - futureYear++; - } - if (noYear && startDate >= referenceDate) { - pastYear--; - } - - let futurePastBeginDates = DateUtils.generateDates(noYear, referenceDate, year, month, beginDay); - let futurePastEndDates = DateUtils.generateDates(noYear, referenceDate, year, month, endDay); - - result.timex = TimexUtil.generateDatePeriodTimex(futurePastBeginDates.future, futurePastEndDates.future, Constants.ByDay, beginDateLuis, endDateLuis); - result.futureValue = [futurePastBeginDates.future, futurePastEndDates.future]; - result.pastValue = [futurePastBeginDates.past, futurePastEndDates.past]; - result.success = true; - return result; - } - - protected parseYear(source: string, referenceDate: Date): DateTimeResolutionResult { - let trimmedSource = source.trim(); - let result = new DateTimeResolutionResult(); - let isChinese = false; - let match = RegExpUtility.getMatches(this.config.yearRegex, trimmedSource).pop(); - if (!match || match.length !== trimmedSource.length) { - match = RegExpUtility.getMatches(this.yearInChineseRegex, trimmedSource).pop(); - isChinese = (match && match.length === trimmedSource.length); - } - - if (!match || match.length !== trimmedSource.length) { - return result; - } - - let yearStr = match.value; - if (this.config.isYearOnly(yearStr)) { - yearStr = yearStr.substr(0, yearStr.length - 1).trim(); - } - - let year = this.convertYear(yearStr, isChinese); - if (yearStr.length === 2) { - if (year < 100 && year >= Constants.MinTwoDigitYearPastNum) { - year += 1900; - } - else if (year < 30) { - year += 2000; - } - } - let beginDay = DateUtils.safeCreateFromMinValue(year, 0, 1); - let endDay = DateUtils.safeCreateFromMinValue(year + 1, 0, 1); - - result.timex = DateTimeFormatUtil.toString(year, 4); - result.futureValue = [beginDay, endDay]; - result.pastValue = [beginDay, endDay]; - result.success = true; - return result; - } - - private convertYear(yearStr: string, isChinese: boolean): number { - let year = -1; - let er: ExtractResult; - if (isChinese) { - let dynastyYear = DateUtils.parseChineseDynastyYear(yearStr, this.dynastyYearRegex, this.dynastyYearMap, this.dynastyStartYear, this.integerExtractor, this.numberParser); - if (dynastyYear > 0) { - return dynastyYear; - } - - let yearNum = 0; - er = this.integerExtractor.extract(yearStr).pop(); - if (er && er.type === NumberConstants.SYS_NUM_INTEGER) { - yearNum = Number.parseInt(this.numberParser.parse(er).value); - } - - if (yearNum < 10) { - yearNum = 0; - for (let index = 0; index < yearStr.length; index++) { - let char = yearStr.charAt(index); - yearNum *= 10; - er = this.integerExtractor.extract(char).pop(); - if (er && er.type === NumberConstants.SYS_NUM_INTEGER) { - yearNum += Number.parseInt(this.numberParser.parse(er).value); - } - } - year = yearNum; - } - else { - year = yearNum; - } - } - else { - year = Number.parseInt(yearStr, 10); - } - - return year === 0 ? -1 : year; - } - - protected getWeekOfMonth(cardinal: number, month: number, year: number, referenceDate: Date, noYear: boolean): DateTimeResolutionResult { - let result = new DateTimeResolutionResult(); - let seedDate = this.computeDate(cardinal, 1, month, year); - - let futureDate = new Date(seedDate); - let pastDate = new Date(seedDate); - if (noYear && futureDate < referenceDate) { - futureDate = this.computeDate(cardinal, 1, month, year + 1); - if (futureDate.getMonth() !== month) { - futureDate.setDate(futureDate.getDate() - 7); - } - } - if (noYear && pastDate >= referenceDate) { - pastDate = this.computeDate(cardinal, 1, month, year - 1); - if (pastDate.getMonth() !== month) { - pastDate.setDate(pastDate.getDate() - 7); - } - } - result.timex = noYear ? - `XXXX-${DateTimeFormatUtil.toString(month + 1, 2)}-W${DateTimeFormatUtil.toString(cardinal, 2)}` : - `${DateTimeFormatUtil.toString(year, 4)}-${DateTimeFormatUtil.toString(month + 1, 2)}-W${DateTimeFormatUtil.toString(cardinal, 2)}`; - result.futureValue = [futureDate, DateUtils.addDays(futureDate, this.inclusiveEndPeriod ? 6 : 7)]; - result.pastValue = [pastDate, DateUtils.addDays(pastDate, this.inclusiveEndPeriod ? 6 : 7)]; - result.success = true; - return result; - } - - protected computeDate(cardinal: number, weekday: number, month: number, year: number) { - let firstDay = new Date(year, month, 1); - let firstWeekday = DateUtils.this(firstDay, weekday); - if (weekday === 0) { - weekday = 7; - } - if (weekday < firstDay.getDay()) { - firstWeekday = DateUtils.next(firstDay, weekday); - } - firstWeekday.setDate(firstWeekday.getDate() + (7 * (cardinal - 1))); - return firstWeekday; - } - - protected parseSeason(source: string, referenceDate: Date): DateTimeResolutionResult { - let result = new DateTimeResolutionResult(); - let match = RegExpUtility.getMatches(this.seasonWithYearRegex, source).pop(); - if (!match || match.length !== source.length) { - return result; - } - - let year = referenceDate.getFullYear(); - let yearNum = match.groups('year').value; - let yearChinese = match.groups(Constants.yearCJK).value; - let yearRelative = match.groups('yearrel').value; - let hasYear = false; - - if (!StringUtility.isNullOrEmpty(yearNum)) { - hasYear = true; - if (this.config.isYearOnly(yearNum)) { - yearNum = yearNum.substr(0, yearNum.length - 1); - } - year = this.convertYear(yearNum, false); - } - else if (!StringUtility.isNullOrEmpty(yearChinese)) { - hasYear = true; - if (this.config.isYearOnly(yearChinese)) { - yearChinese = yearChinese.substr(0, yearChinese.length - 1); - } - year = this.convertYear(yearChinese, true); - } - else if (!StringUtility.isNullOrEmpty(yearRelative)) { - hasYear = true; - year += this.config.getSwiftDayOrMonth(yearRelative); - } - - if (year < 100 && year >= Constants.MaxTwoDigitYearFutureNum) { - year += 1900; - } - else if (year < 100 && year < Constants.MinTwoDigitYearPastNum) { - year += 2000; - } - - let seasonStr = match.groups('season').value; - let season = this.config.seasonMap.get(seasonStr); - - if (hasYear) { - result.timex = `${DateTimeFormatUtil.toString(year, 4)}-${season}`; - } - - result.success = true; - return result; - } - - protected parseQuarter(source: string, referenceDate: Date): DateTimeResolutionResult { - let result = new DateTimeResolutionResult(); - let match = RegExpUtility.getMatches(this.config.quarterRegex, source).pop(); - if (!match || match.length !== source.length) { - return result; - } - - let year = referenceDate.getFullYear(); - let yearNum = match.groups('year').value; - let yearChinese = match.groups(Constants.yearCJK).value; - let yearRelative = match.groups('yearrel').value; - - if (!StringUtility.isNullOrEmpty(yearNum)) { - if (this.config.isYearOnly(yearNum)) { - yearNum = yearNum.substr(0, yearNum.length - 1); - } - year = this.convertYear(yearNum, false); - } - else if (!StringUtility.isNullOrEmpty(yearChinese)) { - if (this.config.isYearOnly(yearChinese)) { - yearChinese = yearChinese.substr(0, yearChinese.length - 1); - } - year = this.convertYear(yearChinese, true); - } - else if (!StringUtility.isNullOrEmpty(yearRelative)) { - year += this.config.getSwiftDayOrMonth(yearRelative); - } - - if (year < 100 && year >= Constants.MaxTwoDigitYearFutureNum) { - year += 1900; - } - else if (year < 100 && year < Constants.MinTwoDigitYearPastNum) { - year += 2000; - } - - let cardinalStr = match.groups('cardinal').value; - let quarterNum = this.config.cardinalMap.get(cardinalStr); - let beginDate = DateUtils.safeCreateFromValue(DateUtils.minValue(), year, quarterNum * 3 - 3, 1); - let endDate = DateUtils.safeCreateFromValue(DateUtils.minValue(), year, quarterNum * 3, 1); - result.futureValue = [beginDate, endDate]; - result.pastValue = [beginDate, endDate]; - result.timex = `(${DateTimeFormatUtil.luisDateFromDate(beginDate)},${DateTimeFormatUtil.luisDateFromDate(endDate)},P3M)`; - result.success = true; - return result; - } - - protected parseNumberWithUnit(source: string, referenceDate: Date): DateTimeResolutionResult { - let result = new DateTimeResolutionResult(); - - // if there are NO spaces between number and unit - let match = RegExpUtility.getMatches(this.numberCombinedWithUnitRegex, source).pop(); - if (!match) { - return result; - } - - let sourceUnit = match.groups('unit').value.trim().toLowerCase(); - if (!this.config.unitMap.has(sourceUnit)) { - return result; - } - - let numStr = match.groups('num').value; - let beforeStr = source.substr(0, match.index).trim().toLowerCase(); - - return this.parseCommonDurationWithUnit(beforeStr, sourceUnit, numStr, referenceDate); - } - - protected parseDuration(source: string, referenceDate: Date): DateTimeResolutionResult { - let result = new DateTimeResolutionResult(); - // for case "前两年" "后三年" - let durationResult = this.config.durationExtractor.extract(source, referenceDate).pop(); - if (!durationResult) { - return result; - } - - let match = RegExpUtility.getMatches(this.unitRegex, durationResult.text).pop(); - if (!match) { - return result; - } - - let sourceUnit = match.groups('unit').value.trim().toLowerCase(); - if (!this.config.unitMap.has(sourceUnit)) { - return result; - } - - let beforeStr = source.substr(0, durationResult.start).trim().toLowerCase(); - let numberStr = durationResult.text.substr(0, match.index).trim().toLowerCase(); - let numberValue = this.convertChineseToNumber(numberStr); - let numStr = numberValue.toString(); - - return this.parseCommonDurationWithUnit(beforeStr, sourceUnit, numStr, referenceDate); - } - - protected parseDecade(source: string, referenceDate: Date): DateTimeResolutionResult { - let result = new DateTimeResolutionResult(); - let century = Math.floor(referenceDate.getFullYear() / 100) + 1; - let decadeLastYear = 10; - let inputCentury = false; - let beginLuisStr; - let endLuisStr; - - let match = RegExpUtility.getMatches(this.decadeRegex, source).pop(); - if (!match) { - return result; - } - - let decadeStr = match.groups(Constants.Decade).value; - let decade = this.convertChineseToNumber(decadeStr); - let centuryStr = match.groups(Constants.Century).value; - if (centuryStr) { - century = this.convertChineseToNumber(centuryStr); - inputCentury = true; - } - else { - centuryStr = match.groups(Constants.RelCentury).value; - if (centuryStr) { - centuryStr = centuryStr.trim(); - let thismatch = RegExpUtility.getMatches(this.thisRegex, centuryStr).pop(); - let nextmatch = RegExpUtility.getMatches(this.nextRegex, centuryStr).pop(); - let lastmatch = RegExpUtility.getMatches(this.lastRegex, centuryStr).pop(); - - if (nextmatch) { - century++; - } - else if (lastmatch) { - century--; - } - - inputCentury = true; - } - } - - let beginYear = ((century - 1) * 100) + decade; - let endYear = beginYear + decadeLastYear; - - if (inputCentury) { - beginLuisStr = DateTimeFormatUtil.luisDate(beginYear, 0, 1); - endLuisStr = DateTimeFormatUtil.luisDate(endYear, 0, 1); - } - else { - let beginYearStr = "XX" + decade; - beginLuisStr = DateTimeFormatUtil.luisDate(-1, 0, 1); - beginLuisStr = beginLuisStr.replace("XXXX", beginYearStr); - - let endYearStr = "XX" + ("0" + endYear % 100).slice(-2); - endLuisStr = DateTimeFormatUtil.luisDate(-1, 0, 1); - endLuisStr = endLuisStr.replace("XXXX", endYearStr); - } - - result.timex = `(${beginLuisStr},${endLuisStr},P10Y)`; - - let futureYear = beginYear - let pastYear = beginYear; - let startDate = DateUtils.safeCreateFromValue(DateUtils.minValue(), beginYear, 0, 1); - - if (!inputCentury && startDate < referenceDate) { - futureYear += 100; - } - - if (!inputCentury && startDate >= referenceDate) { - pastYear -= 100; - } - - result.futureValue = [DateUtils.safeCreateFromValue(DateUtils.minValue(), futureYear, 0, 1), DateUtils.safeCreateFromValue(DateUtils.minValue(), futureYear + decadeLastYear, 0, 1)]; - result.pastValue = [DateUtils.safeCreateFromValue(DateUtils.minValue(), pastYear, 0, 1), DateUtils.safeCreateFromValue(DateUtils.minValue(), pastYear + decadeLastYear, 0, 1)]; - result.success = true; - - return result; - } - - private parseCommonDurationWithUnit(beforeStr: string, sourceUnit: string, numStr: string, referenceDate: Date): DateTimeResolutionResult { - let result = new DateTimeResolutionResult(); - - let unitStr = this.config.unitMap.get(sourceUnit); - let pastMatch = RegExpUtility.getMatches(this.config.pastRegex, beforeStr).pop(); - let hasPast = pastMatch && pastMatch.length === beforeStr.length; - - let futureMatch = RegExpUtility.getMatches(this.config.futureRegex, beforeStr).pop(); - let hasFuture = futureMatch && futureMatch.length === beforeStr.length; - - if (!hasFuture && !hasPast) { - return result; - } - - let beginDate = new Date(referenceDate); - let endDate = new Date(referenceDate); - let difference = Number.parseFloat(numStr); - switch (unitStr) { - case 'D': - beginDate = hasPast ? DateUtils.addDays(referenceDate, -difference) : beginDate; - endDate = hasFuture ? DateUtils.addDays(referenceDate, difference) : endDate; - break; - case 'W': - beginDate = hasPast ? DateUtils.addDays(referenceDate, -7 * difference) : beginDate; - endDate = hasFuture ? DateUtils.addDays(referenceDate, 7 * difference) : endDate; - break; - case 'MON': - beginDate = hasPast ? DateUtils.addMonths(referenceDate, -Math.round(difference)) : beginDate; - endDate = hasFuture ? DateUtils.addMonths(referenceDate, Math.round(difference)) : endDate; - break; - case 'Y': - beginDate = hasPast ? DateUtils.addYears(referenceDate, -Math.round(difference)) : beginDate; - endDate = hasFuture ? DateUtils.addYears(referenceDate, Math.round(difference)) : endDate; - break; - default: return result; - } - if (hasFuture) { - beginDate = DateUtils.addDays(beginDate, 1); - endDate = DateUtils.addDays(endDate, 1); - } - - let beginTimex = DateTimeFormatUtil.luisDateFromDate(beginDate); - let endTimex = DateTimeFormatUtil.luisDateFromDate(endDate); - result.timex = `(${beginTimex},${endTimex},P${numStr}${unitStr.charAt(0)})`; - result.futureValue = [beginDate, endDate]; - result.pastValue = [beginDate, endDate]; - result.success = true; - return result; - } - - private convertChineseToNumber(source: string): number { - let num = -1; - let er = this.integerExtractor.extract(source).pop(); - if (er && er.type === NumberConstants.SYS_NUM_INTEGER) { - num = Number.parseInt(this.numberParser.parse(er).value); - } - return num; - } - - private parseYearAndMonth(source: string, referenceDate: Date): DateTimeResolutionResult { - let result = new DateTimeResolutionResult(); - let match = RegExpUtility.getMatches(this.yearAndMonthRegex, source).pop(); - if (!match || match.length !== source.length) { - match = RegExpUtility.getMatches(this.pureNumberYearAndMonthRegex, source).pop(); - } - if (!match || match.length !== source.length) { - return result; - } - - // parse year - let year = referenceDate.getFullYear(); - let yearNum = match.groups('year').value; - let yearChinese = match.groups(Constants.yearCJK).value; - let yearRelative = match.groups('yearrel').value; - - if (!StringUtility.isNullOrEmpty(yearNum)) { - if (this.config.isYearOnly(yearNum)) { - yearNum = yearNum.substr(0, yearNum.length - 1); - } - year = this.convertYear(yearNum, false); - } - else if (!StringUtility.isNullOrEmpty(yearChinese)) { - if (this.config.isYearOnly(yearChinese)) { - yearChinese = yearChinese.substr(0, yearChinese.length - 1); - } - year = this.convertYear(yearChinese, true); - } - else if (!StringUtility.isNullOrEmpty(yearRelative)) { - year += this.config.getSwiftDayOrMonth(yearRelative); - } - - if (year < 100 && year >= Constants.MaxTwoDigitYearFutureNum) { - year += 1900; - } - else if (year < 100 && year < Constants.MinTwoDigitYearPastNum) { - year += 2000; - } - - let monthStr = match.groups('month').value.toLowerCase(); - let month = (this.config.monthOfYear.get(monthStr) % 12) - 1; - month = month === -1 ? 11 : month; - - let beginDate = DateUtils.safeCreateFromMinValue(year, month, 1); - let endDate = month === 11 - ? DateUtils.safeCreateFromMinValue(year + 1, 0, 1) - : DateUtils.safeCreateFromMinValue(year, month + 1, 1); - - result.timex = DateTimeFormatUtil.toString(year, 4) + '-' + DateTimeFormatUtil.toString(month + 1, 2); - result.futureValue = [beginDate, endDate]; - result.pastValue = [beginDate, endDate]; - result.success = true; - return result; - } - - private parseYearToYear(source: string, referenceDate: Date): DateTimeResolutionResult { - let result = new DateTimeResolutionResult(); - - let match = RegExpUtility.getMatches(this.yearToYearRegex, source).pop(); - if (!match) { - let match = RegExpUtility.getMatches(this.YearToYearSuffixRequired, source).pop(); - if (!match) { - return result; - } - } - - let yearMatches = RegExpUtility.getMatches(this.config.yearRegex, source); - let chineseYearMatches = RegExpUtility.getMatches(this.chineseYearRegex, source); - - let beginYear = 0; - let endYear = 0; - - if (yearMatches.length === 2) { - beginYear = this.convertChineseToNumber(yearMatches[0].groups('year').value); - endYear = this.convertChineseToNumber(yearMatches[1].groups('year').value); - } - else if (chineseYearMatches.length === 2) { - beginYear = this.convertYear(chineseYearMatches[0].groups(Constants.yearCJK).value, true); - endYear = this.convertYear(chineseYearMatches[1].groups(Constants.yearCJK).value, true); - } - else if (yearMatches.length === 1 && chineseYearMatches.length === 1) { - if (yearMatches[0].index < chineseYearMatches[0].index) { - beginYear = this.convertChineseToNumber(yearMatches[0].groups('year').value); - endYear = this.convertChineseToNumber(chineseYearMatches[0].groups(Constants.yearCJK).value); - } - else { - beginYear = this.convertChineseToNumber(chineseYearMatches[0].groups(Constants.yearCJK).value); - endYear = this.convertChineseToNumber(yearMatches[0].groups('year').value); - } - } - - beginYear = this.sanitizeYear(beginYear); - endYear = this.sanitizeYear(endYear); - - let beginDate = DateUtils.safeCreateFromMinValue(beginYear, 0, 1); - let endDate = DateUtils.safeCreateFromMinValue(endYear, 0, 1); - let beginTimex = DateTimeFormatUtil.luisDateFromDate(beginDate); - let endTimex = DateTimeFormatUtil.luisDateFromDate(endDate); - - result.timex = `(${beginTimex},${endTimex},P${endYear - beginYear}Y)`; - result.futureValue = [beginDate, endDate]; - result.pastValue = [beginDate, endDate]; - result.success = true; - - return result; - } - - private sanitizeYear(year: number): number { - let result = year; - if (year < 100 && year >= Constants.MaxTwoDigitYearFutureNum) { - result += 1900; - } - else if (year < 100 && year < Constants.MinTwoDigitYearPastNum) { - result += 2000; - } - return result; - } -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-date-time/src/dateTime/chinese/dateTimeConfiguration.ts b/JavaScript/packages/recognizers-date-time/src/dateTime/chinese/dateTimeConfiguration.ts deleted file mode 100644 index 32efb5658b..0000000000 --- a/JavaScript/packages/recognizers-date-time/src/dateTime/chinese/dateTimeConfiguration.ts +++ /dev/null @@ -1,492 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { IExtractor, ExtractResult, RegExpUtility, StringUtility, MetaData } from "@microsoft/recognizers-text"; -import { AgnosticNumberParserFactory, BaseNumberParser, BaseNumberExtractor, ChineseIntegerExtractor, AgnosticNumberParserType, ChineseNumberParserConfiguration } from "@microsoft/recognizers-text-number"; -import { Constants as NumberConstants } from "@microsoft/recognizers-text-number"; -import { Constants , TimeTypeConstants } from "../constants"; -import { IDateTimeExtractor, IDateTimeExtractorConfiguration, BaseDateTimeExtractor, IDateTimeParserConfiguration, BaseDateTimeParser } from "../baseDateTime"; -import { BaseDurationExtractor, BaseDurationParser } from "../baseDuration"; -import { BaseDateExtractor, BaseDateParser } from "../baseDate"; -import { BaseTimeExtractor, BaseTimeParser } from "../baseTime"; -import { BaseDatePeriodExtractor, BaseDatePeriodParser } from "../baseDatePeriod"; -import { BaseTimePeriodExtractor, BaseTimePeriodParser } from "../baseTimePeriod"; -import { BaseDateTimePeriodExtractor, BaseDateTimePeriodParser } from "../baseDateTimePeriod"; -import { ChineseDurationExtractor } from "./durationConfiguration"; -import { ChineseTimeExtractor, ChineseTimeParser } from "./timeConfiguration"; -import { ChineseDateExtractor, ChineseDateParser } from "./dateConfiguration"; -import { Token, IDateTimeUtilityConfiguration, DateUtils, DateTimeFormatUtil, DateTimeResolutionResult, StringMap } from "../utilities"; -import { ChineseDateTime } from "../../resources/chineseDateTime"; -import { IDateTimeParser, DateTimeParseResult } from "../parsers"; - -class ChineseDateTimeExtractorConfiguration implements IDateTimeExtractorConfiguration { - readonly datePointExtractor: ChineseDateExtractor - readonly timePointExtractor: ChineseTimeExtractor - readonly durationExtractor: BaseDurationExtractor - readonly suffixRegex: RegExp - readonly nowRegex: RegExp - readonly timeOfTodayAfterRegex: RegExp - readonly simpleTimeOfTodayAfterRegex: RegExp - readonly nightRegex: RegExp - readonly timeOfTodayBeforeRegex: RegExp - readonly simpleTimeOfTodayBeforeRegex: RegExp - readonly specificEndOfRegex: RegExp - readonly unspecificEndOfRegex: RegExp - readonly unitRegex: RegExp - readonly prepositionRegex: RegExp - readonly utilityConfiguration: IDateTimeUtilityConfiguration - - constructor(dmyDateFormat: boolean) { - this.datePointExtractor = new ChineseDateExtractor(dmyDateFormat); - this.timePointExtractor = new ChineseTimeExtractor(); - this.prepositionRegex = RegExpUtility.getSafeRegExp(ChineseDateTime.PrepositionRegex); - this.nowRegex = RegExpUtility.getSafeRegExp(ChineseDateTime.NowRegex); - this.nightRegex = RegExpUtility.getSafeRegExp(ChineseDateTime.NightRegex); - this.timeOfTodayBeforeRegex = RegExpUtility.getSafeRegExp(ChineseDateTime.TimeOfSpecialDayRegex); - } - - isConnectorToken(source: string): boolean { - return StringUtility.isNullOrEmpty(source) - || source === ',' - || RegExpUtility.isMatch(this.prepositionRegex, source); - } -} - -export class ChineseDateTimeExtractor extends BaseDateTimeExtractor { - static beforeRegex: RegExp = RegExpUtility.getSafeRegExp(ChineseDateTime.BeforeRegex); - static afterRegex: RegExp = RegExpUtility.getSafeRegExp(ChineseDateTime.AfterRegex); - static dateTimePeriodUnitRegex: RegExp = RegExpUtility.getSafeRegExp(ChineseDateTime.DateTimePeriodUnitRegex); - private readonly durationExtractor: ChineseDurationExtractor; - - constructor(dmyDateFormat: boolean) { - super(new ChineseDateTimeExtractorConfiguration(dmyDateFormat)); - this.durationExtractor = new ChineseDurationExtractor(); - } - - extract(source: string, refDate: Date): ExtractResult[] { - if (!refDate) { - refDate = new Date(); - } - let referenceDate = refDate; - - let tokens: Token[] = new Array() - .concat(this.mergeDateAndTime(source, referenceDate)) - .concat(this.basicRegexMatch(source)) - .concat(this.timeOfToday(source, referenceDate)) - .concat(this.durationWithAgoAndLater(source, referenceDate)); - let result = Token.mergeAllTokens(tokens, source, this.extractorName); - return result; - } - - protected mergeDateAndTime(source: string, refDate: Date): Token[] { - let tokens: Token[] = new Array(); - let ers = this.config.datePointExtractor.extract(source, refDate); - if (ers.length < 1) { - return tokens; - } - ers = ers.concat(this.config.timePointExtractor.extract(source, refDate)); - if (ers.length < 2) { - return tokens; - } - ers = ers.sort((erA, erB) => erA.start < erB.start ? -1 : erA.start === erB.start ? 0 : 1); - let i = 0; - while (i < ers.length - 1) { - let j = i + 1; - while (j < ers.length && ExtractResult.isOverlap(ers[i], ers[j])) { - j++; - } - if (j >= ers.length) { - break; - } - if (ers[i].type === Constants.SYS_DATETIME_DATE && ers[j].type === Constants.SYS_DATETIME_TIME) { - let middleBegin = ers[i].start + ers[i].length; - let middleEnd = ers[j].start; - if (middleBegin > middleEnd) { - continue; - } - let middleStr = source.substr(middleBegin, middleEnd - middleBegin).trim().toLowerCase(); - if (this.config.isConnectorToken(middleStr)) { - let begin = ers[i].start; - let end = ers[j].start + ers[j].length; - tokens.push(new Token(begin, end)); - } - i = j + 1; - continue; - } - i = j; - } - - return tokens; - } - - private timeOfToday(source: string, refDate: Date): Token[] { - let tokens: Token[] = new Array(); - this.config.timePointExtractor.extract(source, refDate).forEach(er => { - let beforeStr = source.substr(0, er.start); - let innerMatch = RegExpUtility.getMatches(this.config.nightRegex, er.text).pop(); - if (innerMatch && innerMatch.index === 0) { - beforeStr = source.substr(0, er.start + innerMatch.length); - } - - if (StringUtility.isNullOrWhitespace(beforeStr)) { - return; - } - - let match = RegExpUtility.getMatches(this.config.timeOfTodayBeforeRegex, beforeStr).pop(); - if (match && StringUtility.isNullOrWhitespace(beforeStr.substr(match.index + match.length))) { - let begin = match.index; - let end = er.start + er.length; - tokens.push(new Token(begin, end)); - } - }); - return tokens; - } - - // Process case like "5分钟前" "二小时后" - protected durationWithAgoAndLater(source: string, refDate: Date): Token[] { - let ret = []; - let durationEr = this.durationExtractor.extract(source, refDate); - durationEr.forEach(er => { - let pos = er.start + er.length; - if (pos < source.length) { - let suffix = source.substr(pos, 1); - let beforeMatch = RegExpUtility.getMatches(ChineseDateTimeExtractor.beforeRegex, suffix).pop(); - let afterMatch = RegExpUtility.getMatches(ChineseDateTimeExtractor.afterRegex, suffix).pop(); - - if (beforeMatch && suffix.startsWith(beforeMatch.value) || afterMatch && suffix.startsWith(afterMatch.value)) { - let metadata = new MetaData(); - metadata.IsDurationWithAgoAndLater = true; - ret.push(new Token(er.start, pos + 1, metadata)); - } - } - }); - return ret; - } -} - -class ChineseDateTimeParserConfiguration implements IDateTimeParserConfiguration { - readonly tokenBeforeDate: string; - readonly tokenBeforeTime: string; - readonly dateExtractor: IDateTimeExtractor; - readonly timeExtractor: ChineseTimeExtractor; - readonly dateParser: ChineseDateParser; - readonly timeParser: ChineseTimeParser; - readonly cardinalExtractor: BaseNumberExtractor; - readonly numberParser: BaseNumberParser; - readonly durationExtractor: BaseDurationExtractor; - readonly durationParser: BaseDurationParser; - readonly nowRegex: RegExp; - readonly amTimeRegex: RegExp; - readonly pmTimeRegex: RegExp; - readonly simpleTimeOfTodayAfterRegex: RegExp; - readonly simpleTimeOfTodayBeforeRegex: RegExp; - readonly specificTimeOfDayRegex: RegExp; - readonly specificEndOfRegex: RegExp; - readonly unspecificEndOfRegex: RegExp; - readonly unitRegex: RegExp; - readonly unitMap: ReadonlyMap; - readonly numbers: ReadonlyMap; - readonly utilityConfiguration: IDateTimeUtilityConfiguration; - - constructor(dmyDateFormat: boolean) { - this.dateExtractor = new ChineseDateExtractor(dmyDateFormat); - this.timeExtractor = new ChineseTimeExtractor(); - this.dateParser = new ChineseDateParser(dmyDateFormat); - this.timeParser = new ChineseTimeParser(); - this.pmTimeRegex = RegExpUtility.getSafeRegExp(ChineseDateTime.DateTimeSimplePmRegex); - this.amTimeRegex = RegExpUtility.getSafeRegExp(ChineseDateTime.DateTimeSimpleAmRegex); - this.specificTimeOfDayRegex = RegExpUtility.getSafeRegExp(ChineseDateTime.TimeOfSpecialDayRegex); - this.nowRegex = RegExpUtility.getSafeRegExp(ChineseDateTime.NowRegex); - this.numberParser = AgnosticNumberParserFactory.getParser(AgnosticNumberParserType.Number, new ChineseNumberParserConfiguration()); - this.unitRegex = RegExpUtility.getSafeRegExp(ChineseDateTime.DateUnitRegex); - this.unitMap = ChineseDateTime.ParserConfigurationUnitMap; - } - - haveAmbiguousToken(text: string, matchedText: string): boolean { - return null; - } - - getMatchedNowTimex(text: string): { matched: boolean; timex: string; } { - let trimmedText = text.trim().toLowerCase(); - if (trimmedText.endsWith('现在')) { - return { matched: true, timex: 'PRESENT_REF' }; - } - else if (trimmedText === '刚刚才' || trimmedText === '刚刚' || trimmedText === '刚才') { - return { matched: true, timex: 'PAST_REF' }; - } - else if (trimmedText === '立刻' || trimmedText === '马上') { - return { matched: true, timex: 'FUTURE_REF' }; - } - return { matched: false, timex: null }; - } - - getSwiftDay(text: string): number { - let swift = 0; - if (text === '明晚' || text === '明早' || text === '明晨') { - swift = 1; - } - else if (text === '昨晚') { - swift = -1; - } - return swift; - } - - getHour(text: string, hour: number): number { - let result = hour; - if (hour < 12 && ['今晚', '明晚', '昨晚'].some(o => o === text)) { - result += 12; - } - else if (hour >= 12 && ['今早', '今晨', '明早', '明晨'].some(o => o === text)) { - result -= 12; - } - return result; - } -} - -export class ChineseDateTimeParser extends BaseDateTimeParser { - private readonly durationExtractor: ChineseDurationExtractor; - private readonly integerExtractor: BaseNumberExtractor - private readonly lunarRegex: RegExp; - private readonly lunarHolidayRegex: RegExp; - - constructor(dmyDateFormat: boolean) { - let config = new ChineseDateTimeParserConfiguration(dmyDateFormat); - super(config); - this.durationExtractor = new ChineseDurationExtractor(); - this.integerExtractor = new ChineseIntegerExtractor(); - this.lunarRegex = RegExpUtility.getSafeRegExp(ChineseDateTime.LunarRegex); - this.lunarHolidayRegex = RegExpUtility.getSafeRegExp(ChineseDateTime.LunarHolidayRegex); - } - - parse(er: ExtractResult, refTime?: Date): DateTimeParseResult { - if (!refTime) { - refTime = new Date(); - } - let referenceTime = refTime; - - let value = null; - if (er.type === BaseDateTimeParser.ParserName) { - let innerResult = this.mergeDateAndTime(er.text, referenceTime); - if (!innerResult.success) { - innerResult = this.parseBasicRegex(er.text, referenceTime); - } - if (!innerResult.success) { - innerResult = this.parseTimeOfToday(er.text, referenceTime); - } - if (!innerResult.success) { - innerResult = this.parserDurationWithAgoAndLater(er.text, referenceTime); - } - if (innerResult.success) { - innerResult.futureResolution = {}; - innerResult.futureResolution[TimeTypeConstants.DATETIME] = DateTimeFormatUtil.formatDateTime(innerResult.futureValue); - innerResult.pastResolution = {}; - innerResult.pastResolution[TimeTypeConstants.DATETIME] = DateTimeFormatUtil.formatDateTime(innerResult.pastValue); - innerResult.isLunar = this.isLunarCalendar(er.text); - value = innerResult; - } - } - - let ret = new DateTimeParseResult(er); { - ret.value = value, - ret.timexStr = value === null ? "" : value.timex, - ret.resolutionStr = ""; - }; - - return ret; - } - - // parse if lunar contains - private isLunarCalendar(text: string): boolean { - let trimmedText = text.trim(); - if (RegExpUtility.getMatches(this.lunarRegex, text).length || RegExpUtility.getMatches(this.lunarHolidayRegex, text).length) - { - return true; - } - - return false; - } - - // merge a Date entity and a Time entity - protected mergeDateAndTime(text: string, referenceTime: Date): DateTimeResolutionResult { - let ret = new DateTimeResolutionResult(); - - let er1 = this.config.dateExtractor.extract(text, referenceTime); - if (er1.length === 0) { - return ret; - } - - let er2 = this.config.timeExtractor.extract(text, referenceTime); - if (er2.length === 0) { - return ret; - } - - let pr1 = this.config.dateParser.parse(er1[0], new Date(referenceTime.toDateString())); - let pr2 = this.config.timeParser.parse(er2[0], referenceTime); - if (pr1.value === null || pr2.value === null) { - return ret; - } - - let futureDate = pr1.value.futureValue; - let pastDate = pr1.value.pastValue; - let time = pr2.value.futureValue; - - let hour = time.getHours(); - let min = time.getMinutes(); - let sec = time.getSeconds(); - - // handle morning, afternoon - if (RegExpUtility.getMatches(this.config.pmTimeRegex, text).length && hour < 12) { - hour += 12; - } - else if (RegExpUtility.getMatches(this.config.amTimeRegex, text).length && hour >= 12) { - hour -= 12; - } - - let timeStr = pr2.timexStr; - if (timeStr.endsWith("ampm")) { - timeStr = timeStr.substring(0, timeStr.length - 4); - } - - timeStr = "T" + DateTimeFormatUtil.toString(hour, 2) + timeStr.substring(3); - ret.timex = pr1.timexStr + timeStr; - - let val = pr2.value; - if (hour <= 12 && !RegExpUtility.getMatches(this.config.pmTimeRegex, text).length - && !RegExpUtility.getMatches(this.config.amTimeRegex, text).length && val.comment) { - ret.comment = "ampm"; - } - - ret.futureValue = new Date(futureDate.getFullYear(), futureDate.getMonth(), futureDate.getDate(), hour, min, sec); - ret.pastValue = new Date(pastDate.getFullYear(), pastDate.getMonth(), pastDate.getDate(), hour, min, sec); - ret.success = true; - - return ret; - } - - protected parseTimeOfToday(text: string, referenceTime: Date): DateTimeResolutionResult { - let ret = new DateTimeResolutionResult(); - - let ers = this.config.timeExtractor.extract(text, referenceTime); - if (ers.length !== 1) { - return ret; - } - - let pr = this.config.timeParser.parse(ers[0], referenceTime); - if (pr.value === null) { - return ret; - } - - let time = pr.value.futureValue; - - let hour = time.getHours(); - let min = time.getMinutes(); - let sec = time.getSeconds(); - let timeStr = pr.timexStr; - - let match = RegExpUtility.getMatches(this.config.specificTimeOfDayRegex, text).pop(); - - if (match) { - let matchStr = match.value.toLowerCase(); - - // handle "last", "next" - let swift = this.config.getSwiftDay(matchStr); - let date = DateUtils.addDays(referenceTime, swift); - - hour = this.config.getHour(matchStr, hour); - - // in this situation, luisStr cannot end up with "ampm", because we always have a "morning" or "night" - if (timeStr.endsWith("ampm")) { - timeStr = timeStr.substring(0, timeStr.length - 4); - } - timeStr = "T" + DateTimeFormatUtil.toString(hour, 2) + timeStr.substring(3); - - ret.timex = DateTimeFormatUtil.formatDate(date) + timeStr; - ret.futureValue = ret.pastValue = new Date(date.getFullYear(), date.getMonth(), date.getDate(), hour, min, sec); - ret.success = true; - return ret; - } - - return ret; - } - - // Handle cases like "5分钟前", "1小时以后" - protected parserDurationWithAgoAndLater(source: string, referenceDate: Date): DateTimeResolutionResult { - let result = new DateTimeResolutionResult(); - let durationRes = this.durationExtractor.extract(source, referenceDate); - - if (durationRes) { - let match = RegExpUtility.getMatches(ChineseDateTimeExtractor.dateTimePeriodUnitRegex, source).pop(); - if (match) { - let suffix = source.substring(durationRes[0].start + durationRes[0].length); - let srcUnit = match.groups('unit').value; - - let numberStr = source.substring(durationRes[0].start, match.index - durationRes[0].start); - let number = this.parseChineseWrittenNumberToValue(numberStr); - - if (this.config.unitMap.has(srcUnit)) { - let unitStr = this.config.unitMap.get(srcUnit); - - let beforeMatch = RegExpUtility.getMatches(ChineseDateTimeExtractor.beforeRegex, suffix).pop(); - if (beforeMatch && suffix.startsWith(beforeMatch.value)) { - let date : Date; - switch (unitStr) { - case Constants.TimexHour: - date = DateUtils.addHours(referenceDate, -number); - break; - case Constants.TimexMinute: - date = DateUtils.addMinutes(referenceDate, -number); - break; - case Constants.TimexSecond: - date = DateUtils.addSeconds(referenceDate, -number); - break; - default: - return result; - } - - result.timex = DateTimeFormatUtil.luisDateFromDate(date); - result.futureValue = result.pastValue = date; - result.success = true; - return result; - } - - let afterMatch = RegExpUtility.getMatches(ChineseDateExtractor.afterRegex, suffix).pop(); - if (afterMatch && suffix.startsWith(afterMatch.value)) { - let date: Date; - switch (unitStr) { - case Constants.TimexHour: - date = DateUtils.addHours(referenceDate, number); - break; - case Constants.TimexMinute: - date = DateUtils.addMinutes(referenceDate, number); - break; - case Constants.TimexSecond: - date = DateUtils.addSeconds(referenceDate, number); - break; - default: - return result; - } - - result.timex = DateTimeFormatUtil.luisDateFromDate(date); - result.futureValue = result.pastValue = date; - result.success = true; - return result; - } - } - - } - } - - return result; - } - - // convert Chinese Number to Integer - private parseChineseWrittenNumberToValue(source: string): number { - let num = -1; - let er = this.integerExtractor.extract(source); - if (er && er[0].type === NumberConstants.SYS_NUM_INTEGER) { - num = Number.parseInt(this.config.numberParser.parse(er[0]).value); - } - - return num; - } -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-date-time/src/dateTime/chinese/dateTimePeriodConfiguration.ts b/JavaScript/packages/recognizers-date-time/src/dateTime/chinese/dateTimePeriodConfiguration.ts deleted file mode 100644 index c9ddf8e74e..0000000000 --- a/JavaScript/packages/recognizers-date-time/src/dateTime/chinese/dateTimePeriodConfiguration.ts +++ /dev/null @@ -1,762 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { IExtractor, IParser, ExtractResult, RegExpUtility, StringUtility } from "@microsoft/recognizers-text"; -import { ChineseNumberParserConfiguration, AgnosticNumberParserFactory, AgnosticNumberParserType, BaseNumberParser, BaseNumberExtractor, ChineseCardinalExtractor } from "@microsoft/recognizers-text-number"; -import { Constants, TimeTypeConstants } from "../constants"; -import { IDateTimePeriodExtractorConfiguration, BaseDateTimePeriodExtractor, IDateTimePeriodParserConfiguration, BaseDateTimePeriodParser } from "../baseDateTimePeriod"; -import { BaseDurationExtractor, BaseDurationParser } from "../baseDuration"; -import { BaseDateExtractor, BaseDateParser } from "../baseDate"; -import { BaseTimeExtractor, BaseTimeParser } from "../baseTime"; -import { BaseDatePeriodExtractor, BaseDatePeriodParser } from "../baseDatePeriod"; -import { BaseTimePeriodExtractor, BaseTimePeriodParser } from "../baseTimePeriod"; -import { ChineseDurationExtractor } from "./durationConfiguration"; -import { ChineseTimeExtractor, ChineseTimeParser } from "./timeConfiguration"; -import { ChineseTimePeriodExtractor, ChineseTimePeriodParser } from "./timePeriodConfiguration"; -import { ChineseDateExtractor, ChineseDateParser } from "./dateConfiguration"; -import { ChineseDateTimeExtractor, ChineseDateTimeParser } from "./dateTimeConfiguration"; -import { DateUtils, Token, IDateTimeUtilityConfiguration, DateTimeResolutionResult, DateTimeFormatUtil, StringMap } from "../utilities"; -import { IDateTimeParser, DateTimeParseResult } from "../parsers"; -import { ChineseDateTime } from "../../resources/chineseDateTime"; -import { IDateTimeExtractor } from "../baseDateTime"; - -class ChineseDateTimePeriodExtractorConfiguration implements IDateTimePeriodExtractorConfiguration { - readonly cardinalExtractor: ChineseCardinalExtractor - readonly singleDateExtractor: BaseDateExtractor - readonly singleTimeExtractor: ChineseTimeExtractor - readonly singleDateTimeExtractor: ChineseDateTimeExtractor - readonly durationExtractor: BaseDurationExtractor - readonly timePeriodExtractor: IDateTimeExtractor - readonly simpleCasesRegexes: RegExp[] - readonly prepositionRegex: RegExp - readonly tillRegex: RegExp - readonly specificTimeOfDayRegex: RegExp - readonly timeOfDayRegex: RegExp - readonly periodTimeOfDayWithDateRegex: RegExp - readonly followedUnit: RegExp - readonly numberCombinedWithUnit: RegExp - readonly timeUnitRegex: RegExp - readonly previousPrefixRegex: RegExp - readonly nextPrefixRegex: RegExp - readonly rangeConnectorRegex: RegExp - readonly relativeTimeUnitRegex: RegExp - readonly restOfDateTimeRegex: RegExp - readonly generalEndingRegex: RegExp - readonly middlePauseRegex: RegExp - - getFromTokenIndex(source: string) { - let result = { matched: false, index: -1 }; - if (source.endsWith("从")) { - result.index = source.lastIndexOf("从"); - result.matched = true; - } - return result; - }; - - getBetweenTokenIndex(source: string) { - return { matched: false, index: -1 }; - }; - - hasConnectorToken(source: string): boolean { - return (source === '和' || source === ' 与' || source === '到'); - }; - - constructor(dmyDateFormat: boolean) { - this.singleDateExtractor = new ChineseDateExtractor(dmyDateFormat); - this.singleTimeExtractor = new ChineseTimeExtractor(); - this.singleDateTimeExtractor = new ChineseDateTimeExtractor(dmyDateFormat); - this.prepositionRegex = RegExpUtility.getSafeRegExp(ChineseDateTime.DateTimePeriodPrepositionRegex); - this.tillRegex = RegExpUtility.getSafeRegExp(ChineseDateTime.DateTimePeriodTillRegex); - this.cardinalExtractor = new ChineseCardinalExtractor(); - this.followedUnit = RegExpUtility.getSafeRegExp(ChineseDateTime.DateTimePeriodFollowedUnit); - this.timeUnitRegex = RegExpUtility.getSafeRegExp(ChineseDateTime.DateTimePeriodUnitRegex); - this.specificTimeOfDayRegex = RegExpUtility.getSafeRegExp(ChineseDateTime.SpecificTimeOfDayRegex); - this.timeOfDayRegex = RegExpUtility.getSafeRegExp(ChineseDateTime.TimeOfDayRegex); - } -} - -export class ChineseDateTimePeriodExtractor extends BaseDateTimePeriodExtractor { - private readonly zhijianRegex: RegExp; - private readonly pastRegex: RegExp; - private readonly futureRegex: RegExp; - - constructor(dmyDateFormat: boolean) { - super(new ChineseDateTimePeriodExtractorConfiguration(dmyDateFormat)); - this.zhijianRegex = RegExpUtility.getSafeRegExp(ChineseDateTime.ZhijianRegex); - this.pastRegex = RegExpUtility.getSafeRegExp(ChineseDateTime.PastRegex); - this.futureRegex = RegExpUtility.getSafeRegExp(ChineseDateTime.FutureRegex); - } - - extract(source: string, refDate: Date): ExtractResult[] { - if (!refDate) { - refDate = new Date(); - } - let referenceDate = refDate; - - let tokens: Token[] = new Array() - .concat(this.mergeDateAndTimePeriod(source, referenceDate)) - .concat(this.mergeTwoTimePoints(source, referenceDate)) - .concat(this.matchNubmerWithUnit(source)) - .concat(this.matchNight(source, referenceDate)); - let result = Token.mergeAllTokens(tokens, source, this.extractorName); - return result; - } - - private mergeDateAndTimePeriod(source: string, refDate: Date): Token[] { - let tokens: Token[] = new Array(); - let ersDate = this.config.singleDateExtractor.extract(source, refDate); - let ersTime = this.config.singleTimeExtractor.extract(source, refDate); - let timeResults = new Array(); - let j = 0; - for (let i = 0; i < ersDate.length; i++) { - timeResults.push(ersDate[i]); - while (j < ersTime.length && ersTime[j].start + ersTime[j].length <= ersDate[i].start) { - timeResults.push(ersTime[j]); - j++; - } - - while (j < ersTime.length && ExtractResult.isOverlap(ersTime[j], ersDate[i])) { - j++; - } - } - - for (j; j < ersTime.length; j++) { - timeResults.push(ersTime[j]); - } - timeResults = timeResults.sort((a, b) => a.start > b.start ? 1 : a.start < b.start ? -1 : 0); - - let idx = 0; - while (idx < timeResults.length - 1) { - let current = timeResults[idx]; - let next = timeResults[idx + 1]; - if (current.type === Constants.SYS_DATETIME_DATE && next.type === Constants.SYS_DATETIME_TIMEPERIOD) { - let middleBegin = current.start + current.length; - let middleEnd = next.start; - let middleStr = source.substring(middleBegin, middleEnd).trim(); - if (StringUtility.isNullOrWhitespace(middleStr) || RegExpUtility.isMatch(this.config.prepositionRegex, middleStr)) { - let periodBegin = current.start; - let periodEnd = next.start + next.length; - tokens.push(new Token(periodBegin, periodEnd)); - } - idx++; - } - idx++; - } - - return tokens; - } - - protected mergeTwoTimePoints(source: string, refDate: Date): Token[] { - let tokens: Token[] = new Array(); - let ersDateTime = this.config.singleDateTimeExtractor.extract(source, refDate); - let ersTime = this.config.singleTimeExtractor.extract(source, refDate); - let innerMarks: ExtractResult[] = []; - let j = 0; - ersDateTime.forEach((erDateTime, index) => { - innerMarks.push(erDateTime); - while (j < ersTime.length && ersTime[j].start + ersTime[j].length < erDateTime.start) { - innerMarks.push(ersTime[j++]); - } - while (j < ersTime.length && ExtractResult.isOverlap(ersTime[j], erDateTime)) { - j++; - } - }); - - while (j < ersTime.length) { - innerMarks.push(ersTime[j++]); - } - innerMarks = innerMarks.sort((erA, erB) => erA.start < erB.start ? -1 : erA.start === erB.start ? 0 : 1); - - let idx = 0; - while (idx < innerMarks.length - 1) { - let currentMark = innerMarks[idx]; - let nextMark = innerMarks[idx + 1]; - if (currentMark.type === Constants.SYS_DATETIME_TIME && nextMark.type === Constants.SYS_DATETIME_TIME) { - idx++; - continue; - } - - let middleBegin = currentMark.start + currentMark.length; - let middleEnd = nextMark.start; - - let middleStr = source.substr(middleBegin, middleEnd - middleBegin).trim().toLowerCase(); - let matches = RegExpUtility.getMatches(this.config.tillRegex, middleStr); - if (matches && matches.length > 0 && matches[0].index === 0 && matches[0].length === middleStr.length) { - let periodBegin = currentMark.start; - let periodEnd = nextMark.start + nextMark.length; - let beforeStr = source.substr(0, periodBegin).trim().toLowerCase(); - let fromTokenIndex = this.config.getFromTokenIndex(beforeStr); - if (fromTokenIndex.matched) { - periodBegin = fromTokenIndex.index; - } - - tokens.push(new Token(periodBegin, periodEnd)); - idx += 2; - continue; - } - if (this.config.hasConnectorToken(middleStr)) { - let periodBegin = currentMark.start; - let periodEnd = nextMark.start + nextMark.length; - let afterStr = source.substr(periodEnd).trim().toLowerCase(); - let match = RegExpUtility.getMatches(this.zhijianRegex, afterStr).pop(); - if (match) { - tokens.push(new Token(periodBegin, periodEnd + match.length)); - idx += 2; - continue; - } - } - idx++; - }; - return tokens; - } - - private matchNubmerWithUnit(source: string): Token[] { - let tokens: Token[] = new Array(); - let durations = new Array(); - this.config.cardinalExtractor.extract(source).forEach(er => { - let afterStr = source.substr(er.start + er.length); - let followedUnitMatch = RegExpUtility.getMatches(this.config.followedUnit, afterStr).pop(); - if (followedUnitMatch && followedUnitMatch.index === 0) { - durations.push(new Token(er.start, er.start + er.length + followedUnitMatch.length)); - } - }); - - RegExpUtility.getMatches(this.config.timeUnitRegex, source).forEach(match => { - durations.push(new Token(match.index, match.index + match.length)); - }); - - durations.forEach(duration => { - let beforeStr = source.substr(0, duration.start).toLowerCase(); - if (StringUtility.isNullOrWhitespace(beforeStr)) { - return; - } - - let match = RegExpUtility.getMatches(this.pastRegex, beforeStr).pop(); - if (match && StringUtility.isNullOrWhitespace(beforeStr.substr(match.index + match.length))) { - tokens.push(new Token(match.index, duration.end)); - return; - } - - match = RegExpUtility.getMatches(this.futureRegex, beforeStr).pop(); - if (match && StringUtility.isNullOrWhitespace(beforeStr.substr(match.index + match.length))) { - tokens.push(new Token(match.index, duration.end)); - return; - } - }); - - return tokens; - } - - protected matchNight(source: string, refDate: Date): Token[] { - let tokens: Token[] = new Array(); - RegExpUtility.getMatches(this.config.specificTimeOfDayRegex, source).forEach(match => { - tokens.push(new Token(match.index, match.index + match.length)); - }); - - this.config.singleDateExtractor.extract(source, refDate).forEach(er => { - let afterStr = source.substr(er.start + er.length); - RegExpUtility.getMatches(this.config.timeOfDayRegex, afterStr).forEach(match => { - let middleStr = source.substr(0, match.index); - if (StringUtility.isNullOrWhitespace(middleStr) || RegExpUtility.isMatch(this.config.prepositionRegex, middleStr)) { - tokens.push(new Token(er.start, er.start + er.length + match.index + match.length)); - } - }); - }); - - return tokens; - } -} - -class ChineseDateTimePeriodParserConfiguration implements IDateTimePeriodParserConfiguration { - readonly pureNumberFromToRegex: RegExp - readonly pureNumberBetweenAndRegex: RegExp - readonly periodTimeOfDayWithDateRegex: RegExp - readonly specificTimeOfDayRegex: RegExp - readonly pastRegex: RegExp - readonly futureRegex: RegExp - readonly relativeTimeUnitRegex: RegExp - readonly restOfDateTimeRegex: RegExp - readonly numbers: ReadonlyMap - readonly unitMap: ReadonlyMap - readonly dateExtractor: BaseDateExtractor - readonly timeExtractor: IDateTimeExtractor - readonly dateTimeExtractor: ChineseDateTimeExtractor - readonly timePeriodExtractor: IDateTimeExtractor - readonly durationExtractor: BaseDurationExtractor - readonly dateParser: BaseDateParser - readonly timeParser: BaseTimeParser - readonly dateTimeParser: ChineseDateTimeParser - readonly timePeriodParser: BaseTimePeriodParser - readonly durationParser: BaseDurationParser - - constructor(dmyDateFormat: boolean) { - this.dateExtractor = new ChineseDateExtractor(dmyDateFormat); - this.timeExtractor = new ChineseTimeExtractor(); - this.dateTimeExtractor = new ChineseDateTimeExtractor(dmyDateFormat); - this.timePeriodExtractor = new ChineseTimePeriodExtractor(); - this.dateParser = new ChineseDateParser(dmyDateFormat); - this.timeParser = new ChineseTimeParser(); - this.dateTimeParser = new ChineseDateTimeParser(dmyDateFormat); - this.timePeriodParser = new ChineseTimePeriodParser(); - this.specificTimeOfDayRegex = RegExpUtility.getSafeRegExp(ChineseDateTime.SpecificTimeOfDayRegex); - this.relativeTimeUnitRegex = RegExpUtility.getSafeRegExp(ChineseDateTime.TimeOfDayRegex); - this.pastRegex = RegExpUtility.getSafeRegExp(ChineseDateTime.PastRegex); - this.futureRegex = RegExpUtility.getSafeRegExp(ChineseDateTime.FutureRegex); - this.unitMap = ChineseDateTime.ParserConfigurationUnitMap; - } - - getMatchedTimeRange(source: string): { timeStr: string; beginHour: number; endHour: number; endMin: number; success: boolean; swift?: number } { - let swift = 0; - let beginHour = 0; - let endHour = 0; - let endMin = 0; - let timeStr = ''; - switch (source) { - case '今晚': - swift = 0; - timeStr = 'TEV'; - beginHour = 16; - endHour = 20; - break; - case '今早': - case '今晨': - swift = 0; - timeStr = 'TMO'; - beginHour = 8; - endHour = 12; - break; - case '明晚': - swift = 1; - timeStr = 'TEV'; - beginHour = 16; - endHour = 20; - break; - case '明早': - case '明晨': - swift = 1; - timeStr = 'TMO'; - beginHour = 8; - endHour = 12; - break; - case '昨晚': - swift = -1; - timeStr = 'TEV'; - beginHour = 16; - endHour = 20; - break; - default: - return { - timeStr: '', - beginHour: 0, - endHour: 0, - endMin: 0, - swift: 0, - success: false - }; - } - return { - timeStr: timeStr, - beginHour: beginHour, - endHour: endHour, - endMin: endMin, - swift: swift, - success: true - }; - } - - getSwiftPrefix(source: string): number { - return null; - } -} - -export class ChineseDateTimePeriodParser extends BaseDateTimePeriodParser { - private readonly TMORegex: RegExp; - private readonly TMIRegex: RegExp; - private readonly TAFRegex: RegExp; - private readonly TEVRegex: RegExp; - private readonly TNIRegex: RegExp; - private readonly unitRegex: RegExp; - private readonly timeOfDayRegex: RegExp; - private readonly cardinalExtractor: IExtractor; - private readonly cardinalParser: IParser; - - constructor(dmyDateFormat: boolean) { - let config = new ChineseDateTimePeriodParserConfiguration(dmyDateFormat); - super(config); - this.TMORegex = RegExpUtility.getSafeRegExp(ChineseDateTime.DateTimePeriodMORegex); - this.TMIRegex = RegExpUtility.getSafeRegExp(ChineseDateTime.DateTimePeriodMIRegex); - this.TAFRegex = RegExpUtility.getSafeRegExp(ChineseDateTime.DateTimePeriodAFRegex); - this.TEVRegex = RegExpUtility.getSafeRegExp(ChineseDateTime.DateTimePeriodEVRegex); - this.TNIRegex = RegExpUtility.getSafeRegExp(ChineseDateTime.DateTimePeriodNIRegex); - this.unitRegex = RegExpUtility.getSafeRegExp(ChineseDateTime.DateTimePeriodUnitRegex); - this.timeOfDayRegex = RegExpUtility.getSafeRegExp(ChineseDateTime.TimeOfDayRegex); - this.cardinalExtractor = new ChineseCardinalExtractor(); - this.cardinalParser = AgnosticNumberParserFactory.getParser(AgnosticNumberParserType.Cardinal, new ChineseNumberParserConfiguration()); - } - - parse(extractorResult: ExtractResult, referenceDate?: Date): DateTimeParseResult | null { - if (!referenceDate) { - referenceDate = new Date(); - } - let resultValue; - if (extractorResult.type === this.parserName) { - let source = extractorResult.text.trim().toLowerCase(); - let innerResult = this.mergeDateAndTimePeriods(source, referenceDate); - if (!innerResult.success) { - innerResult = this.mergeTwoTimePoints(source, referenceDate); - } - if (!innerResult.success) { - innerResult = this.parseSpecificTimeOfDay(source, referenceDate); - } - if (!innerResult.success) { - innerResult = this.parseNumberWithUnit(source, referenceDate); - } - if (innerResult.success) { - innerResult.futureResolution = {}; - innerResult.futureResolution[TimeTypeConstants.START_DATETIME] = DateTimeFormatUtil.formatDateTime(innerResult.futureValue[0]); - innerResult.futureResolution[TimeTypeConstants.END_DATETIME] = DateTimeFormatUtil.formatDateTime(innerResult.futureValue[1]); - innerResult.pastResolution = {}; - innerResult.pastResolution[TimeTypeConstants.START_DATETIME] = DateTimeFormatUtil.formatDateTime(innerResult.pastValue[0]); - innerResult.pastResolution[TimeTypeConstants.END_DATETIME] = DateTimeFormatUtil.formatDateTime(innerResult.pastValue[1]); - resultValue = innerResult; - } - } - let result = new DateTimeParseResult(extractorResult); - result.value = resultValue; - result.timexStr = resultValue ? resultValue.timex : ''; - result.resolutionStr = ''; - - return result; - } - - protected mergeDateAndTimePeriods(text: string, referenceTime: Date): DateTimeResolutionResult { - let result = new DateTimeResolutionResult(); - - let erDate = this.config.dateExtractor.extract(text, referenceTime).pop(); - let erTimePeriod = this.config.timePeriodExtractor.extract(text, referenceTime).pop(); - if (!erDate || !erTimePeriod) { - return result; - } - - let prDate = this.config.dateParser.parse(erDate, referenceTime); - let prTimePeriod = this.config.timePeriodParser.parse(erTimePeriod, referenceTime); - - let split = prTimePeriod.timexStr.split('T'); - if (split.length !== 4) { - return result; - } - - let beginTime: Date = prTimePeriod.value.futureValue.item1; - let endTime: Date = prTimePeriod.value.futureValue.item2; - - let futureDate: Date = prDate.value.futureValue; - let pastDate: Date = prDate.value.pastValue; - - result.futureValue = [ - DateUtils.safeCreateFromMinValueWithDateAndTime(futureDate, beginTime), - DateUtils.safeCreateFromMinValueWithDateAndTime(futureDate, endTime) - ]; - result.pastValue = [ - DateUtils.safeCreateFromMinValueWithDateAndTime(pastDate, beginTime), - DateUtils.safeCreateFromMinValueWithDateAndTime(pastDate, endTime) - ]; - let dateTimex = prDate.timexStr; - result.timex = `${split[0]}${dateTimex}T${split[1]}${dateTimex}T${split[2]}T${split[3]}`; - result.success = true; - - return result; - } - - protected mergeTwoTimePoints(text: string, referenceTime: Date): DateTimeResolutionResult { - let result = new DateTimeResolutionResult(); - let prs: { begin: DateTimeParseResult, end: DateTimeParseResult }; - let timeErs = this.config.timeExtractor.extract(text, referenceTime); - let datetimeErs = this.config.dateTimeExtractor.extract(text, referenceTime); - let bothHasDate = false; - let beginHasDate = false; - let endHasDate = false; - - if (datetimeErs.length === 2) { - prs = this.getTwoPoints(datetimeErs[0], datetimeErs[1], this.config.dateTimeParser, this.config.dateTimeParser, referenceTime); - bothHasDate = true; - } - else if (datetimeErs.length === 1 && timeErs.length === 2) { - if (ExtractResult.isOverlap(datetimeErs[0], timeErs[0])) { - prs = this.getTwoPoints(datetimeErs[0], timeErs[1], this.config.dateTimeParser, this.config.timeParser, referenceTime); - beginHasDate = true; - } - else { - prs = this.getTwoPoints(timeErs[0], datetimeErs[0], this.config.timeParser, this.config.dateTimeParser, referenceTime); - endHasDate = true; - } - } - else if (datetimeErs.length === 1 && timeErs.length === 1) { - if (timeErs[0].start < datetimeErs[0].start) { - prs = this.getTwoPoints(timeErs[0], datetimeErs[0], this.config.timeParser, this.config.dateTimeParser, referenceTime); - endHasDate = true; - } - else { - prs = this.getTwoPoints(datetimeErs[0], timeErs[0], this.config.dateTimeParser, this.config.timeParser, referenceTime); - beginHasDate = true; - } - } - if (!prs || !prs.begin.value || !prs.end.value) { - return result; - } - - let futureBegin: Date = prs.begin.value.futureValue; - let futureEnd: Date = prs.end.value.futureValue; - let pastBegin: Date = prs.begin.value.pastValue; - let pastEnd: Date = prs.end.value.pastValue; - - if (futureBegin.getTime() > futureEnd.getTime()) { - futureBegin = pastBegin; - } - if (pastEnd.getTime() < pastBegin.getTime()) { - pastEnd = futureEnd; - } - - let rightTime = DateUtils.safeCreateFromMinValueWithDateAndTime(referenceTime); - let leftTime = DateUtils.safeCreateFromMinValueWithDateAndTime(referenceTime); - - if (bothHasDate) { - rightTime = DateUtils.safeCreateFromMinValueWithDateAndTime(futureEnd); - leftTime = DateUtils.safeCreateFromMinValueWithDateAndTime(futureBegin); - } - else if (beginHasDate) { - // TODO: Handle "明天下午两点到五点" - futureEnd = DateUtils.safeCreateFromMinValueWithDateAndTime(futureBegin, futureEnd); - pastEnd = DateUtils.safeCreateFromMinValueWithDateAndTime(pastBegin, pastEnd); - leftTime = DateUtils.safeCreateFromMinValueWithDateAndTime(futureBegin); - } - else if (endHasDate) { - // TODO: Handle "明天下午两点到五点" - futureBegin = DateUtils.safeCreateFromMinValueWithDateAndTime(futureEnd, futureBegin); - pastBegin = DateUtils.safeCreateFromMinValueWithDateAndTime(pastEnd, pastBegin); - rightTime = DateUtils.safeCreateFromMinValueWithDateAndTime(futureEnd); - } - - let leftResult: DateTimeResolutionResult = prs.begin.value; - let rightResult: DateTimeResolutionResult = prs.end.value; - let leftResultTime: Date = leftResult.futureValue; - let rightResultTime: Date = rightResult.futureValue; - - leftTime = DateUtils.addTime(leftTime, leftResultTime); - rightTime = DateUtils.addTime(rightTime, rightResultTime); - - // the right side time contains "ampm", while the left side doesn't - if (rightResult.comment === 'ampm' && !leftResult.comment && rightTime.getTime() < leftTime.getTime()) { - rightTime = DateUtils.addHours(rightTime, 12); - } - - if (rightTime.getTime() < leftTime.getTime()) { - rightTime = DateUtils.addDays(rightTime, 1); - } - - result.futureValue = [leftTime, rightTime]; - result.pastValue = [leftTime, rightTime]; - - let leftTimex = prs.begin.timexStr; - let rightTimex = prs.end.timexStr; - if (beginHasDate) { - rightTimex = DateTimeFormatUtil.luisDateShortTime(rightTime, rightTimex); - } - else if (endHasDate) { - leftTimex = DateTimeFormatUtil.luisDateShortTime(leftTime, leftTimex); - } - let durationTimex = DateTimeFormatUtil.luisTimeSpan(leftTime, rightTime); - - result.timex = `(${leftTimex},${rightTimex},${durationTimex})`; - result.success = true; - - return result; - } - - protected parseSpecificTimeOfDay(text: string, referenceTime: Date): DateTimeResolutionResult { - let result = new DateTimeResolutionResult(); - let source = text.trim().toLowerCase(); - - let match = RegExpUtility.getMatches(this.config.specificTimeOfDayRegex, source).pop(); - if (match && match.index === 0 && match.length === source.length) { - let values = this.config.getMatchedTimeRange(source); - if (!values.success) { - return result; - } - let swift = (values as any).swift; - - let date = DateUtils.addDays(referenceTime, swift); - date.setHours(0); - date.setMinutes(0); - date.setSeconds(0); - - result.timex = DateTimeFormatUtil.formatDate(date) + values.timeStr; - result.futureValue = [ - DateUtils.safeCreateFromMinValue(date.getFullYear(), date.getMonth(), date.getDate(), values.beginHour, 0, 0), - DateUtils.safeCreateFromMinValue(date.getFullYear(), date.getMonth(), date.getDate(), values.endHour, values.endMin, values.endMin) - ]; - result.pastValue = [ - DateUtils.safeCreateFromMinValue(date.getFullYear(), date.getMonth(), date.getDate(), values.beginHour, 0, 0), - DateUtils.safeCreateFromMinValue(date.getFullYear(), date.getMonth(), date.getDate(), values.endHour, values.endMin, values.endMin) - ]; - result.success = true; - return result; - } - - let beginHour = 0; - let endHour = 0; - let endMin = 0; - let timeStr = ''; - - // handle morning, afternoon.. - if (RegExpUtility.isMatch(this.TMORegex, source)) { - timeStr = 'TMO'; - beginHour = 8; - endHour = 12; - } - else if (RegExpUtility.isMatch(this.TMIRegex, source)) { - timeStr = 'TMI'; - beginHour = 11; - endHour = 13; - } - else if (RegExpUtility.isMatch(this.TAFRegex, source)) { - timeStr = 'TAF'; - beginHour = 12; - endHour = 16; - } - else if (RegExpUtility.isMatch(this.TEVRegex, source)) { - timeStr = 'TEV'; - beginHour = 16; - endHour = 20; - } - else if (RegExpUtility.isMatch(this.TNIRegex, source)) { - timeStr = 'TNI'; - beginHour = 20; - endHour = 23; - endMin = 59; - } - else { - return result; - } - - // handle Date followed by morning, afternoon - let timeMatch = RegExpUtility.getMatches(this.timeOfDayRegex, source).pop(); - if (!timeMatch) { - return result; - } - - let beforeStr = source.substr(0, timeMatch.index).trim(); - let erDate = this.config.dateExtractor.extract(beforeStr, referenceTime).pop(); - if (!erDate || erDate.length !== beforeStr.length) { - return result; - } - - let prDate = this.config.dateParser.parse(erDate, referenceTime); - let futureDate: Date = prDate.value.futureValue; - let pastDate: Date = prDate.value.pastValue; - - result.timex = prDate.timexStr + timeStr; - result.futureValue = [ - DateUtils.safeCreateFromMinValue(futureDate.getFullYear(), futureDate.getMonth(), futureDate.getDate(), beginHour, 0, 0), - DateUtils.safeCreateFromMinValue(futureDate.getFullYear(), futureDate.getMonth(), futureDate.getDate(), endHour, endMin, endMin) - ]; - result.pastValue = [ - DateUtils.safeCreateFromMinValue(pastDate.getFullYear(), pastDate.getMonth(), pastDate.getDate(), beginHour, 0, 0), - DateUtils.safeCreateFromMinValue(pastDate.getFullYear(), pastDate.getMonth(), pastDate.getDate(), endHour, endMin, endMin) - ]; - result.success = true; - - return result; - } - - protected parseNumberWithUnit(text: string, referenceTime: Date): DateTimeResolutionResult { - let result = new DateTimeResolutionResult(); - let ers = this.cardinalExtractor.extract(text); - - if (ers.length === 1) { - let er = ers[0]; - - let pr = this.cardinalParser.parse(er); - let sourceUnit = text.substr(er.start + er.length).trim().toLowerCase(); - if (sourceUnit.startsWith('个')) { - sourceUnit = sourceUnit.substr(1); - } - - let beforeStr = text.substr(0, er.start).trim().toLowerCase(); - - return this.parseCommonDurationWithUnit(beforeStr, sourceUnit, pr.resolutionStr, pr.value, referenceTime); - } - - // handle "last hour" - let match = RegExpUtility.getMatches(this.unitRegex, text).pop(); - - if (match) { - let srcUnit = match.groups('unit').value; - let beforeStr = text.substr(0, match.index).trim().toLowerCase(); - - return this.parseCommonDurationWithUnit(beforeStr, srcUnit, '1', 1, referenceTime); - } - - return result; - } - - protected parseDuration(text: string, referenceTime: Date): DateTimeResolutionResult { - let result = new DateTimeResolutionResult(); - let match = RegExpUtility.getMatches(this.config.relativeTimeUnitRegex, text).pop(); - if (!match) { - return result; - } - - let sourceUnit = match.groups('unit').value.toLowerCase(); - let beforeStr = text.substr(0, match.index).trim().toLowerCase(); - - return this.parseCommonDurationWithUnit(beforeStr, sourceUnit, '1', 1, referenceTime); - } - - private parseCommonDurationWithUnit(beforeStr: string, sourceUnit: string, numStr: string, swift: number, referenceDate: Date): DateTimeResolutionResult { - let result = new DateTimeResolutionResult(); - - if (!this.config.unitMap.has(sourceUnit)) { - return result; - } - - let unitStr = this.config.unitMap.get(sourceUnit); - - let pastMatch = RegExpUtility.getMatches(this.config.pastRegex, beforeStr).pop(); - let hasPast = pastMatch && pastMatch.length === beforeStr.length; - - let futureMatch = RegExpUtility.getMatches(this.config.futureRegex, beforeStr).pop(); - let hasFuture = futureMatch && futureMatch.length === beforeStr.length; - - if (!hasPast && !hasFuture) { - return result; - } - - let beginDate = new Date(referenceDate); - let endDate = new Date(referenceDate); - - switch (unitStr) { - case 'H': - beginDate = hasPast ? DateUtils.addHours(beginDate, -swift) : beginDate; - endDate = hasFuture ? DateUtils.addHours(endDate, swift) : endDate; - break; - case 'M': - beginDate = hasPast ? DateUtils.addMinutes(beginDate, -swift) : beginDate; - endDate = hasFuture ? DateUtils.addMinutes(endDate, swift) : endDate; - break; - case 'S': - beginDate = hasPast ? DateUtils.addSeconds(beginDate, -swift) : beginDate; - endDate = hasFuture ? DateUtils.addSeconds(endDate, swift) : endDate; - break; - default: return result; - } - - let beginTimex = `${DateTimeFormatUtil.luisDateFromDate(beginDate)}T${DateTimeFormatUtil.luisTimeFromDate(beginDate)}`; - let endTimex = `${DateTimeFormatUtil.luisDateFromDate(endDate)}T${DateTimeFormatUtil.luisTimeFromDate(endDate)}`; - result.timex = `(${beginTimex},${endTimex},PT${numStr}${unitStr.charAt(0)})`; - result.futureValue = [beginDate, endDate]; - result.pastValue = [beginDate, endDate]; - result.success = true; - - return result; - } -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-date-time/src/dateTime/chinese/durationConfiguration.ts b/JavaScript/packages/recognizers-date-time/src/dateTime/chinese/durationConfiguration.ts deleted file mode 100644 index 3d086f6d13..0000000000 --- a/JavaScript/packages/recognizers-date-time/src/dateTime/chinese/durationConfiguration.ts +++ /dev/null @@ -1,141 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { RegExpUtility, ExtractResult } from "@microsoft/recognizers-text"; -import { CultureInfo, Culture, BaseNumberExtractor, BaseNumberParser } from "@microsoft/recognizers-text-number"; -import { ChineseNumberWithUnitExtractorConfiguration, NumberWithUnitExtractor, NumberWithUnitParser, ChineseNumberWithUnitParserConfiguration, UnitValue } from "@microsoft/recognizers-text-number-with-unit"; -import { BaseDateTimeExtractor } from "./baseDateTime"; -import { IDurationParserConfiguration, BaseDurationParser } from "../baseDuration"; -import { Constants, TimeTypeConstants } from "../constants"; -import { ChineseDateTime } from "../../resources/chineseDateTime"; -import { IDateTimeParser, DateTimeParseResult } from "../parsers"; -import { DateTimeResolutionResult, StringMap } from "../utilities"; - -export enum DurationType { - WithNumber -} - -class DurationExtractorConfiguration extends ChineseNumberWithUnitExtractorConfiguration { - readonly suffixList: ReadonlyMap; - readonly prefixList: ReadonlyMap; - readonly ambiguousUnitList: readonly string[]; - readonly extractType: string; - - constructor() { - super(new CultureInfo(Culture.Chinese)); - - this.extractType = Constants.SYS_DATETIME_DURATION; - this.suffixList = ChineseDateTime.DurationSuffixList; - this.prefixList = new Map(); - this.ambiguousUnitList = ChineseDateTime.DurationAmbiguousUnits; - } -} - -export class ChineseDurationExtractor extends BaseDateTimeExtractor { - protected extractorName = Constants.SYS_DATETIME_DURATION; // "Duration"; - private readonly extractor: NumberWithUnitExtractor; - private readonly yearRegex: RegExp; - private readonly halfSuffixRegex: RegExp; - - constructor() { - super(null); - this.extractor = new NumberWithUnitExtractor(new DurationExtractorConfiguration()); - this.yearRegex = RegExpUtility.getSafeRegExp(ChineseDateTime.DurationYearRegex); - this.halfSuffixRegex = RegExpUtility.getSafeRegExp(ChineseDateTime.DurationHalfSuffixRegex); - } - - extract(source: string, refDate: Date): ExtractResult[] { - if (!refDate) { - refDate = new Date(); - } - let referenceDate = refDate; - - let results = new Array(); - this.extractor.extract(source).forEach(result => { - // filter - if (RegExpUtility.isMatch(this.yearRegex, result.text)) { - return; - } - - // match suffix - let suffix = source.substr(result.start + result.length); - - results.push(result); - }); - - return results; - } -} - -class ChineseDurationParserConfiguration implements IDurationParserConfiguration { - readonly cardinalExtractor: BaseNumberExtractor; - readonly numberParser: BaseNumberParser; - readonly followedUnit: RegExp; - readonly suffixAndRegex: RegExp; - readonly numberCombinedWithUnit: RegExp; - readonly anUnitRegex: RegExp; - readonly allDateUnitRegex: RegExp; - readonly halfDateUnitRegex: RegExp; - readonly inexactNumberUnitRegex: RegExp; - readonly unitMap: ReadonlyMap; - readonly unitValueMap: ReadonlyMap; - readonly doubleNumbers: ReadonlyMap; - - constructor() { - this.unitValueMap = ChineseDateTime.DurationUnitValueMap; - } -} - -class DurationParserConfiguration extends ChineseNumberWithUnitParserConfiguration { - constructor() { - super(new CultureInfo(Culture.Chinese)); - this.BindDictionary(ChineseDateTime.DurationSuffixList); - } -} - -export class ChineseDurationParser extends BaseDurationParser { - private readonly internalParser: NumberWithUnitParser - - constructor() { - let config = new ChineseDurationParserConfiguration(); - super(config); - this.internalParser = new NumberWithUnitParser(new DurationParserConfiguration()); - } - - parse(extractorResult: ExtractResult, referenceDate?: Date): DateTimeParseResult | null { - if (!referenceDate) { - referenceDate = new Date(); - } - let resultValue; - if (extractorResult.type === this.parserName) { - let innerResult = new DateTimeResolutionResult(); - - let parserResult = this.internalParser.parse(extractorResult); - let unitResult: UnitValue = parserResult.value; - if (!unitResult) { - return new DateTimeParseResult(); - } - - let unitStr = unitResult.unit; - let numberStr = unitResult.number; - - innerResult.timex = `P${this.isLessThanDay(unitStr) ? 'T' : ''}${numberStr}${unitStr.charAt(0)}`; - innerResult.futureValue = Number.parseFloat(numberStr) * this.config.unitValueMap.get(unitStr); - innerResult.pastValue = Number.parseFloat(numberStr) * this.config.unitValueMap.get(unitStr); - innerResult.futureResolution = {}; - innerResult.futureResolution[TimeTypeConstants.DURATION] = innerResult.futureValue.toString(); - innerResult.pastResolution = {}; - innerResult.pastResolution[TimeTypeConstants.DURATION] = innerResult.pastValue.toString(); - innerResult.success = true; - - resultValue = innerResult; - } - - let result = new DateTimeParseResult(extractorResult); - result.value = resultValue; - result.timexStr = resultValue ? resultValue.timex : ''; - result.resolutionStr = ''; - - return result; - } -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-date-time/src/dateTime/chinese/holidayConfiguration.ts b/JavaScript/packages/recognizers-date-time/src/dateTime/chinese/holidayConfiguration.ts deleted file mode 100644 index e74bbaedb4..0000000000 --- a/JavaScript/packages/recognizers-date-time/src/dateTime/chinese/holidayConfiguration.ts +++ /dev/null @@ -1,327 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { RegExpUtility, Match, StringUtility, IExtractor, IParser, ExtractResult } from "@microsoft/recognizers-text"; -import { IHolidayExtractorConfiguration, BaseHolidayParserConfiguration, BaseHolidayParser } from "../baseHoliday"; -import { ChineseIntegerExtractor, AgnosticNumberParserFactory, AgnosticNumberParserType, ChineseNumberParserConfiguration } from "@microsoft/recognizers-text-number"; -import { Constants as NumberConstants } from "@microsoft/recognizers-text-number"; -import { DateUtils, DateTimeFormatUtil, DateTimeResolutionResult, StringMap } from "../utilities"; -import { ChineseDateTime } from "../../resources/chineseDateTime"; -import { IDateTimeParser, DateTimeParseResult } from "../parsers"; -import { Constants, TimeTypeConstants } from "../constants"; - -export class ChineseHolidayExtractorConfiguration implements IHolidayExtractorConfiguration { - readonly holidayRegexes: RegExp[] - - constructor() { - this.holidayRegexes = [ - RegExpUtility.getSafeRegExp(ChineseDateTime.HolidayRegexList1), - RegExpUtility.getSafeRegExp(ChineseDateTime.HolidayRegexList2), - RegExpUtility.getSafeRegExp(ChineseDateTime.LunarHolidayRegex) - ]; - } -} - -class ChineseHolidayParserConfiguration extends BaseHolidayParserConfiguration { - constructor() { - super(); - this.holidayRegexList = [ - RegExpUtility.getSafeRegExp(ChineseDateTime.HolidayRegexList1), - RegExpUtility.getSafeRegExp(ChineseDateTime.HolidayRegexList2), - RegExpUtility.getSafeRegExp(ChineseDateTime.LunarHolidayRegex) - ]; - this.holidayFuncDictionary = this.initHolidayFuncs(); - this.variableHolidaysTimexDictionary = ChineseDateTime.HolidayNoFixedTimex; - } - - getSwiftYear(source: string): number { - if (source.endsWith('年')) { - return 0; - } - if (source.endsWith('去年')) { - return -1; - } - if (source.endsWith('明年')) { - return 1; - } - return null; - } - - sanitizeHolidayToken(holiday: string): string { - return holiday; - } - - protected initHolidayFuncs(): ReadonlyMap Date> { - return new Map Date>([ - ...super.initHolidayFuncs(), - ['父亲节', BaseHolidayParserConfiguration.FathersDay], - ['母亲节', BaseHolidayParserConfiguration.MothersDay], - ['感恩节', BaseHolidayParserConfiguration.ThanksgivingDay] - ]); - } -} - -export class ChineseHolidayParser extends BaseHolidayParser { - private readonly lunarHolidayRegex; RegExp; - private readonly integerExtractor: IExtractor; - private readonly numberParser: IParser; - private readonly fixedHolidayDictionary: Map Date>; - - constructor() { - let config = new ChineseHolidayParserConfiguration(); - super(config); - this.lunarHolidayRegex = RegExpUtility.getSafeRegExp(ChineseDateTime.LunarHolidayRegex); - this.integerExtractor = new ChineseIntegerExtractor(); - this.numberParser = AgnosticNumberParserFactory.getParser(AgnosticNumberParserType.Integer, new ChineseNumberParserConfiguration()); - this.fixedHolidayDictionary = new Map Date>([ - ['元旦', ChineseHolidayParser.NewYear], - ['元旦节', ChineseHolidayParser.NewYear], - ['教师节', ChineseHolidayParser.TeacherDay], - ['青年节', ChineseHolidayParser.YouthDay], - ['儿童节', ChineseHolidayParser.ChildrenDay], - ['妇女节', ChineseHolidayParser.FemaleDay], - ['植树节', ChineseHolidayParser.TreePlantDay], - ['情人节', ChineseHolidayParser.LoverDay], - ['平安夜', ChineseHolidayParser.ChristmasEve], - ['圣诞节', ChineseHolidayParser.ChristmasDay], - ['新年', ChineseHolidayParser.NewYear], - ['愚人节', ChineseHolidayParser.FoolDay], - ['五一', ChineseHolidayParser.LaborDay], - ['劳动节', ChineseHolidayParser.LaborDay], - ['万圣节', ChineseHolidayParser.HalloweenDay], - ['中秋节', ChineseHolidayParser.MidautumnDay], - ['中秋', ChineseHolidayParser.MidautumnDay], - ['春节', ChineseHolidayParser.SpringDay], - ['除夕', ChineseHolidayParser.NewYearEve], - ['元宵节', ChineseHolidayParser.LanternDay], - ['清明节', ChineseHolidayParser.QingMingDay], - ['清明', ChineseHolidayParser.QingMingDay], - ['端午节', ChineseHolidayParser.DragonBoatDay], - ['端午', ChineseHolidayParser.DragonBoatDay], - ['国庆节', ChineseHolidayParser.ChsNationalDay], - ['建军节', ChineseHolidayParser.ChsMilBuildDay], - ['女生节', ChineseHolidayParser.GirlsDay], - ['光棍节', ChineseHolidayParser.SinglesDay], - ['双十一', ChineseHolidayParser.SinglesDay], - ['重阳节', ChineseHolidayParser.ChongYangDay] - ]); - } - - private static NewYear(year: number): Date { - return new Date(year, 1 - 1, 1); - } - private static ChsNationalDay(year: number): Date { - return new Date(year, 10 - 1, 1); - } - private static LaborDay(year: number): Date { - return new Date(year, 5 - 1, 1); - } - private static ChristmasEve(year: number): Date { - return new Date(year, 12 - 1, 24); - } - private static ChristmasDay(year: number): Date { - return new Date(year, 12 - 1, 25); - } - private static LoverDay(year: number): Date { - return new Date(year, 2 - 1, 14); - } - private static ChsMilBuildDay(year: number): Date { - return new Date(year, 8 - 1, 1); - } - private static FoolDay(year: number): Date { - return new Date(year, 4 - 1, 1); - } - private static GirlsDay(year: number): Date { - return new Date(year, 3 - 1, 7); - } - private static TreePlantDay(year: number): Date { - return new Date(year, 3 - 1, 12); - } - private static FemaleDay(year: number): Date { - return new Date(year, 3 - 1, 8); - } - private static ChildrenDay(year: number): Date { - return new Date(year, 6 - 1, 1); - } - private static YouthDay(year: number): Date { - return new Date(year, 5 - 1, 4); - } - private static TeacherDay(year: number): Date { - return new Date(year, 9 - 1, 10); - } - private static SinglesDay(year: number): Date { - return new Date(year, 11 - 1, 11); - } - private static HalloweenDay(year: number): Date { - return new Date(year, 10 - 1, 31); - } - private static MidautumnDay(year: number): Date { - return new Date(year, 8 - 1, 15); - } - private static SpringDay(year: number): Date { - return new Date(year, 1 - 1, 1); - } - private static NewYearEve(year: number): Date { - return DateUtils.addDays(new Date(year, 1 - 1, 1), -1); - } - private static LanternDay(year: number): Date { - return new Date(year, 1 - 1, 15); - } - private static QingMingDay(year: number): Date { - return new Date(year, 4 - 1, 4); - } - private static DragonBoatDay(year: number): Date { - return new Date(year, 5 - 1, 5); - } - private static ChongYangDay(year: number): Date { - return new Date(year, 9 - 1, 9); - } - - parse(er: ExtractResult, referenceDate?: Date): DateTimeParseResult { - if (!referenceDate) { - referenceDate = new Date(); - } - let value = null; - - if (er.type === BaseHolidayParser.ParserName) { - let innerResult = this.parseHolidayRegexMatch(er.text, referenceDate); - - if (innerResult.success) { - innerResult.futureResolution = {}; - innerResult.futureResolution[TimeTypeConstants.DATE] = DateTimeFormatUtil.formatDate(innerResult.futureValue); - innerResult.pastResolution = {}; - innerResult.pastResolution[TimeTypeConstants.DATE] = DateTimeFormatUtil.formatDate(innerResult.pastValue); - innerResult.isLunar = this.isLunar(er.text); - value = innerResult; - } - } - - let ret = new DateTimeParseResult(er); - ret.value = value; - ret.timexStr = value === null ? "" : value.timex; - ret.resolutionStr = ""; - - return ret; - } - - private isLunar(source: string): boolean { - return RegExpUtility.isMatch(this.lunarHolidayRegex, source); - } - - protected match2Date(match: Match, referenceDate: Date): DateTimeResolutionResult { - let ret = new DateTimeResolutionResult(); - - let holidayStr = this.config.sanitizeHolidayToken(match.groups("holiday").value.toLowerCase()); - if (StringUtility.isNullOrEmpty(holidayStr)) { - return ret; - } - - // get year (if exist) - let year = referenceDate.getFullYear(); - let yearNum = match.groups('year').value; - let yearChinese = match.groups(Constants.yearCJK).value; - let yearRelative = match.groups('yearrel').value; - let hasYear = false; - - if (!StringUtility.isNullOrEmpty(yearNum)) { - hasYear = true; - if (this.config.getSwiftYear(yearNum) === 0) { - yearNum = yearNum.substr(0, yearNum.length - 1); - } - year = this.convertYear(yearNum, false); - } - else if (!StringUtility.isNullOrEmpty(yearChinese)) { - hasYear = true; - if (this.config.getSwiftYear(yearChinese) === 0) { - yearChinese = yearChinese.substr(0, yearChinese.length - 1); - } - year = this.convertYear(yearChinese, true); - } - else if (!StringUtility.isNullOrEmpty(yearRelative)) { - hasYear = true; - year += this.config.getSwiftYear(yearRelative); - } - - if (year < 100 && year >= Constants.MaxTwoDigitYearFutureNum) { - year += 1900; - } - else if (year < 100 && year < Constants.MinTwoDigitYearPastNum) { - year += 2000; - } - - let timex = ''; - let date = new Date(referenceDate); - if (this.fixedHolidayDictionary.has(holidayStr)) { - date = this.fixedHolidayDictionary.get(holidayStr)(year); - timex = `-${DateTimeFormatUtil.toString(date.getMonth() + 1, 2)}-${DateTimeFormatUtil.toString(date.getDate(), 2)}`; - } - else if (this.config.holidayFuncDictionary.has(holidayStr)) { - date = this.config.holidayFuncDictionary.get(holidayStr)(year); - timex = this.config.variableHolidaysTimexDictionary.get(holidayStr); - } - else { - return ret; - } - - if (hasYear) { - ret.timex = DateTimeFormatUtil.toString(year, 4) + timex; - ret.futureValue = new Date(year, date.getMonth(), date.getDate()); - ret.pastValue = new Date(year, date.getMonth(), date.getDate()); - } - else { - ret.timex = "XXXX" + timex; - ret.futureValue = this.getDateValue(date, referenceDate, holidayStr, 1, (d, r) => d.getTime() < r.getTime()); - ret.pastValue = this.getDateValue(date, referenceDate, holidayStr, -1, (d, r) => d.getTime() >= r.getTime()); - } - - ret.success = true; - - return ret; - } - - private convertYear(yearStr: string, isChinese: boolean): number { - let year = -1; - let er: ExtractResult; - if (isChinese) { - let yearNum = 0; - er = this.integerExtractor.extract(yearStr).pop(); - if (er && er.type === NumberConstants.SYS_NUM_INTEGER) { - yearNum = Number.parseInt(this.numberParser.parse(er).value); - } - - if (yearNum < 10) { - yearNum = 0; - for (let index = 0; index < yearStr.length; index++) { - let char = yearStr.charAt[index]; - yearNum *= 10; - er = this.integerExtractor.extract(char).pop(); - if (er && er.type === NumberConstants.SYS_NUM_INTEGER) { - yearNum += Number.parseInt(this.numberParser.parse(er).value); - } - } - } - else { - year = yearNum; - } - } - else { - year = Number.parseInt(yearStr, 10); - } - - return year === 0 ? -1 : year; - } - - private getDateValue(date: Date, referenceDate: Date, holiday: string, swift: number, comparer: (date: Date, referenceDate: Date) => boolean): Date { - let result = new Date(date); - if (comparer(date, referenceDate)) { - if (this.fixedHolidayDictionary.has(holiday)) { - return DateUtils.addYears(date, swift); - } - if (this.config.holidayFuncDictionary.has(holiday)) { - result = this.config.holidayFuncDictionary.get(holiday)(referenceDate.getFullYear() + swift); - } - } - - return result; - } -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-date-time/src/dateTime/chinese/mergedConfiguration.ts b/JavaScript/packages/recognizers-date-time/src/dateTime/chinese/mergedConfiguration.ts deleted file mode 100644 index 37e47c884c..0000000000 --- a/JavaScript/packages/recognizers-date-time/src/dateTime/chinese/mergedConfiguration.ts +++ /dev/null @@ -1,577 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { IMergedExtractorConfiguration, BaseMergedExtractor, IMergedParserConfiguration, BaseMergedParser } from "../baseMerged"; -import { BaseDateExtractor, BaseDateParser } from "../baseDate"; -import { BaseTimeExtractor, BaseTimeParser } from "../baseTime"; -import { BaseSetExtractor, BaseSetParser } from "../baseSet"; -import { BaseHolidayExtractor, BaseHolidayParser } from "../baseHoliday"; -import { BaseDatePeriodExtractor, BaseDatePeriodParser } from "../baseDatePeriod"; -import { BaseTimePeriodExtractor, BaseTimePeriodParser } from "../baseTimePeriod"; -import { BaseDateTimeExtractor, BaseDateTimeParser } from "../baseDateTime"; -import { BaseDateTimePeriodExtractor, BaseDateTimePeriodParser } from "../baseDateTimePeriod"; -import { BaseDurationExtractor, BaseDurationParser } from "../baseDuration"; -import { ExtractResult, RegExpUtility, MetaData } from "@microsoft/recognizers-text"; -import { BaseNumberExtractor } from "@microsoft/recognizers-text-number"; -import { ChineseDateTime } from "../../resources/chineseDateTime"; -import { ChineseDurationExtractor, ChineseDurationParser } from "./durationConfiguration"; -import { ChineseTimeExtractor, ChineseTimeParser } from "./timeConfiguration"; -import { ChineseDateExtractor, ChineseDateParser } from "./dateConfiguration"; -import { ChineseDateTimeExtractor, ChineseDateTimeParser } from "./dateTimeConfiguration"; -import { ChineseTimePeriodExtractor, ChineseTimePeriodParser } from "./timePeriodConfiguration"; -import { ChineseDatePeriodExtractor, ChineseDatePeriodParser } from "./datePeriodConfiguration"; -import { ChineseDateTimePeriodExtractor, ChineseDateTimePeriodParser } from "./dateTimePeriodConfiguration"; -import { ChineseSetExtractor, ChineseSetParser } from "./setConfiguration"; -import { ChineseHolidayExtractorConfiguration, ChineseHolidayParser } from "./holidayConfiguration"; -import { DateTimeOptions } from "../dateTimeRecognizer"; -import { IDateTimeParser, DateTimeParseResult } from "../parsers"; -import { Constants, TimeTypeConstants } from "../constants"; -import { DateTimeFormatUtil, DateUtils, DateTimeResolutionResult, StringMap } from "../utilities"; -import isEqual = require('lodash.isequal'); - -class ChineseMergedExtractorConfiguration implements IMergedExtractorConfiguration { - readonly dateExtractor: BaseDateExtractor - readonly timeExtractor: ChineseTimeExtractor - readonly dateTimeExtractor: BaseDateTimeExtractor - readonly datePeriodExtractor: BaseDatePeriodExtractor - readonly timePeriodExtractor: ChineseTimePeriodExtractor - readonly dateTimePeriodExtractor: BaseDateTimePeriodExtractor - readonly holidayExtractor: BaseHolidayExtractor - readonly durationExtractor: ChineseDurationExtractor - readonly setExtractor: BaseSetExtractor - readonly integerExtractor: BaseNumberExtractor - readonly afterRegex: RegExp - readonly beforeRegex: RegExp - readonly sinceRegex: RegExp - readonly fromToRegex: RegExp - readonly singleAmbiguousMonthRegex: RegExp - readonly prepositionSuffixRegex: RegExp - readonly ambiguousRangeModifierPrefix: RegExp - readonly potentialAmbiguousRangeRegex: RegExp - readonly numberEndingPattern: RegExp - readonly unspecificDatePeriodRegex: RegExp - readonly filterWordRegexList: RegExp[] - readonly AmbiguityFiltersDict: Map - - constructor(dmyDateFormat: boolean) { - this.dateExtractor = new ChineseDateExtractor(dmyDateFormat); - this.timeExtractor = new ChineseTimeExtractor(); - this.dateTimeExtractor = new ChineseDateTimeExtractor(dmyDateFormat); - this.datePeriodExtractor = new ChineseDatePeriodExtractor(dmyDateFormat); - this.timePeriodExtractor = new ChineseTimePeriodExtractor(); - this.dateTimePeriodExtractor = new ChineseDateTimePeriodExtractor(dmyDateFormat); - this.setExtractor = new ChineseSetExtractor(dmyDateFormat); - this.holidayExtractor = new BaseHolidayExtractor(new ChineseHolidayExtractorConfiguration()); - this.durationExtractor = new ChineseDurationExtractor(); - this.beforeRegex = RegExpUtility.getSafeRegExp(ChineseDateTime.ParserConfigurationBefore); - this.afterRegex = RegExpUtility.getSafeRegExp(ChineseDateTime.ParserConfigurationAfter); - } -} - -export class ChineseMergedExtractor extends BaseMergedExtractor { - private readonly dayOfMonthRegex: RegExp; - private readonly sincePrefixRegex: RegExp - private readonly sinceSuffixRegex: RegExp - - constructor(options: DateTimeOptions, dmyDateFormat: boolean = false) { - let config = new ChineseMergedExtractorConfiguration(dmyDateFormat); - super(config, options); - this.dayOfMonthRegex = RegExpUtility.getSafeRegExp(`^\\d{1,2}号`, 'gi'); - this.sincePrefixRegex = RegExpUtility.getSafeRegExp(ChineseDateTime.ParserConfigurationSincePrefix); - this.sinceSuffixRegex = RegExpUtility.getSafeRegExp(ChineseDateTime.ParserConfigurationSinceSuffix); - } - - extract(source: string, refDate: Date): ExtractResult[] { - if (!refDate) { - refDate = new Date(); - } - let referenceDate = refDate; - - let result: ExtractResult[] = new Array(); - this.addTo(result, this.config.dateExtractor.extract(source, referenceDate), source); - this.addTo(result, this.config.timeExtractor.extract(source, referenceDate), source); - this.addTo(result, this.config.durationExtractor.extract(source, referenceDate), source); - this.addTo(result, this.config.datePeriodExtractor.extract(source, referenceDate), source); - this.addTo(result, this.config.dateTimeExtractor.extract(source, referenceDate), source); - this.addTo(result, this.config.timePeriodExtractor.extract(source, referenceDate), source); - this.addTo(result, this.config.dateTimePeriodExtractor.extract(source, referenceDate), source); - this.addTo(result, this.config.setExtractor.extract(source, referenceDate), source); - this.addTo(result, this.config.holidayExtractor.extract(source, referenceDate), source); - - result = this.checkBlackList(result, source); - - this.addMod(result, source); - - result = result.sort((a, b) => a.start - b.start); - return result; - } - - protected addTo(destination: ExtractResult[], source: ExtractResult[], sourceStr: string) { - source.forEach(er => { - let isFound = false; - let rmIndex = -1; - let rmLength = 1; - for (let index = 0; index < destination.length; index++) { - if (ExtractResult.isOverlap(destination[index], er)) { - isFound = true; - if (er.length > destination[index].length) { - rmIndex = index; - let j = index + 1; - while (j < destination.length && ExtractResult.isOverlap(destination[j], er)) { - rmLength++; - j++; - } - } - break; - } - } - if (!isFound) { - destination.push(er); - } - else if (rmIndex >= 0) { - destination.splice(rmIndex, rmLength); - destination.splice(0, destination.length, ...this.moveOverlap(destination, er)); - destination.splice(rmIndex, 0, er); - } - }); - } - - protected moveOverlap(destination: ExtractResult[], result: ExtractResult) { - let duplicated = new Array(); - for (let i = 0; i < destination.length; i++) { - if (result.text.includes(destination[i].text) - && (result.start === destination[i].start || result.start + result.length === destination[i].start + destination[i].length)) { - duplicated.push(i); - } - } - return destination.filter((_, i) => duplicated.indexOf(i) < 0); - } - - // ported from CheckBlackList - protected checkBlackList(destination: ExtractResult[], source: string) { - return destination.filter(value => { - let valueEnd = value.start + value.length; - if (valueEnd !== source.length) { - let lastChar = source.substr(valueEnd, 1); - if (value.text.endsWith('周') && lastChar === '岁') { - return false; - } - } - - if (RegExpUtility.isMatch(this.dayOfMonthRegex, value.text)) { - return false; - } - - return true; - }); - } - - protected addMod(ers: ExtractResult[], source: string) { - let lastEnd = 0; - ers.forEach(er => { - let success = this.tryMergeModifierToken(er, this.config.beforeRegex, source); - if (!success) { - success = this.tryMergeModifierToken(er, this.config.afterRegex, source); - } - - if (!success) { - // SinceRegex in English contains the term "from" which is potentially ambiguous with ranges in the form "from X to Y" - success = this.tryMergeModifierToken(er, this.sincePrefixRegex, source, true, true); - success = this.tryMergeModifierToken(er, this.sinceSuffixRegex, source, false, true); - } - }); - } - - protected tryMergeModifierToken(er:ExtractResult, regex: RegExp, source: string, isPrefix: boolean = false, potentialAmbiguity:boolean = false): boolean { - let subStr = isPrefix ? source.substr(0, er.start) : source.substr(er.start + er.length); - - // Avoid adding mod for ambiguity cases, such as "from" in "from ... to ..." should not add mod - if (potentialAmbiguity && this.config.ambiguousRangeModifierPrefix && - RegExpUtility.isMatch(this.config.ambiguousRangeModifierPrefix, subStr)) { - let matches = RegExpUtility.getMatches(this.config.potentialAmbiguousRangeRegex, source); - if (matches.find(m => m.index < er.start + er.length && m.index + m.length > er.start)) { - return false - } - } - - let token = this.hasTokenIndex(subStr.trim(), regex, isPrefix); - if (token.matched) { - let modLength = isPrefix ? subStr.length - token.index : token.index; - er.length += modLength; - er.start -= isPrefix ? modLength : 0; - er.text = source.substr(er.start, er.length); - - er.metaData = this.assignModMetadata(er.metaData); - - return true; - } - - return false; - } - - protected assignModMetadata(metadata: MetaData): MetaData { - - if (metadata === undefined || metadata === null) { - metadata = new MetaData(); - metadata.HasMod = true; - } else { - metadata.HasMod = true; - } - - return metadata - } - - protected hasTokenIndex(source: string, regex: RegExp, isPrefix: boolean = false): { matched: boolean, index: number } { - // This part is different from C# because no Regex RightToLeft option in JS - let result = { matched: false, index: -1 }; - let matchResult = RegExpUtility.getMatches(regex, source); - let index = isPrefix ? matchResult.length - 1 : 0; - let match = matchResult.length > 0 ? matchResult[index]: false; - if (match) { - let leftStr = isPrefix ? source.substr(match.index + match.length).trim() : source.substr(0, match.index).trim() - if (!leftStr.length) { - result.matched = true; - result.index = match.index + (isPrefix ? 0 : match.length); - } - } - return result; - } -} - -class ChineseMergedParserConfiguration implements IMergedParserConfiguration { - readonly beforeRegex: RegExp; - readonly afterRegex: RegExp; - readonly sinceRegex: RegExp; - readonly dateParser: BaseDateParser; - readonly holidayParser: BaseHolidayParser; - readonly timeParser: BaseTimeParser; - readonly dateTimeParser: BaseDateTimeParser; - readonly datePeriodParser: BaseDatePeriodParser; - readonly timePeriodParser: BaseTimePeriodParser; - readonly dateTimePeriodParser: BaseDateTimePeriodParser; - readonly durationParser: BaseDurationParser; - readonly setParser: BaseSetParser; - - constructor(dmyDateFormat: boolean) { - this.beforeRegex = RegExpUtility.getSafeRegExp(ChineseDateTime.ParserConfigurationBefore); - this.afterRegex = RegExpUtility.getSafeRegExp(ChineseDateTime.ParserConfigurationAfter); - - this.dateParser = new ChineseDateParser(dmyDateFormat); - this.holidayParser = new ChineseHolidayParser(); - this.timeParser = new ChineseTimeParser(); - this.dateTimeParser = new ChineseDateTimeParser(dmyDateFormat); - this.datePeriodParser = new ChineseDatePeriodParser(dmyDateFormat); - this.timePeriodParser = new ChineseTimePeriodParser(); - this.dateTimePeriodParser = new ChineseDateTimePeriodParser(dmyDateFormat); - this.durationParser = new ChineseDurationParser(); - this.setParser = new ChineseSetParser(dmyDateFormat); - } -} - -export class ChineseMergedParser extends BaseMergedParser { - constructor(dmyDateFormat: boolean) { - let config = new ChineseMergedParserConfiguration(dmyDateFormat); - super(config, 0); - } - - parse(er: ExtractResult, refTime?: Date): DateTimeParseResult | null { - let referenceTime = refTime || new Date(); - let pr: DateTimeParseResult = null; - - // push, save teh MOD string - let hasBefore = RegExpUtility.isMatch(this.config.beforeRegex, er.text); - let hasAfter = RegExpUtility.isMatch(this.config.afterRegex, er.text); - let hasSince = RegExpUtility.isMatch(this.config.sinceRegex, er.text); - let modStr = ''; - - if (er.type === Constants.SYS_DATETIME_DATE) { - pr = this.config.dateParser.parse(er, referenceTime); - if (pr.value === null || pr.value === undefined) { - pr = this.config.holidayParser.parse(er, referenceTime); - } - } - else if (er.type === Constants.SYS_DATETIME_TIME) { - pr = this.config.timeParser.parse(er, referenceTime); - } - else if (er.type === Constants.SYS_DATETIME_DATETIME) { - pr = this.config.dateTimeParser.parse(er, referenceTime); - } - else if (er.type === Constants.SYS_DATETIME_DATEPERIOD) { - pr = this.config.datePeriodParser.parse(er, referenceTime); - } - else if (er.type === Constants.SYS_DATETIME_TIMEPERIOD) { - pr = this.config.timePeriodParser.parse(er, referenceTime); - } - else if (er.type === Constants.SYS_DATETIME_DATETIMEPERIOD) { - pr = this.config.dateTimePeriodParser.parse(er, referenceTime); - } - else if (er.type === Constants.SYS_DATETIME_DURATION) { - pr = this.config.durationParser.parse(er, referenceTime); - } - else if (er.type === Constants.SYS_DATETIME_SET) { - pr = this.config.setParser.parse(er, referenceTime); - } - else { - return null; - } - - // pop, restore the MOD string - if (hasBefore && pr.value !== null) { - let val = pr.value; - val.mod = TimeTypeConstants.beforeMod; - pr.value = val; - } - - if (hasAfter && pr.value !== null) { - let val = pr.value; - val.mod = TimeTypeConstants.afterMod; - pr.value = val; - } - - if (hasSince && pr.value !== null) { - let val = pr.value; - val.mod = TimeTypeConstants.sinceMod; - pr.value = val; - } - - let hasRangeChangingMod = hasBefore || hasAfter || hasSince; - pr.value = this.dateTimeResolution(pr, hasBefore, hasAfter, hasSince); - pr.type = `${this.parserTypeName}.${this.determineDateTimeType(er.type, hasRangeChangingMod)}`; - - return pr; - } -} - -export class ChineseFullMergedParser extends BaseMergedParser { - private readonly sincePrefixRegex: RegExp; - private readonly sinceSuffixRegex: RegExp; - - constructor(dmyDateFormat: boolean = false) { - let config = new ChineseMergedParserConfiguration(dmyDateFormat); - super(config, 0); - this.sincePrefixRegex = RegExpUtility.getSafeRegExp(ChineseDateTime.ParserConfigurationSincePrefix); - this.sinceSuffixRegex = RegExpUtility.getSafeRegExp(ChineseDateTime.ParserConfigurationSinceSuffix); - } - - parse(er: ExtractResult, refTime?: Date): DateTimeParseResult | null { - let referenceTime = refTime || new Date(); - let pr: DateTimeParseResult = null; - - // push, save teh MOD string - let hasBefore = false; - let hasAfter = false; - let hasSince = false; - let modStr = '', modStrPrefix = '', modStrSuffix = ''; - let erLength = er.length; - - if (er.metaData !== null && er.metaData !== undefined && er.metaData.HasMod) { - let beforeMatch = RegExpUtility.getMatches(this.config.beforeRegex, er.text).shift(); - let afterMatch = RegExpUtility.getMatches(this.config.afterRegex, er.text).shift(); - let sincePrefixMatch = RegExpUtility.getMatches(this.sincePrefixRegex, er.text).shift(); - let sinceSuffixMatch = RegExpUtility.getMatches(this.sinceSuffixRegex, er.text).shift(); - if (beforeMatch && beforeMatch.index + beforeMatch.length === erLength) { - hasBefore = true; - er.length -= beforeMatch.length; - er.text = er.text.substring(0, er.length); - modStr = beforeMatch.value; - } - else if (afterMatch && afterMatch.index + afterMatch.length === erLength) { - hasAfter = true; - er.length -= afterMatch.length; - er.text = er.text.substring(0, er.length); - modStr = afterMatch.value; - } - else { - if (sincePrefixMatch && sincePrefixMatch.index === 0) { - hasSince = true; - er.start += sincePrefixMatch.length; - er.length -= sincePrefixMatch.length; - er.text = er.text.substring(sincePrefixMatch.length); - modStrPrefix = sincePrefixMatch.value; - } - - if (sinceSuffixMatch && sinceSuffixMatch.index + sinceSuffixMatch.length === erLength) { - hasSince = true; - er.length -= sinceSuffixMatch.length; - er.text = er.text.substring(0, er.length); - modStrSuffix = sinceSuffixMatch.value; - } - } - } - - if (er.type === Constants.SYS_DATETIME_DATE) { - pr = this.config.dateParser.parse(er, referenceTime); - if (pr.value === null || pr.value === undefined) { - pr = this.config.holidayParser.parse(er, referenceTime); - } - } - else if (er.type === Constants.SYS_DATETIME_TIME) { - pr = this.config.timeParser.parse(er, referenceTime); - } - else if (er.type === Constants.SYS_DATETIME_DATETIME) { - pr = this.config.dateTimeParser.parse(er, referenceTime); - } - else if (er.type === Constants.SYS_DATETIME_DATEPERIOD) { - pr = this.config.datePeriodParser.parse(er, referenceTime); - } - else if (er.type === Constants.SYS_DATETIME_TIMEPERIOD) { - pr = this.config.timePeriodParser.parse(er, referenceTime); - } - else if (er.type === Constants.SYS_DATETIME_DATETIMEPERIOD) { - pr = this.config.dateTimePeriodParser.parse(er, referenceTime); - } - else if (er.type === Constants.SYS_DATETIME_DURATION) { - pr = this.config.durationParser.parse(er, referenceTime); - } - else if (er.type === Constants.SYS_DATETIME_SET) { - pr = this.config.setParser.parse(er, referenceTime); - } - else { - return null; - } - - // pop, restore the MOD string - if (hasBefore && pr.value !== null) { - pr.length += modStr.length; - pr.text = pr.text + modStr; - let val = pr.value; - val.mod = this.combineMod(val.mod, TimeTypeConstants.beforeMod); - pr.value = val; - } - - if (hasAfter && pr.value !== null) { - pr.length += modStr.length; - pr.text = pr.text + modStr; - let val = pr.value; - val.mod = this.combineMod(val.mod, TimeTypeConstants.afterMod); - pr.value = val; - } - - if (hasSince && pr.value !== null) { - pr.length += modStrPrefix.length + modStrSuffix.length; - pr.start -= modStrPrefix.length; - pr.text = modStrPrefix + pr.text + modStrSuffix; - let val = pr.value; - val.mod = this.combineMod(val.mod, TimeTypeConstants.sinceMod); - pr.value = val; - } - - let hasRangeChangingMod = hasBefore || hasAfter || hasSince; - pr.value = this.dateTimeResolution(pr, hasRangeChangingMod); - pr.type = `${this.parserTypeName}.${this.determineDateTimeType(er.type, hasRangeChangingMod)}`; - - return pr; - } - - protected dateTimeResolution(slot: DateTimeParseResult, hasRangeChangingMod: boolean): { [s: string]: StringMap[]; } { - if (!slot) { - return null; - } - - let result = new Map(); - let resolutions = new Array(); - - let type = slot.type; - let outputType = this.determineDateTimeType(type, hasRangeChangingMod); - let timex = slot.timexStr; - let sourceEntity = this.determineSourceEntityType(type, outputType, hasRangeChangingMod); - - let value: DateTimeResolutionResult = slot.value; - if (!value) { - return null; - } - - let isLunar = value.isLunar; - let mod = value.mod; - let comment = value.comment; - - // the following should added to res first since the ResolveAmPm is using these fields - this.addResolutionFieldsAny(result, Constants.TimexKey, timex); - this.addResolutionFieldsAny(result, Constants.CommentKey, comment); - this.addResolutionFieldsAny(result, Constants.ModKey, mod); - this.addResolutionFieldsAny(result, Constants.TypeKey, outputType); - - let futureResolution = value.futureResolution; - let pastResolution = value.pastResolution; - - let future = this.generateFromResolution(type, futureResolution, mod); - let past = this.generateFromResolution(type, pastResolution, mod); - - let futureValues = Array.from(this.getValues(future)).sort(); - let pastValues = Array.from(this.getValues(past)).sort(); - if (isEqual(futureValues, pastValues)) { - if (pastValues.length > 0) { - this.addResolutionFieldsAny(result, Constants.ResolveKey, past); - } - } - else { - if (pastValues.length > 0) { - this.addResolutionFieldsAny(result, Constants.ResolveToPastKey, past); - } - if (futureValues.length > 0) { - this.addResolutionFieldsAny(result, Constants.ResolveToFutureKey, future); - } - } - - if (comment && comment === 'ampm') { - if (result.has('resolve')) { - this.resolveAMPM(result, 'resolve'); - } - else { - this.resolveAMPM(result, 'resolveToPast'); - this.resolveAMPM(result, 'resolveToFuture'); - } - } - - result.forEach((value, key) => { - if (this.isObject(value)) { - // is "StringMap" - let newValues = {}; - - this.addResolutionFields(newValues, Constants.TimexKey, timex); - this.addResolutionFields(newValues, Constants.ModKey, mod); - this.addResolutionFields(newValues, Constants.TypeKey, outputType); - this.addResolutionFields(newValues, Constants.SourceEntity, sourceEntity); - if (isLunar) { - this.addResolutionFields(newValues, Constants.IsLunarKey, "True"); - } - - Object.keys(value).forEach((innerKey) => { - newValues[innerKey] = value[innerKey]; - }); - - resolutions.push(newValues); - } - }); - - if (Object.keys(past).length === 0 && Object.keys(future).length === 0) { - let o = {}; - o['timex'] = timex; - o['type'] = outputType; - o['value'] = 'not resolved'; - resolutions.push(o); - } - return { - values: resolutions - }; - } - - protected determineDateTimeType(type: string, hasMod: boolean): string { - if (hasMod) { - if (type === Constants.SYS_DATETIME_DATE) { - return Constants.SYS_DATETIME_DATEPERIOD; - } - if (type === Constants.SYS_DATETIME_TIME) { - return Constants.SYS_DATETIME_TIMEPERIOD; - } - if (type === Constants.SYS_DATETIME_DATETIME) { - return Constants.SYS_DATETIME_DATETIMEPERIOD; - } - } - return type; - } - - protected isDurationWithAgoAndLater(er: ExtractResult): boolean { - return er.metaData && er.metaData.IsDurationWithAgoAndLater; - } -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-date-time/src/dateTime/chinese/setConfiguration.ts b/JavaScript/packages/recognizers-date-time/src/dateTime/chinese/setConfiguration.ts deleted file mode 100644 index 08e78964b8..0000000000 --- a/JavaScript/packages/recognizers-date-time/src/dateTime/chinese/setConfiguration.ts +++ /dev/null @@ -1,262 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { IExtractor, ExtractResult, RegExpUtility, StringUtility } from "@microsoft/recognizers-text"; -import { BaseNumberParser, BaseNumberExtractor } from "@microsoft/recognizers-text-number"; -import { ISetExtractorConfiguration, BaseSetExtractor, ISetParserConfiguration, BaseSetParser } from "../baseSet"; -import { BaseDurationExtractor, BaseDurationParser } from "../baseDuration"; -import { IDateTimeParser, DateTimeParseResult } from "../parsers"; -import { Constants, TimeTypeConstants } from "../constants"; -import { BaseDateExtractor, BaseDateParser } from "../baseDate"; -import { BaseTimeExtractor, BaseTimeParser } from "../baseTime"; -import { BaseDatePeriodExtractor, BaseDatePeriodParser } from "../baseDatePeriod"; -import { BaseTimePeriodExtractor, BaseTimePeriodParser } from "../baseTimePeriod"; -import { BaseDateTimeExtractor, BaseDateTimeParser, IDateTimeExtractor } from "../baseDateTime"; -import { BaseDateTimePeriodExtractor, BaseDateTimePeriodParser } from "../baseDateTimePeriod"; -import { ChineseDurationExtractor, ChineseDurationParser } from "./durationConfiguration"; -import { ChineseTimeExtractor, ChineseTimeParser } from "./timeConfiguration"; -import { ChineseDateExtractor, ChineseDateParser } from "./dateConfiguration"; -import { ChineseDateTimeExtractor, ChineseDateTimeParser } from "./dateTimeConfiguration"; -import { Token, IDateTimeUtilityConfiguration, DateTimeResolutionResult, StringMap } from "../utilities"; -import { ChineseDateTime } from "../../resources/chineseDateTime"; - -class ChineseSetExtractorConfiguration implements ISetExtractorConfiguration { - readonly lastRegex: RegExp; - readonly eachPrefixRegex: RegExp; - readonly periodicRegex: RegExp; - readonly eachUnitRegex: RegExp; - readonly eachDayRegex: RegExp; - readonly beforeEachDayRegex: RegExp; - readonly setWeekDayRegex: RegExp; - readonly setEachRegex: RegExp; - readonly durationExtractor: ChineseDurationExtractor; - readonly timeExtractor: ChineseTimeExtractor; - readonly dateExtractor: ChineseDateExtractor; - readonly dateTimeExtractor: BaseDateTimeExtractor; - readonly datePeriodExtractor: BaseDatePeriodExtractor; - readonly timePeriodExtractor: BaseTimePeriodExtractor; - readonly dateTimePeriodExtractor: BaseDateTimePeriodExtractor; - - constructor(dmyDateFormat: boolean) { - this.eachUnitRegex = RegExpUtility.getSafeRegExp(ChineseDateTime.SetEachUnitRegex); - this.durationExtractor = new ChineseDurationExtractor(); - this.lastRegex = RegExpUtility.getSafeRegExp(ChineseDateTime.SetLastRegex); - this.eachPrefixRegex = RegExpUtility.getSafeRegExp(ChineseDateTime.SetEachPrefixRegex); - this.timeExtractor = new ChineseTimeExtractor(); - this.beforeEachDayRegex = RegExpUtility.getSafeRegExp(ChineseDateTime.SetEachDayRegex); - this.eachDayRegex = RegExpUtility.getSafeRegExp(ChineseDateTime.SetEachDayRegex); - this.dateExtractor = new ChineseDateExtractor(dmyDateFormat); - this.dateTimeExtractor = new ChineseDateTimeExtractor(dmyDateFormat); - } -} - -export class ChineseSetExtractor extends BaseSetExtractor { - - constructor(dmyDateFormat: boolean) { - super(new ChineseSetExtractorConfiguration(dmyDateFormat)); - } - - extract(source: string, refDate: Date): ExtractResult[] { - if (!refDate) { - refDate = new Date(); - } - let referenceDate = refDate; - - let tokens: Token[] = new Array() - .concat(super.matchEachUnit(source)) - .concat(super.matchEachDuration(source, referenceDate)) - .concat(this.matchEachSpecific(this.config.timeExtractor, this.config.eachDayRegex, source, referenceDate)) - .concat(this.matchEachSpecific(this.config.dateExtractor, this.config.eachPrefixRegex, source, referenceDate)) - .concat(this.matchEachSpecific(this.config.dateTimeExtractor, this.config.eachPrefixRegex, source, referenceDate)); - let result = Token.mergeAllTokens(tokens, source, this.extractorName); - return result; - } - - private matchEachSpecific(extractor: IDateTimeExtractor, eachRegex: RegExp, source: string, refDate: Date) { - let ret = []; - extractor.extract(source, refDate).forEach(er => { - let beforeStr = source.substr(0, er.start); - let beforeMatch = RegExpUtility.getMatches(eachRegex, beforeStr).pop(); - if (beforeMatch) { - ret.push(new Token(beforeMatch.index, er.start + er.length)); - } - }); - return ret; - } -} - -class ChineseSetParserConfiguration implements ISetParserConfiguration { - readonly durationExtractor: IDateTimeExtractor; - readonly durationParser: BaseDurationParser; - readonly timeExtractor: IDateTimeExtractor; - readonly timeParser: BaseTimeParser; - readonly dateExtractor: BaseDateExtractor; - readonly dateParser: BaseDateParser; - readonly dateTimeExtractor: BaseDateTimeExtractor; - readonly dateTimeParser: BaseDateTimeParser; - readonly datePeriodExtractor: BaseDatePeriodExtractor; - readonly datePeriodParser: BaseDatePeriodParser; - readonly timePeriodExtractor: BaseTimePeriodExtractor; - readonly timePeriodParser: BaseTimePeriodParser; - readonly dateTimePeriodExtractor: BaseDateTimePeriodExtractor; - readonly dateTimePeriodParser: BaseDateTimePeriodParser; - readonly unitMap: ReadonlyMap; - readonly eachPrefixRegex: RegExp; - readonly periodicRegex: RegExp; - readonly eachUnitRegex: RegExp; - readonly eachDayRegex: RegExp; - readonly setWeekDayRegex: RegExp; - readonly setEachRegex: RegExp; - - constructor(dmyDateFormat: boolean) { - this.dateExtractor = new ChineseDateExtractor(dmyDateFormat); - this.timeExtractor = new ChineseTimeExtractor(); - this.durationExtractor = new ChineseDurationExtractor(); - this.dateTimeExtractor = new ChineseDateTimeExtractor(dmyDateFormat); - this.dateParser = new ChineseDateParser(dmyDateFormat); - this.timeParser = new ChineseTimeParser(); - this.durationParser = new ChineseDurationParser(); - this.dateTimeParser = new ChineseDateTimeParser(dmyDateFormat); - this.unitMap = ChineseDateTime.ParserConfigurationUnitMap; - this.eachUnitRegex = RegExpUtility.getSafeRegExp(ChineseDateTime.SetEachUnitRegex); - this.eachDayRegex = RegExpUtility.getSafeRegExp(ChineseDateTime.SetEachDayRegex); - this.eachPrefixRegex = RegExpUtility.getSafeRegExp(ChineseDateTime.SetEachPrefixRegex); - } - - public getMatchedDailyTimex(text: string): { matched: boolean, timex: string } { - return null; - } - - public getMatchedUnitTimex(source: string): { matched: boolean, timex: string } { - let timex = ''; - if (source === '天' || source === '日') { - timex = 'P1D'; - } - else if (source === '周' || source === '星期') { - timex = 'P1W'; - } - else if (source === '月') { - timex = 'P1M'; - } - else if (source === '年') { - timex = 'P1Y'; - } - return { matched: timex !== '', timex: timex }; - } -} - -export class ChineseSetParser extends BaseSetParser { - - constructor(dmyDateFormat: boolean) { - let config = new ChineseSetParserConfiguration(dmyDateFormat); - super(config); - } - - parse(er: ExtractResult, referenceDate?: Date): DateTimeParseResult | null { - if (!referenceDate) { - referenceDate = new Date(); - } - let value = null; - if (er.type === BaseSetParser.ParserName) { - let innerResult = this.parseEachUnit(er.text); - if (!innerResult.success) { - innerResult = this.parseEachDuration(er.text, referenceDate); - } - if (!innerResult.success) { - innerResult = this.parserTimeEveryday(er.text, referenceDate); - } - if (!innerResult.success) { - innerResult = this.parseEach(this.config.dateTimeExtractor, this.config.dateTimeParser, er.text, referenceDate); - } - if (!innerResult.success) { - innerResult = this.parseEach(this.config.dateExtractor, this.config.dateParser, er.text, referenceDate); - } - if (innerResult.success) { - innerResult.futureResolution = {}; - innerResult.futureResolution[TimeTypeConstants.SET] = innerResult.futureValue; - innerResult.pastResolution = {}; - innerResult.pastResolution[TimeTypeConstants.SET] = innerResult.pastValue; - value = innerResult; - } - } - - let ret = new DateTimeParseResult(er); - ret.value = value, - ret.timexStr = value === null ? "" : value.timex, - ret.resolutionStr = ""; - - return ret; - } - - protected parseEachUnit(text: string): DateTimeResolutionResult { - let ret = new DateTimeResolutionResult(); - - // handle "each month" - let match = RegExpUtility.getMatches(this.config.eachUnitRegex, text).pop(); - if (!match || match.length !== text.length) { - return ret; - } - - let sourceUnit = match.groups("unit").value; - if (StringUtility.isNullOrEmpty(sourceUnit) || !this.config.unitMap.has(sourceUnit)) { - return ret; - } - - let getMatchedUnitTimex = this.config.getMatchedUnitTimex(sourceUnit); - if (!getMatchedUnitTimex.matched) { - return ret; - } - - ret.timex = getMatchedUnitTimex.timex; - ret.futureValue = "Set: " + ret.timex; - ret.pastValue = "Set: " + ret.timex; - ret.success = true; - return ret; - } - - protected parserTimeEveryday(text: string, refDate: Date): DateTimeResolutionResult { - let result = new DateTimeResolutionResult(); - let ers = this.config.timeExtractor.extract(text, refDate); - if (ers.length !== 1) { - return result; - } - - let er = ers[0]; - let beforeStr = text.substr(0, er.start); - let match = RegExpUtility.getMatches(this.config.eachDayRegex, beforeStr).pop(); - if (!match) { - return result; - } - - let pr = this.config.timeParser.parse(er); - result.timex = pr.timexStr; - result.futureValue = "Set: " + result.timex; - result.pastValue = "Set: " + result.timex; - result.success = true; - - return result; - } - - protected parseEach(extractor: IDateTimeExtractor, parser: IDateTimeParser, text: string, refDate: Date): DateTimeResolutionResult { - let result = new DateTimeResolutionResult(); - let ers = extractor.extract(text, refDate); - if (ers.length !== 1) { - return result; - } - - let er = ers[0]; - let beforeStr = text.substr(0, er.start); - let match = RegExpUtility.getMatches(this.config.eachPrefixRegex, beforeStr).pop(); - if (!match) { - return result; - } - - let timex = parser.parse(er).timexStr; - result.timex = timex; - result.futureValue = `Set: ${timex}`; - result.pastValue = `Set: ${timex}`; - result.success = true; - - return result; - } -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-date-time/src/dateTime/chinese/timeConfiguration.ts b/JavaScript/packages/recognizers-date-time/src/dateTime/chinese/timeConfiguration.ts deleted file mode 100644 index 96e4fd03cd..0000000000 --- a/JavaScript/packages/recognizers-date-time/src/dateTime/chinese/timeConfiguration.ts +++ /dev/null @@ -1,166 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { RegExpUtility, StringUtility, ExtractResult } from "@microsoft/recognizers-text"; -import { CultureInfo, Culture } from "@microsoft/recognizers-text-number"; -import { NumberWithUnitExtractor, ChineseNumberWithUnitExtractorConfiguration } from "@microsoft/recognizers-text-number-with-unit"; -import { BaseDateTimeExtractor, DateTimeExtra, TimeResult, TimeResolutionUtils } from "./baseDateTime"; -import { BaseTimeParser } from "../baseTime"; -import { Constants, TimeTypeConstants } from "../constants"; -import { IDateTimeParser, DateTimeParseResult } from "../parsers"; -import { DateTimeResolutionResult, DateTimeFormatUtil, DateUtils, StringMap } from "../utilities"; -import { ChineseDateTime } from "../../resources/chineseDateTime"; - -export enum TimeType { - ChineseTime, - LessTime, - DigitTime -} - -export class ChineseTimeExtractor extends BaseDateTimeExtractor { - protected extractorName = Constants.SYS_DATETIME_TIME; // "Time"; - - constructor() { - super(new Map([ - [RegExpUtility.getSafeRegExp(ChineseDateTime.TimeRegexes1), TimeType.ChineseTime], - [RegExpUtility.getSafeRegExp(ChineseDateTime.TimeRegexes2), TimeType.DigitTime], - [RegExpUtility.getSafeRegExp(ChineseDateTime.TimeRegexes3), TimeType.LessTime] - ])); - } -} - -export class ChineseTimeParser extends BaseTimeParser { - private readonly onlyDigitMatch: RegExp; - private readonly numbersMap: ReadonlyMap; - private readonly lowBoundMap: ReadonlyMap; - private readonly functionMap: ReadonlyMap) => TimeResult>; - private readonly innerExtractor: ChineseTimeExtractor; - - constructor() { - super(null); - this.functionMap = new Map) => TimeResult>([ - [TimeType.DigitTime, x => this.handleDigit(x)], - [TimeType.ChineseTime, x => this.handleChinese(x)], - [TimeType.LessTime, x => this.handleLess(x)] - ]); - this.onlyDigitMatch = RegExpUtility.getSafeRegExp('\\d+'); - this.numbersMap = ChineseDateTime.TimeNumberDictionary; - this.lowBoundMap = ChineseDateTime.TimeLowBoundDesc; - this.innerExtractor = new ChineseTimeExtractor(); - } - - public parse(er: ExtractResult, referenceTime?: Date): DateTimeParseResult | null { - if (!referenceTime) { - referenceTime = new Date(); - } - - let extra: DateTimeExtra = er.data; - if (!extra) { - let innerResult = this.innerExtractor.extract(er.text, referenceTime).pop(); - extra = innerResult.data; - } - - let timeResult = this.functionMap.get(extra.dataType)(extra); - let parseResult = this.packTimeResult(extra, timeResult, referenceTime); - - if (parseResult.success) { - parseResult.futureResolution = {}; - parseResult.futureResolution[TimeTypeConstants.TIME] = DateTimeFormatUtil.formatTime(parseResult.futureValue); - parseResult.pastResolution = {}; - parseResult.pastResolution[TimeTypeConstants.TIME] = DateTimeFormatUtil.formatTime(parseResult.pastValue); - } - - let result = new DateTimeParseResult(er); - result.value = parseResult; - result.data = timeResult; - result.resolutionStr = ''; - result.timexStr = parseResult.timex; - - return result; - } - - private handleLess(extra: DateTimeExtra): TimeResult { - let hour = this.matchToValue(extra.namedEntity('hour').value); - let quarter = this.matchToValue(extra.namedEntity('quarter').value); - let minute = !StringUtility.isNullOrEmpty(extra.namedEntity('half').value) - ? 30 - : quarter !== -1 ? quarter * 15 : 0; - let second = this.matchToValue(extra.namedEntity('sec').value); - let less = this.matchToValue(extra.namedEntity('min').value); - - let all = hour * 60 + minute - less; - if (all < 0) { - all += 1440; - } - - return new TimeResult(all / 60, all % 60, second); - } - - private handleChinese(extra: DateTimeExtra): TimeResult { - let hour = this.matchToValue(extra.namedEntity('hour').value); - let quarter = this.matchToValue(extra.namedEntity('quarter').value); - let minute = !StringUtility.isNullOrEmpty(extra.namedEntity('half').value) - ? 30 - : quarter !== -1 ? quarter * 15 - : this.matchToValue(extra.namedEntity('min').value); - let second = this.matchToValue(extra.namedEntity('sec').value); - - return new TimeResult(hour, minute, second); - } - - private handleDigit(extra: DateTimeExtra): TimeResult { - return new TimeResult( - this.matchToValue(extra.namedEntity('hour').value), - this.matchToValue(extra.namedEntity('min').value), - this.matchToValue(extra.namedEntity('sec').value) - ); - } - - private packTimeResult(extra: DateTimeExtra, timeResult: TimeResult, referenceTime: Date): DateTimeResolutionResult { - let result = new DateTimeResolutionResult(); - let dayDescription = extra.namedEntity('daydesc').value; - let noDescription = StringUtility.isNullOrEmpty(dayDescription); - if (noDescription) { - result.comment = 'ampm'; - } - else { - this.addDescription(timeResult, dayDescription); - } - - let hour = timeResult.hour > 0 ? timeResult.hour : 0; - let min = timeResult.minute > 0 ? timeResult.minute : 0; - let sec = timeResult.second > 0 ? timeResult.second : 0; - let day = referenceTime.getDate(); - let month = referenceTime.getMonth(); - let year = referenceTime.getFullYear(); - - let timex = 'T'; - if (timeResult.hour >= 0) { - timex = timex + DateTimeFormatUtil.toString(timeResult.hour, 2); - if (timeResult.minute >= 0) { - timex = timex + ':' + DateTimeFormatUtil.toString(timeResult.minute, 2); - if (timeResult.second >= 0) { - timex = timex + ':' + DateTimeFormatUtil.toString(timeResult.second, 2); - } - } - } - if (hour === 24) { - hour = 0; - } - - result.futureValue = DateUtils.safeCreateFromMinValue(year, month, day, hour, min, sec); - result.pastValue = DateUtils.safeCreateFromMinValue(year, month, day, hour, min, sec); - result.timex = timex; - result.success = true; - - return result; - } - - private matchToValue(source: string): number { - return TimeResolutionUtils.matchToValue(this.onlyDigitMatch, this.numbersMap, source); - } - - private addDescription(timeResult: TimeResult, description: string) { - TimeResolutionUtils.addDescription(this.lowBoundMap, timeResult, description); - } -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-date-time/src/dateTime/chinese/timePeriodConfiguration.ts b/JavaScript/packages/recognizers-date-time/src/dateTime/chinese/timePeriodConfiguration.ts deleted file mode 100644 index bed4e98e03..0000000000 --- a/JavaScript/packages/recognizers-date-time/src/dateTime/chinese/timePeriodConfiguration.ts +++ /dev/null @@ -1,295 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { RegExpUtility, ExtractResult, IExtractor } from "@microsoft/recognizers-text"; -import { CultureInfo, Culture, EnglishIntegerExtractor } from "@microsoft/recognizers-text-number"; -import { NumberWithUnitExtractor, ChineseNumberWithUnitExtractorConfiguration } from "@microsoft/recognizers-text-number-with-unit"; -import { BaseDateTimeExtractor, DateTimeExtra, TimeResult, TimeResolutionUtils } from "./baseDateTime"; -import { Constants, TimeTypeConstants } from "../constants"; -import { ChineseDateTime } from "../../resources/chineseDateTime"; -import { DateTimeResolutionResult, DateTimeFormatUtil, DateUtils, StringMap, TimexUtil } from "../utilities"; -import { BaseTimePeriodParser, ITimePeriodParserConfiguration } from "../baseTimePeriod"; -import { IDateTimeParser, DateTimeParseResult } from "../parsers"; -import { ChineseTimeParser } from "./timeConfiguration"; -import { IDateTimeExtractor } from "../baseDateTime"; - -export enum TimePeriodType { - ShortTime, - FullTime -} - -export class ChineseTimePeriodExtractor extends BaseDateTimeExtractor { - protected extractorName = Constants.SYS_DATETIME_TIMEPERIOD; // "time range"; - - constructor() { - super(new Map([ - [RegExpUtility.getSafeRegExp(ChineseDateTime.TimePeriodRegexes1), TimePeriodType.FullTime], - [RegExpUtility.getSafeRegExp(ChineseDateTime.TimePeriodRegexes2), TimePeriodType.ShortTime], - [RegExpUtility.getSafeRegExp(ChineseDateTime.TimeOfDayRegex), TimePeriodType.ShortTime] - ])); - } -} - -class ChineseTimePeriodParserConfiguration implements ITimePeriodParserConfiguration { - timeExtractor: IDateTimeExtractor; - timeParser: ChineseTimeParser; - integerExtractor: IExtractor; - pureNumberFromToRegex: RegExp; - pureNumberBetweenAndRegex: RegExp; - timeOfDayRegex: RegExp; - tillRegex: RegExp; - numbers: ReadonlyMap; - utilityConfiguration: any; - specificTimeFromToRegex: RegExp; - specificTimeBetweenAndRegex: RegExp; - - constructor() { - this.timeParser = new ChineseTimeParser(); - this.integerExtractor = new EnglishIntegerExtractor(); - } - - getMatchedTimexRange(text: string): any { - return null; - } -} - -export class ChineseTimePeriodParser extends BaseTimePeriodParser { - private readonly dayDescriptionRegex: RegExp; - private readonly onlyDigitMatch: RegExp; - private readonly lowBoundMap: ReadonlyMap; - private readonly numbersMap: ReadonlyMap; - - constructor() { - let config = new ChineseTimePeriodParserConfiguration(); - super(config); - this.dayDescriptionRegex = RegExpUtility.getSafeRegExp(ChineseDateTime.TimeDayDescRegex); - this.onlyDigitMatch = RegExpUtility.getSafeRegExp('\\d+'); - this.numbersMap = ChineseDateTime.TimeNumberDictionary; - this.lowBoundMap = ChineseDateTime.TimeLowBoundDesc; - } - - public parse(er: ExtractResult, referenceTime?: Date): DateTimeParseResult { - if (!referenceTime) { - referenceTime = new Date(); - } - - let result = new DateTimeParseResult(er); - let extra: DateTimeExtra = er.data; - - if (!extra) { - return result; - } - - let parseResult = this.parseChineseTimeOfDay(er.text, referenceTime); - - if (!parseResult.success) { - parseResult = this.parseTimePeriod(extra, referenceTime); - } - - if (parseResult.success) { - parseResult.futureResolution = {}; - parseResult.futureResolution[TimeTypeConstants.START_TIME] = DateTimeFormatUtil.formatTime(parseResult.futureValue.item1); - parseResult.futureResolution[TimeTypeConstants.END_TIME] = DateTimeFormatUtil.formatTime(parseResult.futureValue.item2); - parseResult.pastResolution = {}; - parseResult.pastResolution[TimeTypeConstants.START_TIME] = DateTimeFormatUtil.formatTime(parseResult.pastValue.item1); - parseResult.pastResolution[TimeTypeConstants.END_TIME] = DateTimeFormatUtil.formatTime(parseResult.pastValue.item2); - } - - result.value = parseResult; - result.resolutionStr = ''; - result.timexStr = parseResult.timex; - - return result; - } - - private parseChineseTimeOfDay(text: string, referenceTime: Date): DateTimeResolutionResult { - let day = referenceTime.getDay(); - let month = referenceTime.getMonth(); - let year = referenceTime.getFullYear(); - let ret = new DateTimeResolutionResult(); - - let parameters = this.GetMatchedTimexRange(text); - if (!parameters.matched) { - return new DateTimeResolutionResult(); - } - - ret.timex = parameters.timex; - ret.futureValue = ret.pastValue = { - item1: DateUtils.safeCreateFromMinValue(year, month, day, parameters.beginHour, 0, 0), - item2: DateUtils.safeCreateFromMinValue(year, month, day, parameters.endHour, parameters.endMin, 0) - }; - ret.success = true; - - return ret; - } - - private GetMatchedTimexRange(text: string): { matched: boolean, timex: string, beginHour: number, endHour: number, endMin: number } { - let trimmedText = text.trim(); - let matched = false; - let timex = null; - let beginHour = 0; - let endHour = 0; - let endMin = 0; - - let timeOfDay = ""; - if (ChineseDateTime.MorningTermList.some(o => trimmedText.endsWith(o))) { - timeOfDay = Constants.Morning; - } - else if (ChineseDateTime.MidDayTermList.some(o => trimmedText.endsWith(o))) { - timeOfDay = Constants.MidDay; - } - else if (ChineseDateTime.AfternoonTermList.some(o => trimmedText.endsWith(o))) { - timeOfDay = Constants.Afternoon; - } - else if (ChineseDateTime.EveningTermList.some(o => trimmedText.endsWith(o))) { - timeOfDay = Constants.Evening; - } - else if (ChineseDateTime.DaytimeTermList.some(o => trimmedText.localeCompare(o) == 0)) { - timeOfDay = Constants.Daytime; - } - else if (ChineseDateTime.NightTermList.some(o => trimmedText.endsWith(o))) { - timeOfDay = Constants.Night; - } - else { - timex = null; - matched = false; - return { matched, timex, beginHour, endHour, endMin }; - } - - let parseResult = TimexUtil.parseTimeOfDay(timeOfDay); - timex = parseResult.timeX; - beginHour = parseResult.beginHour; - endHour = parseResult.endHour; - endMin = parseResult.endMin; - - matched = true; - return { matched, timex, beginHour, endHour, endMin }; - } - - private parseTimePeriod(extra: DateTimeExtra, referenceTime: Date): DateTimeResolutionResult { - let result = new DateTimeResolutionResult(); - - let leftEntity = extra.namedEntity('left'); - let leftResult = extra.dataType === TimePeriodType.FullTime - ? this.getParseTimeResult(leftEntity, referenceTime) - : this.getShortLeft(leftEntity.value); - - let rightEntity = extra.namedEntity('right'); - let rightResult = this.getParseTimeResult(rightEntity, referenceTime); - - // the right side doesn't contain desc while the left side does - if (rightResult.lowBound === -1 && leftResult.lowBound !== -1 && rightResult.hour <= leftResult.lowBound) { - rightResult.hour += 12; - } - - let leftDate = this.buildDate(leftResult, referenceTime); - let rightDate = this.buildDate(rightResult, referenceTime); - - if (rightDate.getHours() < leftDate.getHours()) { - rightDate = DateUtils.addDays(rightDate, 1); - } - - result.futureValue = result.pastValue = { - item1: leftDate, - item2: rightDate - }; - let leftTimex = this.buildTimex(leftResult); - let rightTimex = this.buildTimex(rightResult); - let spanTimex = this.buildSpan(leftResult, rightResult); - result.timex = `(${leftTimex},${rightTimex},${spanTimex})`; - result.success = true; - - return result; - } - - private getParseTimeResult(entity: any, referenceTime: Date): TimeResult { - let extractResult: ExtractResult = { - start: entity.index, - length: entity.length, - text: entity.value, - type: Constants.SYS_DATETIME_TIME - }; - let result = this.config.timeParser.parse(extractResult, referenceTime); - return result.data; - } - - private getShortLeft(source: string): TimeResult { - let description = ''; - if (RegExpUtility.isMatch(this.dayDescriptionRegex, source)) { - description = source.substr(0, source.length - 1); - } - - let hour = TimeResolutionUtils.matchToValue(this.onlyDigitMatch, this.numbersMap, source.substr(source.length - 1)); - let timeResult = new TimeResult(hour, -1, -1); - TimeResolutionUtils.addDescription(this.lowBoundMap, timeResult, description); - return timeResult; - } - - private buildDate(time: TimeResult, referenceTime: Date): Date { - let day = referenceTime.getDate(); - let month = referenceTime.getMonth(); - let year = referenceTime.getFullYear(); - - let hour = time.hour > 0 ? time.hour : 0; - let min = time.minute > 0 ? time.minute : 0; - let sec = time.second > 0 ? time.second : 0; - - return DateUtils.safeCreateFromMinValue(year, month, day, hour, min, sec); - } - - private buildTimex(timeResult: TimeResult): string { - let timex = 'T'; - if (timeResult.hour >= 0) { - timex = timex + DateTimeFormatUtil.toString(timeResult.hour, 2); - if (timeResult.minute >= 0) { - timex = timex + ':' + DateTimeFormatUtil.toString(timeResult.minute, 2); - if (timeResult.second >= 0) { - timex = timex + ':' + DateTimeFormatUtil.toString(timeResult.second, 2); - } - } - } - return timex; - } - - private buildSpan(left: TimeResult, right: TimeResult): string { - left = this.sanitizeTimeResult(left); - right = this.sanitizeTimeResult(right); - - let spanHour = right.hour - left.hour; - let spanMin = right.minute - left.minute; - let spanSec = right.second - left.second; - - if (spanSec < 0) { - spanSec += 60; - spanMin -= 1; - } - - if (spanMin < 0) { - spanMin += 60; - spanHour -= 1; - } - - if (spanHour < 0) { - spanHour += 24; - } - let spanTimex = `PT`; - if (spanHour > 0 ) { - spanTimex = spanTimex + `${spanHour}H`; - } - if (spanMin !== 0 && spanSec === 0) { - spanTimex = spanTimex + `${spanMin}M`; - } - else if (spanSec !== 0) { - spanTimex = spanTimex + `${spanMin}M${spanSec}S`; - } - return spanTimex; - } - - private sanitizeTimeResult(timeResult: TimeResult): TimeResult { - return new TimeResult( - timeResult.hour, - timeResult.minute === -1 ? 0 : timeResult.minute, - timeResult.second === -1 ? 0 : timeResult.second - ); - } -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-date-time/src/dateTime/constants.ts b/JavaScript/packages/recognizers-date-time/src/dateTime/constants.ts deleted file mode 100644 index c2277bc277..0000000000 --- a/JavaScript/packages/recognizers-date-time/src/dateTime/constants.ts +++ /dev/null @@ -1,154 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { BaseDateTime } from "../resources/baseDateTime"; - -export class Constants { - static readonly SYS_DATETIME_DATE: string = "date"; - static readonly SYS_DATETIME_TIME: string = "time"; - static readonly SYS_DATETIME_DATEPERIOD: string = "daterange"; - static readonly SYS_DATETIME_DATETIME: string = "datetime"; - static readonly SYS_DATETIME_TIMEPERIOD: string = "timerange"; - static readonly SYS_DATETIME_DATETIMEPERIOD: string = "datetimerange"; - static readonly SYS_DATETIME_DURATION: string = "duration"; - static readonly SYS_DATETIME_SET: string = "set"; - - // SourceEntity Types - static readonly SYS_DATETIME_DATETIMEPOINT = "datetimepoint"; - - // key - static readonly TimexKey: string = "timex"; - static readonly ModKey: string = "Mod"; - static readonly SourceEntity: string = "sourceEntity"; - static readonly TypeKey: string = "type"; - static readonly IsLunarKey: string = "isLunar"; - static readonly ResolveKey: string = "resolve"; - static readonly ResolveToPastKey: string = "resolveToPast"; - static readonly ResolveToFutureKey: string = "resolveToFuture"; - static readonly Decade: string = "decade"; - static readonly Century: string = "century" - static readonly RelCentury: string = "relcentury" - - static readonly CommentKey: string = "Comment"; - static readonly CommentAmPm: string = "ampm"; - - // Tag to mark cases where the specifc resolution timex depends on future or past values. - static readonly Comment_DoubleTimex: string = "DoubleTimex"; - - static readonly SemesterMonthCount: number = 6; - static readonly TrimesterMonthCount: number = 3; - static readonly QuarterCount: number = 4; - static readonly FourDigitsYearLength: number = 4; - static readonly MaxMonth: number = 11; - static readonly MinMonth: number = 0; - - // specifies the priority interpreting month and day order - static readonly DefaultLanguageFallback_MDY: string = 'MDY'; - static readonly DefaultLanguageFallback_DMY: string = 'DMY'; - static readonly DefaultLanguageFallback_YMD: string = "YMD"; // ZH - - static readonly MinYearNum: number = parseInt(BaseDateTime.MinYearNum); - static readonly MaxYearNum: number = parseInt(BaseDateTime.MaxYearNum); - - static readonly MaxTwoDigitYearFutureNum: number = parseInt(BaseDateTime.MaxTwoDigitYearFutureNum); - static readonly MinTwoDigitYearPastNum: number = parseInt(BaseDateTime.MinTwoDigitYearPastNum); - - // Mod Value - // "before" -> To mean "preceding in time". I.e. Does not include the extracted datetime entity in the resolution's ending point. Equivalent to "<" - static readonly BEFORE_MOD: string = 'before'; - - // "after" -> To mean "following in time". I.e. Does not include the extracted datetime entity in the resolution's starting point. Equivalent to ">" - static readonly AFTER_MOD: string = 'after'; - - // "since" -> Same as "after", but including the extracted datetime entity. Equivalent to ">=" - static readonly SINCE_MOD: string = 'since'; - - // "until" -> Same as "before", but including the extracted datetime entity. Equivalent to "<=" - static readonly UNTIL_MOD: string = 'until'; - - static readonly EARLY_MOD: string = 'start'; - static readonly MID_MOD: string = 'mid'; - static readonly LATE_MOD: string = 'end'; - - static readonly MORE_THAN_MOD: string = 'more'; - static readonly LESS_THAN_MOD: string = 'less'; - - static readonly REF_UNDEF_MOD: string = 'ref_undef'; - - // Timex - static readonly TimexYear: string = "Y"; - static readonly TimexMonth: string = "M"; - static readonly TimexMonthFull: string = "MON"; - static readonly TimexWeek: string = "W"; - static readonly TimexDay: string = "D"; - static readonly TimexBusinessDay: string = "BD"; - static readonly TimexWeekend: string = "WE"; - static readonly TimexHour: string = "H"; - static readonly TimexMinute: string = "M"; - static readonly TimexSecond: string = "S"; - static readonly TimexFuzzy: string = 'X'; - static readonly TimexFuzzyYear: string = "XXXX"; - static readonly TimexFuzzyMonth: string = "XX"; - static readonly TimexFuzzyWeek: string = "WXX"; - static readonly TimexFuzzyDay: string = "XX"; - static readonly DateTimexConnector: string = "-"; - static readonly TimeTimexConnector: string = ":"; - static readonly GeneralPeriodPrefix: string = "P"; - static readonly TimeTimexPrefix: string = "T"; - static readonly ByDay: string = "ByDay"; - static readonly ByWeek: string = "ByWeek"; - static readonly ByMonth: string = "ByMonth"; - static readonly ByYear: string = "ByYear"; - - static readonly DatePeriodTimexTypeToTimexSuffix: ReadonlyMap = new Map([[Constants.ByDay, Constants.TimexDay], [Constants.ByWeek, Constants.TimexWeek], [Constants.ByMonth, Constants.TimexMonth], [Constants.ByYear, Constants.TimexYear]]); - - // Timex of TimeOfDay - static readonly EarlyMorning: string = "TDA"; - static readonly Morning: string = "TMO"; - static readonly MidDay: string = "TMI"; - static readonly Afternoon: string = "TAF"; - static readonly Evening: string = "TEV"; - static readonly Daytime: string = "TDT"; - static readonly Night: string = "TNI"; - static readonly BusinessHour: string = "TBH"; - - static readonly InvalidDateString: string = "0001-01-01"; - - static readonly CompositeTimexDelimiter: string = "|"; - - // Group names - static readonly yearCJK: string = "yearCJK"; - - // Invalid year - static readonly InvalidYear: number = Number.MIN_VALUE; - public readonly InvalidMonth: number = Number.MIN_VALUE; - public readonly InvalidDay: number = Number.MIN_VALUE; - public readonly InvalidHour: number = Number.MIN_VALUE; - public readonly InvalidMinute: number = Number.MIN_VALUE; - public readonly InvalidSecond: number = Number.MIN_VALUE; - -} - -export class TimeTypeConstants { - static readonly DATE: string = "date"; - static readonly START_DATE: string = "startDate"; - static readonly END_DATE: string = "endDate"; - static readonly DATETIME: string = "dateTime"; - static readonly START_DATETIME: string = "startDateTime"; - static readonly END_DATETIME: string = "endDateTime"; - static readonly DURATION: string = "duration"; - static readonly SET: string = "set"; - static readonly TIME: string = "time"; - static readonly VALUE: string = "value"; - static readonly START_TIME: string = "startTime"; - static readonly END_TIME: string = "endTime"; - - static readonly START: string = "start"; - static readonly END: string = "end"; - - static readonly beforeMod: string = "before"; - static readonly afterMod: string = "after"; - static readonly sinceMod: string = "since"; - static readonly moreThanMod: string = "more"; - static readonly lessThanMod: string = "less"; -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-date-time/src/dateTime/dateTimeRecognizer.ts b/JavaScript/packages/recognizers-date-time/src/dateTime/dateTimeRecognizer.ts deleted file mode 100644 index e2a7e569f4..0000000000 --- a/JavaScript/packages/recognizers-date-time/src/dateTime/dateTimeRecognizer.ts +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { IModel, ModelResult, Recognizer } from "@microsoft/recognizers-text"; -import { Culture } from "@microsoft/recognizers-text-number"; -import { IDateTimeModel, DateTimeModel } from "./models"; -import { BaseMergedParser, BaseMergedExtractor } from "./baseMerged"; -import { EnglishCommonDateTimeParserConfiguration } from "./english/baseConfiguration"; -import { EnglishMergedExtractorConfiguration, EnglishMergedParserConfiguration } from "./english/mergedConfiguration"; -import { SpanishMergedParserConfiguration, SpanishMergedExtractorConfiguration } from "./spanish/mergedConfiguration"; -import { FrenchMergedParserConfiguration, FrenchMergedExtractorConfiguration } from "./french/mergedConfiguration"; -import { ChineseMergedExtractor, ChineseMergedParser, ChineseFullMergedParser } from "./chinese/mergedConfiguration"; - -export enum DateTimeOptions { - None = 0, SkipFromToMerge = 1, SplitDateAndTime = 2, Calendar = 4 -} - -export function recognizeDateTime(query: string, culture: string, options: DateTimeOptions = DateTimeOptions.None, - referenceDate: Date = new Date(), fallbackToDefaultCulture: boolean = true): ModelResult[] { - let recognizer = new DateTimeRecognizer(culture, options); - let model = recognizer.getDateTimeModel(culture, fallbackToDefaultCulture); - return model.parse(query, referenceDate); -} - -export default class DateTimeRecognizer extends Recognizer { - constructor(culture: string, options: DateTimeOptions = DateTimeOptions.None, lazyInitialization: boolean = false) { - super(culture, options, lazyInitialization); - } - - protected InitializeConfiguration() { - // #region English - this.registerModel("DateTimeModel", Culture.English, (options) => new DateTimeModel( - new BaseMergedParser(new EnglishMergedParserConfiguration(new EnglishCommonDateTimeParserConfiguration()), this.Options), - new BaseMergedExtractor(new EnglishMergedExtractorConfiguration(), this.Options) - )); - // #endregion - - // #region EnglishOhters - this.registerModel("DateTimeModel", Culture.EnglishOthers, (options) => new DateTimeModel( - new BaseMergedParser(new EnglishMergedParserConfiguration(new EnglishCommonDateTimeParserConfiguration(true)), this.Options), - new BaseMergedExtractor(new EnglishMergedExtractorConfiguration(true), this.Options) - )); - // #endregion - - // #region Spanish - this.registerModel("DateTimeModel", Culture.Spanish, (options) => new DateTimeModel( - new BaseMergedParser(new SpanishMergedParserConfiguration(), this.Options), - new BaseMergedExtractor(new SpanishMergedExtractorConfiguration(), this.Options) - )); - // #endregion - - // #region Chinese - this.registerModel("DateTimeModel", Culture.Chinese, (options) => new DateTimeModel( - new ChineseFullMergedParser(), - new ChineseMergedExtractor(this.Options) - )); - // #endregion - - // #region French - this.registerModel("DateTimeModel", Culture.French, (options) => new DateTimeModel( - new BaseMergedParser(new FrenchMergedParserConfiguration(), this.Options), - new BaseMergedExtractor(new FrenchMergedExtractorConfiguration(), this.Options) - )); - // #endregion - } - - protected IsValidOptions(options: number): boolean { - return options >= 0 && options <= DateTimeOptions.None + DateTimeOptions.SkipFromToMerge + DateTimeOptions.SplitDateAndTime + DateTimeOptions.Calendar; - } - - getDateTimeModel(culture: string = null, fallbackToDefaultCulture: boolean = true): IDateTimeModel { - return this.getModel("DateTimeModel", culture, fallbackToDefaultCulture); - } -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-date-time/src/dateTime/english/baseConfiguration.ts b/JavaScript/packages/recognizers-date-time/src/dateTime/english/baseConfiguration.ts deleted file mode 100644 index 1c7f92c145..0000000000 --- a/JavaScript/packages/recognizers-date-time/src/dateTime/english/baseConfiguration.ts +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { RegExpUtility } from "@microsoft/recognizers-text"; -import { EnglishCardinalExtractor, EnglishIntegerExtractor, EnglishOrdinalExtractor, BaseNumberParser, EnglishNumberParserConfiguration } from "@microsoft/recognizers-text-number"; -import { EnglishDateTime } from "../../resources/englishDateTime"; -import { BaseDateTime } from "../../resources/baseDateTime"; -import { DateTimeFormatUtil, DateTimeResolutionResult, IDateTimeUtilityConfiguration } from "../utilities"; -import { BaseDateParserConfiguration } from "../parsers"; -import { BaseDateExtractor, BaseDateParser } from "../baseDate"; -import { BaseTimeExtractor } from "../baseTime"; -import { BaseDatePeriodExtractor, BaseDatePeriodParser } from "../baseDatePeriod"; -import { BaseTimePeriodExtractor, BaseTimePeriodParser } from "../baseTimePeriod"; -import { BaseDateTimeExtractor, BaseDateTimeParser } from "../baseDateTime"; -import { BaseDateTimePeriodExtractor, BaseDateTimePeriodParser } from "../baseDateTimePeriod"; -import { BaseDurationExtractor, BaseDurationParser } from "../baseDuration"; -import { EnglishDurationExtractorConfiguration, EnglishDurationParserConfiguration } from "./durationConfiguration"; -import { EnglishTimeExtractorConfiguration, EnglishTimeParserConfiguration } from "./timeConfiguration"; -import { EnglishDateExtractorConfiguration, EnglishDateParserConfiguration } from "./dateConfiguration"; -import { EnglishDateTimeExtractorConfiguration, EnglishDateTimeParserConfiguration } from "./dateTimeConfiguration"; -import { EnglishTimePeriodExtractorConfiguration, EnglishTimePeriodParserConfiguration } from "./timePeriodConfiguration"; -import { EnglishDatePeriodExtractorConfiguration, EnglishDatePeriodParserConfiguration } from "./datePeriodConfiguration"; -import { EnglishDateTimePeriodExtractorConfiguration, EnglishDateTimePeriodParserConfiguration } from "./dateTimePeriodConfiguration"; -import { EnglishTimeParser } from "./parsers"; - -export class EnglishDateTimeUtilityConfiguration implements IDateTimeUtilityConfiguration { - readonly agoRegex: RegExp; - readonly laterRegex: RegExp; - readonly inConnectorRegex: RegExp; - readonly rangeUnitRegex: RegExp; - readonly amDescRegex: RegExp; - readonly pmDescRegex: RegExp; - readonly amPmDescRegex: RegExp; - - constructor() { - this.laterRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.LaterRegex); - this.agoRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.AgoRegex); - this.inConnectorRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.InConnectorRegex); - this.rangeUnitRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.RangeUnitRegex); - this.amDescRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.AmDescRegex); - this.pmDescRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.PmDescRegex); - this.amPmDescRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.AmPmDescRegex); - } -} - -export class EnglishCommonDateTimeParserConfiguration extends BaseDateParserConfiguration { - constructor(dmyDateFormat: boolean = false) { - super(); - this.utilityConfiguration = new EnglishDateTimeUtilityConfiguration(); - this.unitMap = EnglishDateTime.UnitMap; - this.unitValueMap = EnglishDateTime.UnitValueMap; - this.seasonMap = EnglishDateTime.SeasonMap; - this.cardinalMap = EnglishDateTime.CardinalMap; - this.dayOfWeek = EnglishDateTime.DayOfWeek; - this.monthOfYear = EnglishDateTime.MonthOfYear; - this.numbers = EnglishDateTime.Numbers; - this.doubleNumbers = EnglishDateTime.DoubleNumbers; - this.cardinalExtractor = new EnglishCardinalExtractor(); - this.integerExtractor = new EnglishIntegerExtractor(); - this.ordinalExtractor = new EnglishOrdinalExtractor(); - this.dayOfMonth = new Map([...BaseDateTime.DayOfMonthDictionary, ...EnglishDateTime.DayOfMonth]); - this.numberParser = new BaseNumberParser(new EnglishNumberParserConfiguration()); - this.dateExtractor = new BaseDateExtractor(new EnglishDateExtractorConfiguration(dmyDateFormat)); - this.timeExtractor = new BaseTimeExtractor(new EnglishTimeExtractorConfiguration()); - this.dateTimeExtractor = new BaseDateTimeExtractor(new EnglishDateTimeExtractorConfiguration(dmyDateFormat)); - this.durationExtractor = new BaseDurationExtractor(new EnglishDurationExtractorConfiguration()); - this.datePeriodExtractor = new BaseDatePeriodExtractor(new EnglishDatePeriodExtractorConfiguration(dmyDateFormat)); - this.timePeriodExtractor = new BaseTimePeriodExtractor(new EnglishTimePeriodExtractorConfiguration()); - this.dateTimePeriodExtractor = new BaseDateTimePeriodExtractor(new EnglishDateTimePeriodExtractorConfiguration(dmyDateFormat)); - this.durationParser = new BaseDurationParser(new EnglishDurationParserConfiguration(this)); - this.dateParser = new BaseDateParser(new EnglishDateParserConfiguration(this, dmyDateFormat)); - this.timeParser = new EnglishTimeParser(new EnglishTimeParserConfiguration(this)); - this.dateTimeParser = new BaseDateTimeParser(new EnglishDateTimeParserConfiguration(this)); - this.datePeriodParser = new BaseDatePeriodParser(new EnglishDatePeriodParserConfiguration(this)); - this.timePeriodParser = new BaseTimePeriodParser(new EnglishTimePeriodParserConfiguration(this)); - this.dateTimePeriodParser = new BaseDateTimePeriodParser(new EnglishDateTimePeriodParserConfiguration(this)); - } -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-date-time/src/dateTime/english/dateConfiguration.ts b/JavaScript/packages/recognizers-date-time/src/dateTime/english/dateConfiguration.ts deleted file mode 100644 index 4a159d8d82..0000000000 --- a/JavaScript/packages/recognizers-date-time/src/dateTime/english/dateConfiguration.ts +++ /dev/null @@ -1,228 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { IDateExtractorConfiguration, IDateParserConfiguration } from "../baseDate"; -import { BaseDurationExtractor, BaseDurationParser } from "../baseDuration"; -import { IDateTimeUtilityConfiguration } from "../utilities"; -import { RegExpUtility } from "@microsoft/recognizers-text"; -import { BaseNumberParser, BaseNumberExtractor, EnglishOrdinalExtractor, EnglishIntegerExtractor, EnglishNumberParserConfiguration } from "@microsoft/recognizers-text-number"; -import { EnglishDateTime } from "../../resources/englishDateTime"; -import { EnglishCommonDateTimeParserConfiguration, EnglishDateTimeUtilityConfiguration } from "./baseConfiguration"; -import { EnglishDurationExtractorConfiguration } from "./durationConfiguration"; -import { IDateTimeParser } from "../parsers"; -import { IDateTimeExtractor } from "../baseDateTime"; -import { Constants } from "../constants"; - -export class EnglishDateExtractorConfiguration implements IDateExtractorConfiguration { - readonly dateRegexList: RegExp[]; - readonly implicitDateList: RegExp[]; - readonly monthEnd: RegExp; - readonly ofMonth: RegExp; - readonly dateUnitRegex: RegExp; - readonly forTheRegex: RegExp; - readonly weekDayAndDayOfMonthRegex: RegExp; - readonly relativeMonthRegex: RegExp; - readonly strictRelativeRegex: RegExp; - readonly weekDayRegex: RegExp; - readonly dayOfWeek: ReadonlyMap; - readonly ordinalExtractor: BaseNumberExtractor; - readonly integerExtractor: BaseNumberExtractor; - readonly numberParser: BaseNumberParser; - readonly durationExtractor: IDateTimeExtractor; - readonly utilityConfiguration: IDateTimeUtilityConfiguration; - readonly rangeConnectorSymbolRegex : RegExp; - - constructor(dmyDateFormat: boolean) { - - let enableDmy = dmyDateFormat || EnglishDateTime.DefaultLanguageFallback === Constants.DefaultLanguageFallback_DMY; - - this.dateRegexList = [ - RegExpUtility.getSafeRegExp(EnglishDateTime.DateExtractor1), - RegExpUtility.getSafeRegExp(EnglishDateTime.DateExtractor3), - - enableDmy ? - RegExpUtility.getSafeRegExp(EnglishDateTime.DateExtractor5) : - RegExpUtility.getSafeRegExp(EnglishDateTime.DateExtractor4), - - enableDmy ? - RegExpUtility.getSafeRegExp(EnglishDateTime.DateExtractor4) : - RegExpUtility.getSafeRegExp(EnglishDateTime.DateExtractor5), - - RegExpUtility.getSafeRegExp(EnglishDateTime.DateExtractor6), - - enableDmy ? - RegExpUtility.getSafeRegExp(EnglishDateTime.DateExtractor9L) : - RegExpUtility.getSafeRegExp(EnglishDateTime.DateExtractor7L), - - enableDmy ? - RegExpUtility.getSafeRegExp(EnglishDateTime.DateExtractor9S) : - RegExpUtility.getSafeRegExp(EnglishDateTime.DateExtractor7S), - - RegExpUtility.getSafeRegExp(EnglishDateTime.DateExtractor8), - - enableDmy ? - RegExpUtility.getSafeRegExp(EnglishDateTime.DateExtractor7L) : - RegExpUtility.getSafeRegExp(EnglishDateTime.DateExtractor9L), - - enableDmy ? - RegExpUtility.getSafeRegExp(EnglishDateTime.DateExtractor7S) : - RegExpUtility.getSafeRegExp(EnglishDateTime.DateExtractor9S), - - RegExpUtility.getSafeRegExp(EnglishDateTime.DateExtractorA), - ]; - this.implicitDateList = [ - RegExpUtility.getSafeRegExp(EnglishDateTime.OnRegex), - RegExpUtility.getSafeRegExp(EnglishDateTime.RelaxedOnRegex), - RegExpUtility.getSafeRegExp(EnglishDateTime.SpecialDayRegex), - RegExpUtility.getSafeRegExp(EnglishDateTime.SpecialDayWithNumRegex), - RegExpUtility.getSafeRegExp(EnglishDateTime.ThisRegex), - RegExpUtility.getSafeRegExp(EnglishDateTime.LastDateRegex), - RegExpUtility.getSafeRegExp(EnglishDateTime.NextDateRegex), - RegExpUtility.getSafeRegExp(EnglishDateTime.SingleWeekDayRegex), - RegExpUtility.getSafeRegExp(EnglishDateTime.WeekDayOfMonthRegex), - RegExpUtility.getSafeRegExp(EnglishDateTime.SpecialDate), - RegExpUtility.getSafeRegExp(EnglishDateTime.RelativeWeekDayRegex), - ]; - this.monthEnd = RegExpUtility.getSafeRegExp(EnglishDateTime.MonthEnd); - this.ofMonth = RegExpUtility.getSafeRegExp(EnglishDateTime.OfMonth); - this.dateUnitRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.DateUnitRegex); - this.forTheRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.ForTheRegex); - this.weekDayAndDayOfMonthRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.WeekDayAndDayOfMonthRegex); - this.relativeMonthRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.RelativeMonthRegex); - this.strictRelativeRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.StrictRelativeRegex); - this.weekDayRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.WeekDayRegex); - this.dayOfWeek = EnglishDateTime.DayOfWeek; - this.ordinalExtractor = new EnglishOrdinalExtractor(); - this.integerExtractor = new EnglishIntegerExtractor(); - this.numberParser = new BaseNumberParser(new EnglishNumberParserConfiguration()); - this.durationExtractor = new BaseDurationExtractor(new EnglishDurationExtractorConfiguration()); - this.utilityConfiguration = new EnglishDateTimeUtilityConfiguration(); - this.rangeConnectorSymbolRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.RangeConnectorRegex); - } -} - -export class EnglishDateParserConfiguration implements IDateParserConfiguration { - readonly ordinalExtractor: BaseNumberExtractor - readonly integerExtractor: BaseNumberExtractor - readonly cardinalExtractor: BaseNumberExtractor - readonly durationExtractor: IDateTimeExtractor - readonly numberParser: BaseNumberParser - readonly durationParser: IDateTimeParser - readonly monthOfYear: ReadonlyMap - readonly dayOfMonth: ReadonlyMap - readonly dayOfWeek: ReadonlyMap - readonly unitMap: ReadonlyMap - readonly cardinalMap: ReadonlyMap - readonly dateRegex: RegExp[] - readonly onRegex: RegExp - readonly specialDayRegex: RegExp - readonly specialDayWithNumRegex: RegExp - readonly nextRegex: RegExp - readonly unitRegex: RegExp - readonly monthRegex: RegExp - readonly weekDayRegex: RegExp - readonly lastRegex: RegExp - readonly thisRegex: RegExp - readonly weekDayOfMonthRegex: RegExp - readonly forTheRegex: RegExp; - readonly weekDayAndDayOfMonthRegex: RegExp; - readonly relativeMonthRegex: RegExp; - readonly strictRelativeRegex: RegExp; - readonly relativeWeekDayRegex: RegExp; - readonly utilityConfiguration: IDateTimeUtilityConfiguration - readonly dateTokenPrefix: string - - // The following three regexes only used in this configuration - // They are not used in the base parser, therefore they are not extracted - // If the spanish date parser need the same regexes, they should be extracted - static readonly relativeDayRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.RelativeDayRegex); - static readonly nextPrefixRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.NextPrefixRegex); - static readonly previousPrefixRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.PreviousPrefixRegex); - - constructor(config: EnglishCommonDateTimeParserConfiguration, dmyDateFormat: boolean) { - this.ordinalExtractor = config.ordinalExtractor; - this.integerExtractor = config.integerExtractor; - this.cardinalExtractor = config.cardinalExtractor; - this.durationExtractor = config.durationExtractor; - this.numberParser = config.numberParser; - this.durationParser = config.durationParser; - this.monthOfYear = config.monthOfYear; - this.dayOfMonth = config.dayOfMonth; - this.dayOfWeek = config.dayOfWeek; - this.unitMap = config.unitMap; - this.cardinalMap = config.cardinalMap; - this.dateRegex = new EnglishDateExtractorConfiguration(dmyDateFormat).dateRegexList; - this.onRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.OnRegex); - this.specialDayRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.SpecialDayRegex); - this.specialDayWithNumRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.SpecialDayWithNumRegex); - this.nextRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.NextDateRegex); - this.unitRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.DateUnitRegex); - this.monthRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.MonthRegex); - this.weekDayRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.WeekDayRegex); - this.lastRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.LastDateRegex); - this.thisRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.ThisRegex); - this.weekDayOfMonthRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.WeekDayOfMonthRegex); - this.forTheRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.ForTheRegex); - this.weekDayAndDayOfMonthRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.WeekDayAndDayOfMonthRegex); - this.relativeMonthRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.RelativeMonthRegex); - this.strictRelativeRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.StrictRelativeRegex); - this.relativeWeekDayRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.RelativeWeekDayRegex); - this.utilityConfiguration = config.utilityConfiguration; - this.dateTokenPrefix = EnglishDateTime.DateTokenPrefix; - } - - getSwiftDay(source: string): number { - let trimmedText = source.trim().toLowerCase(); - let swift = 0; - let matches = RegExpUtility.getMatches(EnglishDateParserConfiguration.relativeDayRegex, source); - if (trimmedText === "today") { - swift = 0; - } - else if (trimmedText === "tomorrow" || trimmedText === "tmr") { - swift = 1; - } - else if (trimmedText === "yesterday") { - swift = -1; - } - else if (trimmedText.endsWith("day after tomorrow") || - trimmedText.endsWith("day after tmr")) { - swift = 2; - } - else if (trimmedText.endsWith("day before yesterday")) { - swift = -2; - } - else if (trimmedText.endsWith("day after")) { - swift = 1; - } - else if (trimmedText.endsWith("day before")) { - swift = -1; - } - else if (matches.length) { - swift = this.getSwift(source); - } - return swift; - } - - getSwiftMonthOrYear(source: string): number { - return this.getSwift(source); - } - - getSwift(source: string): number { - let trimmedText = source.trim().toLowerCase(); - let swift = 0; - let nextPrefixMatches = RegExpUtility.getMatches(EnglishDateParserConfiguration.nextPrefixRegex, trimmedText); - let pastPrefixMatches = RegExpUtility.getMatches(EnglishDateParserConfiguration.previousPrefixRegex, trimmedText); - if (nextPrefixMatches.length) { - swift = 1; - } - else if (pastPrefixMatches.length) { - swift = -1; - } - return swift; - } - - isCardinalLast(source: string): boolean { - let trimmedText = source.trim().toLowerCase(); - return trimmedText === "last"; - } -} diff --git a/JavaScript/packages/recognizers-date-time/src/dateTime/english/datePeriodConfiguration.ts b/JavaScript/packages/recognizers-date-time/src/dateTime/english/datePeriodConfiguration.ts deleted file mode 100644 index 518058234f..0000000000 --- a/JavaScript/packages/recognizers-date-time/src/dateTime/english/datePeriodConfiguration.ts +++ /dev/null @@ -1,256 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { IDatePeriodExtractorConfiguration, IDatePeriodParserConfiguration } from "../baseDatePeriod"; -import { BaseDateExtractor, BaseDateParser } from "../baseDate"; -import { RegExpUtility } from "@microsoft/recognizers-text"; -import { BaseNumberParser, BaseNumberExtractor, EnglishIntegerExtractor, EnglishNumberParserConfiguration } from "@microsoft/recognizers-text-number"; -import { BaseDurationExtractor, BaseDurationParser } from "../baseDuration"; -import { BaseDateTime } from "../../resources/baseDateTime"; -import { EnglishDateTime } from "../../resources/englishDateTime"; -import { EnglishCommonDateTimeParserConfiguration } from "./baseConfiguration"; -import { EnglishDurationExtractorConfiguration } from "./durationConfiguration"; -import { EnglishDateExtractorConfiguration } from "./dateConfiguration"; -import { IDateTimeExtractor } from "../baseDateTime"; - -export class EnglishDatePeriodExtractorConfiguration implements IDatePeriodExtractorConfiguration { - readonly simpleCasesRegexes: RegExp[] - readonly illegalYearRegex: RegExp - readonly YearRegex: RegExp - readonly tillRegex: RegExp - readonly followedUnit: RegExp - readonly numberCombinedWithUnit: RegExp - readonly pastRegex: RegExp - readonly futureRegex: RegExp - readonly weekOfRegex: RegExp - readonly monthOfRegex: RegExp - readonly dateUnitRegex: RegExp - readonly inConnectorRegex: RegExp - readonly rangeUnitRegex: RegExp - readonly datePointExtractor: IDateTimeExtractor - readonly integerExtractor: BaseNumberExtractor - readonly numberParser: BaseNumberParser - readonly durationExtractor: IDateTimeExtractor - readonly rangeConnectorRegex: RegExp - readonly nowRegex: RegExp - - constructor(dmyDateFormat: boolean) { - this.simpleCasesRegexes = [ - RegExpUtility.getSafeRegExp(EnglishDateTime.SimpleCasesRegex), - RegExpUtility.getSafeRegExp(EnglishDateTime.BetweenRegex), - RegExpUtility.getSafeRegExp(EnglishDateTime.OneWordPeriodRegex), - RegExpUtility.getSafeRegExp(EnglishDateTime.MonthWithYear), - RegExpUtility.getSafeRegExp(EnglishDateTime.MonthNumWithYear), - RegExpUtility.getSafeRegExp(EnglishDateTime.YearRegex), - RegExpUtility.getSafeRegExp(EnglishDateTime.WeekOfMonthRegex), - RegExpUtility.getSafeRegExp(EnglishDateTime.WeekOfYearRegex), - RegExpUtility.getSafeRegExp(EnglishDateTime.MonthFrontBetweenRegex), - RegExpUtility.getSafeRegExp(EnglishDateTime.MonthFrontSimpleCasesRegex), - RegExpUtility.getSafeRegExp(EnglishDateTime.QuarterRegex), - RegExpUtility.getSafeRegExp(EnglishDateTime.QuarterRegexYearFront), - RegExpUtility.getSafeRegExp(EnglishDateTime.AllHalfYearRegex), - RegExpUtility.getSafeRegExp(EnglishDateTime.SeasonRegex), - RegExpUtility.getSafeRegExp(EnglishDateTime.WhichWeekRegex), - RegExpUtility.getSafeRegExp(EnglishDateTime.RestOfDateRegex), - RegExpUtility.getSafeRegExp(EnglishDateTime.LaterEarlyPeriodRegex), - RegExpUtility.getSafeRegExp(EnglishDateTime.WeekWithWeekDayRangeRegex) - ]; - this.illegalYearRegex = RegExpUtility.getSafeRegExp(BaseDateTime.IllegalYearRegex); - this.YearRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.YearRegex); - this.tillRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.TillRegex); - this.followedUnit = RegExpUtility.getSafeRegExp(EnglishDateTime.FollowedDateUnit); - this.numberCombinedWithUnit = RegExpUtility.getSafeRegExp(EnglishDateTime.NumberCombinedWithDateUnit); - this.pastRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.PreviousPrefixRegex); - this.futureRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.NextPrefixRegex); - this.weekOfRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.WeekOfRegex); - this.monthOfRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.MonthOfRegex); - this.dateUnitRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.DateUnitRegex); - this.inConnectorRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.InConnectorRegex); - this.rangeUnitRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.RangeUnitRegex); - this.datePointExtractor = new BaseDateExtractor(new EnglishDateExtractorConfiguration(dmyDateFormat)); - this.integerExtractor = new EnglishIntegerExtractor(); - this.numberParser = new BaseNumberParser(new EnglishNumberParserConfiguration()); - this.durationExtractor = new BaseDurationExtractor(new EnglishDurationExtractorConfiguration()); - this.rangeConnectorRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.RangeConnectorRegex); - this.nowRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.NowRegex); - } - - getFromTokenIndex(source: string) { - let result = { matched: false, index: -1 }; - if (source.endsWith("from")) { - result.index = source.lastIndexOf("from"); - result.matched = true; - } - return result; - }; - - getBetweenTokenIndex(source: string) { - let result = { matched: false, index: -1 }; - if (source.endsWith("between")) { - result.index = source.lastIndexOf("between"); - result.matched = true; - } - return result; - }; - - hasConnectorToken(source: string): boolean { - let match = RegExpUtility.getMatches(this.rangeConnectorRegex, source).pop(); - return match && match.length === source.length; - }; -} - -export class EnglishDatePeriodParserConfiguration implements IDatePeriodParserConfiguration { - readonly dateExtractor: IDateTimeExtractor - readonly dateParser: BaseDateParser - readonly durationExtractor: IDateTimeExtractor - readonly durationParser: BaseDurationParser - readonly integerExtractor: BaseNumberExtractor - readonly numberParser: BaseNumberParser - readonly monthFrontBetweenRegex: RegExp - readonly betweenRegex: RegExp - readonly monthFrontSimpleCasesRegex: RegExp - readonly simpleCasesRegex: RegExp - readonly oneWordPeriodRegex: RegExp - readonly monthWithYear: RegExp - readonly monthNumWithYear: RegExp - readonly yearRegex: RegExp - readonly relativeRegex: RegExp - readonly pastRegex: RegExp - readonly futureRegex: RegExp - readonly inConnectorRegex: RegExp - readonly weekOfMonthRegex: RegExp - readonly weekOfYearRegex: RegExp - readonly quarterRegex: RegExp - readonly quarterRegexYearFront: RegExp - readonly allHalfYearRegex: RegExp - readonly seasonRegex: RegExp - readonly weekOfRegex: RegExp - readonly monthOfRegex: RegExp - readonly whichWeekRegex: RegExp - readonly nextPrefixRegex: RegExp - readonly previousPrefixRegex: RegExp - readonly thisPrefixRegex: RegExp - readonly restOfDateRegex: RegExp - readonly laterEarlyPeriodRegex: RegExp - readonly weekWithWeekDayRangeRegex: RegExp - readonly unspecificEndOfRangeRegex: RegExp - readonly nowRegex: RegExp - readonly tokenBeforeDate: string - readonly dayOfMonth: ReadonlyMap - readonly monthOfYear: ReadonlyMap - readonly cardinalMap: ReadonlyMap - readonly seasonMap: ReadonlyMap - readonly unitMap: ReadonlyMap - - constructor(config: EnglishCommonDateTimeParserConfiguration) { - this.dateExtractor = config.dateExtractor; - this.dateParser = config.dateParser; - this.durationExtractor = config.durationExtractor; - this.durationParser = config.durationParser; - this.numberParser = config.numberParser; - this.integerExtractor = config.integerExtractor; - this.monthFrontBetweenRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.MonthFrontBetweenRegex); - this.betweenRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.BetweenRegex); - this.monthFrontSimpleCasesRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.MonthFrontSimpleCasesRegex); - this.simpleCasesRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.SimpleCasesRegex); - this.oneWordPeriodRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.OneWordPeriodRegex); - this.monthWithYear = RegExpUtility.getSafeRegExp(EnglishDateTime.MonthWithYear); - this.monthNumWithYear = RegExpUtility.getSafeRegExp(EnglishDateTime.MonthNumWithYear); - this.yearRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.YearRegex); - this.pastRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.PreviousPrefixRegex); - this.relativeRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.RelativeRegex); - this.futureRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.NextPrefixRegex); - this.inConnectorRegex = config.utilityConfiguration.inConnectorRegex; - this.weekOfMonthRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.WeekOfMonthRegex); - this.weekOfYearRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.WeekOfYearRegex); - this.quarterRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.QuarterRegex); - this.quarterRegexYearFront = RegExpUtility.getSafeRegExp(EnglishDateTime.QuarterRegexYearFront); - this.allHalfYearRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.AllHalfYearRegex); - this.seasonRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.SeasonRegex); - this.weekOfRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.WeekOfRegex); - this.monthOfRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.MonthOfRegex); - this.whichWeekRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.WhichWeekRegex); - this.nextPrefixRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.NextPrefixRegex); - this.previousPrefixRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.PreviousPrefixRegex); - this.thisPrefixRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.ThisPrefixRegex); - this.restOfDateRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.RestOfDateRegex); - this.laterEarlyPeriodRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.LaterEarlyPeriodRegex); - this.weekWithWeekDayRangeRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.WeekWithWeekDayRangeRegex); - this.unspecificEndOfRangeRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.UnspecificEndOfRangeRegex); - this.nowRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.NowRegex); - this.tokenBeforeDate = EnglishDateTime.TokenBeforeDate; - this.dayOfMonth = config.dayOfMonth; - this.monthOfYear = config.monthOfYear; - this.cardinalMap = config.cardinalMap; - this.seasonMap = config.seasonMap; - this.unitMap = config.unitMap; - } - - getSwiftDayOrMonth(source: string): number { - let trimmedSource = source.trim().toLowerCase(); - let swift = 0; - if (RegExpUtility.getMatches(this.nextPrefixRegex, trimmedSource).length > 0) { - swift = 1; - } - else if (RegExpUtility.getMatches(this.previousPrefixRegex, trimmedSource).length > 0) { - swift = -1; - } - return swift; - } - - getSwiftYear(source: string): number { - let trimmedSource = source.trim().toLowerCase(); - let swift = -10; - if (RegExpUtility.getMatches(this.nextPrefixRegex, trimmedSource).length > 0) { - swift = 1; - } - else if (RegExpUtility.getMatches(this.previousPrefixRegex, trimmedSource).length > 0) { - swift = -1; - } - else if (RegExpUtility.getMatches(this.thisPrefixRegex, trimmedSource).length > 0) { - swift = 0; - } - return swift; - } - - isFuture(source: string): boolean { - let trimmedSource = source.trim().toLowerCase(); - return EnglishDateTime.FutureTerms.some(o => trimmedSource.startsWith(o)); - } - - isYearToDate(source: string): boolean { - let trimmedSource = source.trim().toLowerCase(); - return EnglishDateTime.YearToDateTerms.some(o => trimmedSource === o); - } - - isMonthToDate(source: string): boolean { - let trimmedSource = source.trim().toLowerCase(); - return EnglishDateTime.MonthToDateTerms.some(o => trimmedSource === o); - } - - isWeekOnly(source: string): boolean { - let trimmedSource = source.trim().toLowerCase(); - return EnglishDateTime.WeekTerms.some(o => trimmedSource.endsWith(o)); - } - - isWeekend(source: string): boolean { - let trimmedSource = source.trim().toLowerCase(); - return EnglishDateTime.WeekendTerms.some(o => trimmedSource.endsWith(o)); - } - - isMonthOnly(source: string): boolean { - let trimmedSource = source.trim().toLowerCase(); - return EnglishDateTime.MonthTerms.some(o => trimmedSource.endsWith(o)); - } - - isYearOnly(source: string): boolean { - let trimmedSource = source.trim().toLowerCase(); - return EnglishDateTime.YearTerms.some(o => trimmedSource.endsWith(o)) || - (EnglishDateTime.GenericYearTerms.some(o => trimmedSource.endsWith(o) && RegExpUtility.isMatch(this.unspecificEndOfRangeRegex, trimmedSource))); - } - - isLastCardinal(source: string): boolean { - let trimmedSource = source.trim().toLowerCase(); - return EnglishDateTime.LastCardinalTerms.some(o => trimmedSource === o); - } -} diff --git a/JavaScript/packages/recognizers-date-time/src/dateTime/english/dateTimeConfiguration.ts b/JavaScript/packages/recognizers-date-time/src/dateTime/english/dateTimeConfiguration.ts deleted file mode 100644 index 8d114e42fc..0000000000 --- a/JavaScript/packages/recognizers-date-time/src/dateTime/english/dateTimeConfiguration.ts +++ /dev/null @@ -1,161 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { IDateTimeExtractor, IDateTimeExtractorConfiguration, IDateTimeParserConfiguration } from "../baseDateTime"; -import { BaseDateExtractor, BaseDateParser } from "../baseDate"; -import { BaseTimeExtractor, BaseTimeParser } from "../baseTime"; -import { RegExpUtility, StringUtility } from "@microsoft/recognizers-text"; -import { BaseNumberExtractor, BaseNumberParser } from "@microsoft/recognizers-text-number"; -import { BaseDurationExtractor, BaseDurationParser } from "../baseDuration"; -import { EnglishDateTime } from "../../resources/englishDateTime"; -import { ICommonDateTimeParserConfiguration, IDateTimeParser } from "../parsers"; -import { EnglishDateTimeUtilityConfiguration } from "./baseConfiguration"; -import { IDateTimeUtilityConfiguration } from "../utilities"; -import { EnglishDurationExtractorConfiguration } from "./durationConfiguration"; -import { EnglishDateExtractorConfiguration } from "./dateConfiguration"; -import { EnglishTimeExtractorConfiguration } from "./timeConfiguration"; - -export class EnglishDateTimeExtractorConfiguration implements IDateTimeExtractorConfiguration { - readonly datePointExtractor: IDateTimeExtractor - readonly timePointExtractor: IDateTimeExtractor - readonly durationExtractor: IDateTimeExtractor - readonly suffixRegex: RegExp - readonly nowRegex: RegExp - readonly timeOfTodayAfterRegex: RegExp - readonly simpleTimeOfTodayAfterRegex: RegExp - readonly nightRegex: RegExp - readonly timeOfTodayBeforeRegex: RegExp - readonly simpleTimeOfTodayBeforeRegex: RegExp - readonly specificEndOfRegex: RegExp - readonly unspecificEndOfRegex: RegExp - readonly unitRegex: RegExp - readonly prepositionRegex: RegExp - readonly connectorRegex: RegExp - readonly utilityConfiguration: IDateTimeUtilityConfiguration - - constructor(dmyDateFormat: boolean) { - this.datePointExtractor = new BaseDateExtractor(new EnglishDateExtractorConfiguration(dmyDateFormat)); - this.timePointExtractor = new BaseTimeExtractor(new EnglishTimeExtractorConfiguration()); - this.durationExtractor = new BaseDurationExtractor(new EnglishDurationExtractorConfiguration()); - this.suffixRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.SuffixRegex); - this.nowRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.NowRegex); - this.timeOfTodayAfterRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.TimeOfTodayAfterRegex); - this.simpleTimeOfTodayAfterRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.SimpleTimeOfTodayAfterRegex); - this.nightRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.TimeOfDayRegex); - this.timeOfTodayBeforeRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.TimeOfTodayBeforeRegex); - this.simpleTimeOfTodayBeforeRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.SimpleTimeOfTodayBeforeRegex); - this.specificEndOfRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.SpecificEndOfRegex); - this.unspecificEndOfRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.UnspecificEndOfRegex); - this.unitRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.TimeUnitRegex); - this.prepositionRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.PrepositionRegex); - this.connectorRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.ConnectorRegex); - this.utilityConfiguration = new EnglishDateTimeUtilityConfiguration(); - } - - isConnectorToken(source: string): boolean { - return (StringUtility.isNullOrWhitespace(source) - || RegExpUtility.getMatches(this.connectorRegex, source).length > 0 - || RegExpUtility.getMatches(this.prepositionRegex, source).length > 0); - } -} - - -export class EnglishDateTimeParserConfiguration implements IDateTimeParserConfiguration { - tokenBeforeDate: string; - tokenBeforeTime: string; - dateExtractor: IDateTimeExtractor; - timeExtractor: IDateTimeExtractor; - dateParser: BaseDateParser; - timeParser: BaseTimeParser; - cardinalExtractor: BaseNumberExtractor; - numberParser: BaseNumberParser; - durationExtractor: IDateTimeExtractor; - durationParser: IDateTimeParser; - nowRegex: RegExp; - amTimeRegex: RegExp; - pmTimeRegex: RegExp; - simpleTimeOfTodayAfterRegex: RegExp; - simpleTimeOfTodayBeforeRegex: RegExp; - specificTimeOfDayRegex: RegExp; - specificEndOfRegex: RegExp; - unspecificEndOfRegex: RegExp; - unitRegex: RegExp; - unitMap: ReadonlyMap; - numbers: ReadonlyMap; - utilityConfiguration: IDateTimeUtilityConfiguration; - nowTimeRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.NowTimeRegex); - recentlyTimeRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.RecentlyTimeRegex); - asapTimeRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.AsapTimeRegex); - - constructor(config: ICommonDateTimeParserConfiguration) { - this.tokenBeforeDate = EnglishDateTime.TokenBeforeDate; - this.tokenBeforeTime = EnglishDateTime.TokenBeforeTime; - this.dateExtractor = config.dateExtractor; - this.timeExtractor = config.timeExtractor; - this.dateParser = config.dateParser; - this.timeParser = config.timeParser; - this.nowRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.NowRegex); - this.amTimeRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.AMTimeRegex); - this.pmTimeRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.PMTimeRegex); - this.simpleTimeOfTodayAfterRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.SimpleTimeOfTodayAfterRegex); - this.simpleTimeOfTodayBeforeRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.SimpleTimeOfTodayBeforeRegex); - this.specificTimeOfDayRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.SpecificTimeOfDayRegex); - this.specificEndOfRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.SpecificEndOfRegex); - this.unspecificEndOfRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.UnspecificEndOfRegex); - this.unitRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.TimeUnitRegex); - this.numbers = config.numbers; - this.cardinalExtractor = config.cardinalExtractor; - this.numberParser = config.numberParser; - this.durationExtractor = config.durationExtractor; - this.durationParser = config.durationParser; - this.unitMap = config.unitMap; - this.utilityConfiguration = config.utilityConfiguration; - } - - public getHour(text: string, hour: number): number { - let trimmedText = text.trim().toLowerCase(); - let result = hour; - if (trimmedText.endsWith("morning") && hour >= 12) { - result -= 12; - } - else if (!trimmedText.endsWith("morning") && hour < 12 && !(trimmedText.endsWith("night") && hour < 6)) { - result += 12; - } - return result; - } - - public getMatchedNowTimex(text: string): { matched: boolean, timex: string } { - let trimmedText = text.trim().toLowerCase(); - let timex: string; - if (RegExpUtility.isMatch(this.nowTimeRegex, trimmedText)) { - timex = "PRESENT_REF"; - } - else if (RegExpUtility.isMatch(this.recentlyTimeRegex, trimmedText)) { - timex = "PAST_REF"; - } - else if (RegExpUtility.isMatch(this.asapTimeRegex, trimmedText)) { - timex = "FUTURE_REF"; - } - else { - timex = null; - return { matched: false, timex: timex }; - } - return { matched: true, timex: timex }; - } - - public getSwiftDay(text: string): number { - let trimmedText = text.trim().toLowerCase(); - let swift = 0; - if (trimmedText.startsWith("next")) { - swift = 1; - } - else if (trimmedText.startsWith("last")) { - swift = -1; - } - return swift; - } - - public haveAmbiguousToken(text: string, matchedText: string): boolean { - return false; - } -} diff --git a/JavaScript/packages/recognizers-date-time/src/dateTime/english/dateTimePeriodConfiguration.ts b/JavaScript/packages/recognizers-date-time/src/dateTime/english/dateTimePeriodConfiguration.ts deleted file mode 100644 index 77652f1eda..0000000000 --- a/JavaScript/packages/recognizers-date-time/src/dateTime/english/dateTimePeriodConfiguration.ts +++ /dev/null @@ -1,195 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { IExtractor } from "@microsoft/recognizers-text"; -import { IDateTimePeriodExtractorConfiguration, IDateTimePeriodParserConfiguration } from "../baseDateTimePeriod"; -import { BaseDateExtractor, BaseDateParser } from "../baseDate"; -import { BaseTimeExtractor, BaseTimeParser } from "../baseTime"; -import { IDateTimeExtractor, BaseDateTimeExtractor, BaseDateTimeParser } from "../baseDateTime"; -import { BaseTimePeriodExtractor } from "../baseTimePeriod"; -import { BaseDurationExtractor, BaseDurationParser } from "../baseDuration"; -import { RegExpUtility } from "@microsoft/recognizers-text"; -import { EnglishCardinalExtractor } from "@microsoft/recognizers-text-number"; -import { EnglishDateTime } from "../../resources/englishDateTime"; -import { EnglishCommonDateTimeParserConfiguration } from "./baseConfiguration"; -import { EnglishDurationExtractorConfiguration } from "./durationConfiguration"; -import { EnglishTimeExtractorConfiguration } from "./timeConfiguration"; -import { EnglishDateTimeExtractorConfiguration } from "./dateTimeConfiguration"; -import { EnglishDateExtractorConfiguration } from "./dateConfiguration"; -import { EnglishTimePeriodExtractorConfiguration } from "../english/timePeriodConfiguration"; -import { IDateTimeParser } from "../parsers"; - -export class EnglishDateTimePeriodExtractorConfiguration implements IDateTimePeriodExtractorConfiguration { - readonly cardinalExtractor: EnglishCardinalExtractor - readonly singleDateExtractor: IDateTimeExtractor - readonly singleTimeExtractor: IDateTimeExtractor - readonly singleDateTimeExtractor: IDateTimeExtractor - readonly durationExtractor: IDateTimeExtractor - readonly timePeriodExtractor: IDateTimeExtractor - readonly simpleCasesRegexes: RegExp[] - readonly prepositionRegex: RegExp - readonly tillRegex: RegExp - readonly specificTimeOfDayRegex: RegExp - readonly timeOfDayRegex: RegExp - readonly periodTimeOfDayWithDateRegex: RegExp - readonly followedUnit: RegExp - readonly numberCombinedWithUnit: RegExp - readonly timeUnitRegex: RegExp - readonly previousPrefixRegex: RegExp - readonly nextPrefixRegex: RegExp - readonly rangeConnectorRegex: RegExp - readonly relativeTimeUnitRegex: RegExp - readonly restOfDateTimeRegex: RegExp - readonly generalEndingRegex: RegExp - readonly middlePauseRegex: RegExp - - constructor(dmyDateFormat: boolean) { - this.cardinalExtractor = new EnglishCardinalExtractor(); - this.singleDateExtractor = new BaseDateExtractor(new EnglishDateExtractorConfiguration(dmyDateFormat)); - this.singleTimeExtractor = new BaseTimeExtractor(new EnglishTimeExtractorConfiguration()); - this.singleDateTimeExtractor = new BaseDateTimeExtractor(new EnglishDateTimeExtractorConfiguration(dmyDateFormat)); - this.durationExtractor = new BaseDurationExtractor(new EnglishDurationExtractorConfiguration()); - this.timePeriodExtractor = new BaseTimePeriodExtractor(new EnglishTimePeriodExtractorConfiguration()); - this.simpleCasesRegexes = [ - RegExpUtility.getSafeRegExp(EnglishDateTime.PureNumFromTo), - RegExpUtility.getSafeRegExp(EnglishDateTime.PureNumBetweenAnd), - ]; - this.prepositionRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.PrepositionRegex); - this.tillRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.TillRegex); - this.specificTimeOfDayRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.PeriodSpecificTimeOfDayRegex); - this.timeOfDayRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.PeriodTimeOfDayRegex); - this.periodTimeOfDayWithDateRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.PeriodTimeOfDayWithDateRegex); - this.followedUnit = RegExpUtility.getSafeRegExp(EnglishDateTime.TimeFollowedUnit); - this.numberCombinedWithUnit = RegExpUtility.getSafeRegExp(EnglishDateTime.TimeNumberCombinedWithUnit); - this.timeUnitRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.TimeUnitRegex); - this.previousPrefixRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.PreviousPrefixRegex); - this.nextPrefixRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.NextPrefixRegex); - this.rangeConnectorRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.RangeConnectorRegex); - this.relativeTimeUnitRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.RelativeTimeUnitRegex); - this.restOfDateTimeRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.RestOfDateTimeRegex); - this.generalEndingRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.GeneralEndingRegex); - this.middlePauseRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.MiddlePauseRegex); - } - - getFromTokenIndex(source: string) { - let result = { matched: false, index: -1 }; - if (source.endsWith("from")) { - result.index = source.lastIndexOf("from"); - result.matched = true; - } - return result; - }; - - getBetweenTokenIndex(source: string) { - let result = { matched: false, index: -1 }; - if (source.endsWith("between")) { - result.index = source.lastIndexOf("between"); - result.matched = true; - } - return result; - }; - - hasConnectorToken(source: string): boolean { - let match = RegExpUtility.getMatches(this.rangeConnectorRegex, source).pop(); - return match && match.length === source.length; - }; -} - -export class EnglishDateTimePeriodParserConfiguration implements IDateTimePeriodParserConfiguration { - readonly pureNumberFromToRegex: RegExp - readonly pureNumberBetweenAndRegex: RegExp - readonly periodTimeOfDayWithDateRegex: RegExp - readonly specificTimeOfDayRegex: RegExp - readonly pastRegex: RegExp - readonly futureRegex: RegExp - readonly relativeTimeUnitRegex: RegExp - readonly numbers: ReadonlyMap - readonly unitMap: ReadonlyMap - readonly dateExtractor: IDateTimeExtractor - readonly timePeriodExtractor: IDateTimeExtractor - readonly timeExtractor: IDateTimeExtractor - readonly dateTimeExtractor: IDateTimeExtractor - readonly durationExtractor: IDateTimeExtractor - readonly dateParser: BaseDateParser - readonly timeParser: BaseTimeParser - readonly dateTimeParser: BaseDateTimeParser - readonly timePeriodParser: IDateTimeParser - readonly durationParser: BaseDurationParser - readonly morningStartEndRegex: RegExp - readonly afternoonStartEndRegex: RegExp - readonly eveningStartEndRegex: RegExp - readonly nightStartEndRegex: RegExp - readonly restOfDateTimeRegex: RegExp - - constructor(config: EnglishCommonDateTimeParserConfiguration) { - this.pureNumberFromToRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.PureNumFromTo); - this.pureNumberBetweenAndRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.PureNumBetweenAnd); - this.periodTimeOfDayWithDateRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.PeriodTimeOfDayWithDateRegex); - this.specificTimeOfDayRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.PeriodSpecificTimeOfDayRegex); - this.pastRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.PreviousPrefixRegex); - this.futureRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.NextPrefixRegex); - this.relativeTimeUnitRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.RelativeTimeUnitRegex); - this.numbers = config.numbers; - this.unitMap = config.unitMap; - this.dateExtractor = config.dateExtractor; - this.timePeriodExtractor = config.timePeriodExtractor; - this.timeExtractor = config.timeExtractor; - this.dateTimeExtractor = config.dateTimeExtractor; - this.durationExtractor = config.durationExtractor; - this.dateParser = config.dateParser; - this.timeParser = config.timeParser; - this.dateTimeParser = config.dateTimeParser; - this.timePeriodParser = config.timePeriodParser; - this.durationParser = config.durationParser; - this.morningStartEndRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.MorningStartEndRegex); - this.afternoonStartEndRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.AfternoonStartEndRegex); - this.eveningStartEndRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.EveningStartEndRegex); - this.nightStartEndRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.NightStartEndRegex); - this.restOfDateTimeRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.RestOfDateTimeRegex); - } - - getMatchedTimeRange(source: string): { timeStr: string, beginHour: number, endHour: number, endMin: number, success: boolean } { - let timeStr: string; - let beginHour = 0; - let endHour = 0; - let endMin = 0; - let success = false; - if (RegExpUtility.getMatches(this.morningStartEndRegex, source).length > 0) { - timeStr = 'TMO'; - beginHour = 8; - endHour = 12; - success = true; - } - else if (RegExpUtility.getMatches(this.afternoonStartEndRegex, source).length > 0) { - timeStr = 'TAF'; - beginHour = 12; - endHour = 16; - success = true; - } - else if (RegExpUtility.getMatches(this.eveningStartEndRegex, source).length > 0) { - timeStr = 'TEV'; - beginHour = 16; - endHour = 20; - success = true; - } - else if (RegExpUtility.getMatches(this.nightStartEndRegex, source).length > 0) { - timeStr = 'TNI'; - beginHour = 20; - endHour = 23; - endMin = 59; - success = true; - } - return { timeStr: timeStr, beginHour: beginHour, endHour: endHour, endMin: endMin, success: success }; - } - - getSwiftPrefix(source: string): number { - let swift = 0; - if (source.startsWith('next')) { - swift = 1; - } - else if (source.startsWith('last')) { - swift = -1; - } - return swift; - } -} diff --git a/JavaScript/packages/recognizers-date-time/src/dateTime/english/durationConfiguration.ts b/JavaScript/packages/recognizers-date-time/src/dateTime/english/durationConfiguration.ts deleted file mode 100644 index 37cf23e88e..0000000000 --- a/JavaScript/packages/recognizers-date-time/src/dateTime/english/durationConfiguration.ts +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { IDurationExtractorConfiguration, IDurationParserConfiguration } from "../baseDuration"; -import { RegExpUtility } from "@microsoft/recognizers-text"; -import { BaseNumberExtractor, BaseNumberParser, EnglishCardinalExtractor } from "@microsoft/recognizers-text-number"; -import { EnglishDateTime } from "../../resources/englishDateTime"; -import { ICommonDateTimeParserConfiguration } from "../parsers"; - -export class EnglishDurationExtractorConfiguration implements IDurationExtractorConfiguration { - readonly allRegex: RegExp - readonly halfRegex: RegExp - readonly followedUnit: RegExp - readonly numberCombinedWithUnit: RegExp - readonly anUnitRegex: RegExp - readonly inexactNumberUnitRegex: RegExp - readonly suffixAndRegex: RegExp - readonly relativeDurationUnitRegex: RegExp - readonly moreThanRegex: RegExp; - readonly lessThanRegex: RegExp; - readonly cardinalExtractor: EnglishCardinalExtractor - - constructor() { - this.allRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.AllRegex); - this.halfRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.HalfRegex); - this.followedUnit = RegExpUtility.getSafeRegExp(EnglishDateTime.DurationFollowedUnit); - this.numberCombinedWithUnit = RegExpUtility.getSafeRegExp(EnglishDateTime.NumberCombinedWithDurationUnit); - this.anUnitRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.AnUnitRegex); - this.inexactNumberUnitRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.InexactNumberUnitRegex); - this.suffixAndRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.SuffixAndRegex); - this.relativeDurationUnitRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.RelativeDurationUnitRegex); - this.moreThanRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.MoreThanRegex); - this.lessThanRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.LessThanRegex); - this.cardinalExtractor = new EnglishCardinalExtractor(); - } -} - -export class EnglishDurationParserConfiguration implements IDurationParserConfiguration { - readonly cardinalExtractor: BaseNumberExtractor - readonly numberParser: BaseNumberParser - readonly followedUnit: RegExp - readonly suffixAndRegex: RegExp - readonly numberCombinedWithUnit: RegExp - readonly anUnitRegex: RegExp - readonly allDateUnitRegex: RegExp - readonly halfDateUnitRegex: RegExp - readonly inexactNumberUnitRegex: RegExp - readonly unitMap: ReadonlyMap - readonly unitValueMap: ReadonlyMap - readonly doubleNumbers: ReadonlyMap - - constructor(config: ICommonDateTimeParserConfiguration) { - this.cardinalExtractor = config.cardinalExtractor; - this.numberParser = config.numberParser; - this.followedUnit = RegExpUtility.getSafeRegExp(EnglishDateTime.DurationFollowedUnit); - this.suffixAndRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.SuffixAndRegex); - this.numberCombinedWithUnit = RegExpUtility.getSafeRegExp(EnglishDateTime.NumberCombinedWithDurationUnit); - this.anUnitRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.AnUnitRegex); - this.allDateUnitRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.AllRegex); - this.halfDateUnitRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.HalfRegex); - this.inexactNumberUnitRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.InexactNumberUnitRegex); - this.unitMap = config.unitMap; - this.unitValueMap = config.unitValueMap; - this.doubleNumbers = config.doubleNumbers; - } -} diff --git a/JavaScript/packages/recognizers-date-time/src/dateTime/english/holidayConfiguration.ts b/JavaScript/packages/recognizers-date-time/src/dateTime/english/holidayConfiguration.ts deleted file mode 100644 index 8ce4fab5fb..0000000000 --- a/JavaScript/packages/recognizers-date-time/src/dateTime/english/holidayConfiguration.ts +++ /dev/null @@ -1,188 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { IHolidayExtractorConfiguration, BaseHolidayParserConfiguration } from "../baseHoliday"; -import { RegExpUtility } from "@microsoft/recognizers-text"; -import { DateUtils } from "../utilities"; -import { EnglishDateTime } from "../../resources/englishDateTime"; - -export class EnglishHolidayExtractorConfiguration implements IHolidayExtractorConfiguration { - readonly holidayRegexes: RegExp[] - - constructor() { - this.holidayRegexes = [ - RegExpUtility.getSafeRegExp(EnglishDateTime.HolidayRegex, "gis") - ]; - } -} - -export class EnglishHolidayParserConfiguration extends BaseHolidayParserConfiguration { - constructor() { - super(); - this.holidayRegexList = [ - RegExpUtility.getSafeRegExp(EnglishDateTime.HolidayRegex, "gis") - ]; - this.holidayNames = EnglishDateTime.HolidayNames; - this.holidayFuncDictionary = this.initHolidayFuncs(); - } - - protected initHolidayFuncs(): ReadonlyMap Date> { - return new Map Date>( - [ - ...super.initHolidayFuncs(), - ["maosbirthday", EnglishHolidayParserConfiguration.MaoBirthday], - ["yuandan", EnglishHolidayParserConfiguration.NewYear], - ["teachersday", EnglishHolidayParserConfiguration.TeacherDay], - ["singleday", EnglishHolidayParserConfiguration.SinglesDay], - ["allsaintsday", EnglishHolidayParserConfiguration.HalloweenDay], - ["youthday", EnglishHolidayParserConfiguration.YouthDay], - ["childrenday", EnglishHolidayParserConfiguration.ChildrenDay], - ["femaleday", EnglishHolidayParserConfiguration.FemaleDay], - ["treeplantingday", EnglishHolidayParserConfiguration.TreePlantDay], - ["arborday", EnglishHolidayParserConfiguration.TreePlantDay], - ["girlsday", EnglishHolidayParserConfiguration.GirlsDay], - ["whiteloverday", EnglishHolidayParserConfiguration.WhiteLoverDay], - ["loverday", EnglishHolidayParserConfiguration.ValentinesDay], - ["christmas", EnglishHolidayParserConfiguration.ChristmasDay], - ["xmas", EnglishHolidayParserConfiguration.ChristmasDay], - ["newyear", EnglishHolidayParserConfiguration.NewYear], - ["newyearday", EnglishHolidayParserConfiguration.NewYear], - ["newyearsday", EnglishHolidayParserConfiguration.NewYear], - ["inaugurationday", EnglishHolidayParserConfiguration.InaugurationDay], - ["groundhougday", EnglishHolidayParserConfiguration.GroundhogDay], - ["valentinesday", EnglishHolidayParserConfiguration.ValentinesDay], - ["stpatrickday", EnglishHolidayParserConfiguration.StPatrickDay], - ["aprilfools", EnglishHolidayParserConfiguration.FoolDay], - ["stgeorgeday", EnglishHolidayParserConfiguration.StGeorgeDay], - ["mayday", EnglishHolidayParserConfiguration.Mayday], - ["cincodemayoday", EnglishHolidayParserConfiguration.CincoDeMayoday], - ["baptisteday", EnglishHolidayParserConfiguration.BaptisteDay], - ["usindependenceday", EnglishHolidayParserConfiguration.UsaIndependenceDay], - ["independenceday", EnglishHolidayParserConfiguration.UsaIndependenceDay], - ["bastilleday", EnglishHolidayParserConfiguration.BastilleDay], - ["halloweenday", EnglishHolidayParserConfiguration.HalloweenDay], - ["allhallowday", EnglishHolidayParserConfiguration.AllHallowDay], - ["allsoulsday", EnglishHolidayParserConfiguration.AllSoulsday], - ["guyfawkesday", EnglishHolidayParserConfiguration.GuyFawkesDay], - ["veteransday", EnglishHolidayParserConfiguration.Veteransday], - ["christmaseve", EnglishHolidayParserConfiguration.ChristmasEve], - ["newyeareve", EnglishHolidayParserConfiguration.NewYearEve], - ["easterday", EnglishHolidayParserConfiguration.EasterDay], - ["juneteenth", EnglishHolidayParserConfiguration.Juneteenth] - ]); - } - - // All JavaScript dates are zero-based (-1) - private static NewYear(year: number): Date { - return new Date(year, 1 - 1, 1); - } - private static NewYearEve(year: number): Date { - return new Date(year, 12 - 1, 31); - } - private static ChristmasDay(year: number): Date { - return new Date(year, 12 - 1, 25); - } - private static ChristmasEve(year: number): Date { - return new Date(year, 12 - 1, 24); - } - private static ValentinesDay(year: number): Date { - return new Date(year, 2 - 1, 14); - } - private static WhiteLoverDay(year: number): Date { - return new Date(year, 3 - 1, 14); - } - private static FoolDay(year: number): Date { - return new Date(year, 4 - 1, 1); - } - private static GirlsDay(year: number): Date { - return new Date(year, 3 - 1, 7); - } - private static TreePlantDay(year: number): Date { - return new Date(year, 3 - 1, 12); - } - private static FemaleDay(year: number): Date { - return new Date(year, 3 - 1, 8); - } - private static ChildrenDay(year: number): Date { - return new Date(year, 6 - 1, 1); - } - private static YouthDay(year: number): Date { - return new Date(year, 5 - 1, 4); - } - private static TeacherDay(year: number): Date { - return new Date(year, 9 - 1, 10); - } - private static SinglesDay(year: number): Date { - return new Date(year, 11 - 1, 11); - } - private static MaoBirthday(year: number): Date { - return new Date(year, 12 - 1, 26); - } - private static InaugurationDay(year: number): Date { - return new Date(year, 1 - 1, 20); - } - private static GroundhogDay(year: number): Date { - return new Date(year, 2 - 1, 2); - } - private static StPatrickDay(year: number): Date { - return new Date(year, 3 - 1, 17); - } - private static StGeorgeDay(year: number): Date { - return new Date(year, 4 - 1, 23); - } - private static Mayday(year: number): Date { - return new Date(year, 5 - 1, 1); - } - private static CincoDeMayoday(year: number): Date { - return new Date(year, 5 - 1, 5); - } - private static BaptisteDay(year: number): Date { - return new Date(year, 6 - 1, 24); - } - private static UsaIndependenceDay(year: number): Date { - return new Date(year, 7 - 1, 4); - } - private static BastilleDay(year: number): Date { - return new Date(year, 7 - 1, 14); - } - private static HalloweenDay(year: number): Date { - return new Date(year, 10 - 1, 31); - } - private static AllHallowDay(year: number): Date { - return new Date(year, 11 - 1, 1); - } - private static AllSoulsday(year: number): Date { - return new Date(year, 11 - 1, 2); - } - private static GuyFawkesDay(year: number): Date { - return new Date(year, 11 - 1, 5); - } - private static Veteransday(year: number): Date { - return new Date(year, 11 - 1, 11); - } - private static Juneteenth(year: number): Date { - return new Date(year, 6 - 1, 19); - } - private static EasterDay(year: number): Date { - return DateUtils.minValue(); - } - - public getSwiftYear(text: string): number { - let trimmedText = text.trim().toLowerCase(); - let swift = -10; - if (trimmedText.startsWith("next")) { - swift = 1; - } - else if (trimmedText.startsWith("last")) { - swift = -1; - } - else if (trimmedText.startsWith("this")) { - swift = 0; - } - return swift; - } - - public sanitizeHolidayToken(holiday: string): string { - return holiday.replace(/[ ']/g, ""); - } -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-date-time/src/dateTime/english/mergedConfiguration.ts b/JavaScript/packages/recognizers-date-time/src/dateTime/english/mergedConfiguration.ts deleted file mode 100644 index 7c575c1012..0000000000 --- a/JavaScript/packages/recognizers-date-time/src/dateTime/english/mergedConfiguration.ts +++ /dev/null @@ -1,109 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { IMergedExtractorConfiguration, IMergedParserConfiguration } from "../baseMerged"; -import { BaseDateExtractor, BaseDateParser } from "../baseDate"; -import { BaseTimeExtractor, BaseTimeParser } from "../baseTime"; -import { BaseSetExtractor, BaseSetParser } from "../baseSet"; -import { BaseHolidayExtractor, BaseHolidayParser } from "../baseHoliday"; -import { BaseDatePeriodExtractor, BaseDatePeriodParser } from "../baseDatePeriod"; -import { BaseTimePeriodExtractor, BaseTimePeriodParser } from "../baseTimePeriod"; -import { IDateTimeExtractor, BaseDateTimeExtractor, BaseDateTimeParser } from "../baseDateTime"; -import { BaseDateTimePeriodExtractor, BaseDateTimePeriodParser } from "../baseDateTimePeriod"; -import { BaseDurationExtractor, BaseDurationParser } from "../baseDuration"; -import { RegExpUtility } from "@microsoft/recognizers-text"; -import { BaseNumberExtractor, EnglishIntegerExtractor } from "@microsoft/recognizers-text-number"; -import { EnglishDateTime } from "../../resources/englishDateTime"; -import { EnglishCommonDateTimeParserConfiguration } from "./baseConfiguration"; -import { EnglishDurationExtractorConfiguration } from "./durationConfiguration"; -import { EnglishTimeExtractorConfiguration } from "./timeConfiguration"; -import { EnglishDateExtractorConfiguration } from "./dateConfiguration"; -import { EnglishDateTimeExtractorConfiguration } from "./dateTimeConfiguration"; -import { EnglishTimePeriodExtractorConfiguration } from "./timePeriodConfiguration"; -import { EnglishDatePeriodExtractorConfiguration } from "./datePeriodConfiguration"; -import { EnglishDateTimePeriodExtractorConfiguration } from "./dateTimePeriodConfiguration"; -import { EnglishSetExtractorConfiguration, EnglishSetParserConfiguration } from "./setConfiguration"; -import { EnglishHolidayExtractorConfiguration, EnglishHolidayParserConfiguration } from "./holidayConfiguration"; -import { DefinitionLoader } from "../utilities"; - -export class EnglishMergedExtractorConfiguration implements IMergedExtractorConfiguration { - readonly dateExtractor: IDateTimeExtractor - readonly timeExtractor: IDateTimeExtractor - readonly dateTimeExtractor: IDateTimeExtractor - readonly datePeriodExtractor: IDateTimeExtractor - readonly timePeriodExtractor: IDateTimeExtractor - readonly dateTimePeriodExtractor: IDateTimeExtractor - readonly holidayExtractor: IDateTimeExtractor - readonly durationExtractor: IDateTimeExtractor - readonly setExtractor: IDateTimeExtractor - readonly integerExtractor: BaseNumberExtractor - readonly afterRegex: RegExp - readonly sinceRegex: RegExp - readonly beforeRegex: RegExp - readonly fromToRegex: RegExp - readonly singleAmbiguousMonthRegex: RegExp - readonly prepositionSuffixRegex: RegExp - readonly ambiguousRangeModifierPrefix: RegExp - readonly potentialAmbiguousRangeRegex: RegExp - readonly numberEndingPattern: RegExp - readonly unspecificDatePeriodRegex: RegExp - readonly filterWordRegexList: RegExp[] - readonly AmbiguityFiltersDict: Map - - constructor(dmyDateFormat: boolean = false) { - this.dateExtractor = new BaseDateExtractor(new EnglishDateExtractorConfiguration(dmyDateFormat)); - this.timeExtractor = new BaseTimeExtractor(new EnglishTimeExtractorConfiguration()); - this.dateTimeExtractor = new BaseDateTimeExtractor(new EnglishDateTimeExtractorConfiguration(dmyDateFormat)); - this.datePeriodExtractor = new BaseDatePeriodExtractor(new EnglishDatePeriodExtractorConfiguration(dmyDateFormat)); - this.timePeriodExtractor = new BaseTimePeriodExtractor(new EnglishTimePeriodExtractorConfiguration()); - this.dateTimePeriodExtractor = new BaseDateTimePeriodExtractor(new EnglishDateTimePeriodExtractorConfiguration(dmyDateFormat)); - this.holidayExtractor = new BaseHolidayExtractor(new EnglishHolidayExtractorConfiguration()); - this.durationExtractor = new BaseDurationExtractor(new EnglishDurationExtractorConfiguration()); - this.setExtractor = new BaseSetExtractor(new EnglishSetExtractorConfiguration(dmyDateFormat)); - this.integerExtractor = new EnglishIntegerExtractor(); - this.afterRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.AfterRegex); - this.sinceRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.SinceRegex); - this.beforeRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.BeforeRegex); - this.fromToRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.FromToRegex); - this.singleAmbiguousMonthRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.SingleAmbiguousMonthRegex); - this.prepositionSuffixRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.PrepositionSuffixRegex); - this.ambiguousRangeModifierPrefix = RegExpUtility.getSafeRegExp(EnglishDateTime.AmbiguousRangeModifierPrefix); - this.potentialAmbiguousRangeRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.FromToRegex); - this.numberEndingPattern = RegExpUtility.getSafeRegExp(EnglishDateTime.NumberEndingPattern); - this.unspecificDatePeriodRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.UnspecificDatePeriodRegex); - this.filterWordRegexList = [ - RegExpUtility.getSafeRegExp(EnglishDateTime.OneOnOneRegex) - ]; - this.AmbiguityFiltersDict = DefinitionLoader.LoadAmbiguityFilters(EnglishDateTime.AmbiguityFiltersDict); - } -} - -export class EnglishMergedParserConfiguration implements IMergedParserConfiguration { - readonly beforeRegex: RegExp - readonly afterRegex: RegExp - readonly sinceRegex: RegExp - readonly dateParser: BaseDateParser - readonly holidayParser: BaseHolidayParser - readonly timeParser: BaseTimeParser - readonly dateTimeParser: BaseDateTimeParser - readonly datePeriodParser: BaseDatePeriodParser - readonly timePeriodParser: BaseTimePeriodParser - readonly dateTimePeriodParser: BaseDateTimePeriodParser - readonly durationParser: BaseDurationParser - readonly setParser: BaseSetParser - - constructor(config: EnglishCommonDateTimeParserConfiguration) { - this.beforeRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.BeforeRegex); - this.afterRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.AfterRegex); - this.sinceRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.SinceRegex); - this.holidayParser = new BaseHolidayParser(new EnglishHolidayParserConfiguration()); - this.dateParser = config.dateParser; - this.timeParser = config.timeParser; - this.dateTimeParser = config.dateTimeParser; - this.datePeriodParser = config.datePeriodParser; - this.timePeriodParser = config.timePeriodParser; - this.dateTimePeriodParser = config.dateTimePeriodParser; - this.durationParser = config.durationParser; - this.setParser = new BaseSetParser(new EnglishSetParserConfiguration(config)); - } -} diff --git a/JavaScript/packages/recognizers-date-time/src/dateTime/english/parsers.ts b/JavaScript/packages/recognizers-date-time/src/dateTime/english/parsers.ts deleted file mode 100644 index aa4d644046..0000000000 --- a/JavaScript/packages/recognizers-date-time/src/dateTime/english/parsers.ts +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { BaseTimeParser, ITimeParserConfiguration } from "../baseTime"; -import { EnglishTimeExtractorConfiguration } from "./timeConfiguration"; -import { DateTimeResolutionResult, DateTimeFormatUtil } from "../utilities"; -import { RegExpUtility } from "@microsoft/recognizers-text"; - -export class EnglishTimeParser extends BaseTimeParser { - constructor(configuration: ITimeParserConfiguration) { - super(configuration); - } - - internalParse(text: string, referenceTime: Date): DateTimeResolutionResult { - let innerResult = super.internalParse(text, referenceTime); - if (!innerResult.success) { - innerResult = this.parseIsh(text, referenceTime); - } - return innerResult; - } - - // parse "noonish", "11-ish" - private parseIsh(text: string, referenceTime: Date): DateTimeResolutionResult { - let ret = new DateTimeResolutionResult(); - let trimmedText = text.toLowerCase().trim(); - - let matches = RegExpUtility.getMatches(EnglishTimeExtractorConfiguration.ishRegex, trimmedText); - if (matches.length > 0 && matches[0].length === trimmedText.length) { - let hourStr = matches[0].groups("hour").value; - let hour = 12; - if (hourStr) { - hour = Number.parseInt(hourStr, 10); - } - - ret.timex = "T" + DateTimeFormatUtil.toString(hour, 2); - ret.futureValue = - ret.pastValue = - new Date(referenceTime.getFullYear(), referenceTime.getMonth(), referenceTime.getDate(), hour, 0, 0); - ret.success = true; - return ret; - } - - return ret; - } -} diff --git a/JavaScript/packages/recognizers-date-time/src/dateTime/english/setConfiguration.ts b/JavaScript/packages/recognizers-date-time/src/dateTime/english/setConfiguration.ts deleted file mode 100644 index 0d4988ce02..0000000000 --- a/JavaScript/packages/recognizers-date-time/src/dateTime/english/setConfiguration.ts +++ /dev/null @@ -1,158 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { ISetExtractorConfiguration, ISetParserConfiguration } from "../baseSet"; -import { BaseDateExtractor, BaseDateParser } from "../baseDate"; -import { BaseTimeExtractor, BaseTimeParser } from "../baseTime"; -import { BaseDatePeriodExtractor, BaseDatePeriodParser } from "../baseDatePeriod"; -import { BaseTimePeriodExtractor, BaseTimePeriodParser } from "../baseTimePeriod"; -import { IDateTimeExtractor, BaseDateTimeExtractor, BaseDateTimeParser } from "../baseDateTime"; -import { BaseDateTimePeriodExtractor, BaseDateTimePeriodParser } from "../baseDateTimePeriod"; -import { BaseDurationExtractor, BaseDurationParser } from "../baseDuration"; -import { RegExpUtility } from "@microsoft/recognizers-text"; -import { EnglishDateTime } from "../../resources/englishDateTime"; -import { ICommonDateTimeParserConfiguration } from "../parsers"; -import { EnglishDurationExtractorConfiguration } from "./durationConfiguration"; -import { EnglishTimeExtractorConfiguration } from "./timeConfiguration"; -import { EnglishDateExtractorConfiguration } from "./dateConfiguration"; -import { EnglishDateTimeExtractorConfiguration } from "./dateTimeConfiguration"; -import { EnglishTimePeriodExtractorConfiguration } from "./timePeriodConfiguration"; -import { EnglishDatePeriodExtractorConfiguration } from "./datePeriodConfiguration"; -import { EnglishDateTimePeriodExtractorConfiguration } from "./dateTimePeriodConfiguration"; - -export class EnglishSetExtractorConfiguration implements ISetExtractorConfiguration { - readonly lastRegex: RegExp; - readonly eachPrefixRegex: RegExp; - readonly periodicRegex: RegExp; - readonly eachUnitRegex: RegExp; - readonly eachDayRegex: RegExp; - readonly beforeEachDayRegex: RegExp; - readonly setWeekDayRegex: RegExp; - readonly setEachRegex: RegExp; - readonly durationExtractor: IDateTimeExtractor; - readonly timeExtractor: IDateTimeExtractor; - readonly dateExtractor: IDateTimeExtractor; - readonly dateTimeExtractor: IDateTimeExtractor; - readonly datePeriodExtractor: IDateTimeExtractor; - readonly timePeriodExtractor: IDateTimeExtractor; - readonly dateTimePeriodExtractor: IDateTimeExtractor; - - constructor(dmyDateFormat: boolean) { - this.durationExtractor = new BaseDurationExtractor(new EnglishDurationExtractorConfiguration()); - this.timeExtractor = new BaseTimeExtractor(new EnglishTimeExtractorConfiguration()); - this.dateExtractor = new BaseDateExtractor(new EnglishDateExtractorConfiguration(dmyDateFormat)); - this.dateTimeExtractor = new BaseDateTimeExtractor(new EnglishDateTimeExtractorConfiguration(dmyDateFormat)); - this.datePeriodExtractor = new BaseDatePeriodExtractor(new EnglishDatePeriodExtractorConfiguration(dmyDateFormat)); - this.timePeriodExtractor = new BaseTimePeriodExtractor(new EnglishTimePeriodExtractorConfiguration()); - this.dateTimePeriodExtractor = new BaseDateTimePeriodExtractor(new EnglishDateTimePeriodExtractorConfiguration(dmyDateFormat)); - this.lastRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.SetLastRegex); - this.eachPrefixRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.EachPrefixRegex); - this.periodicRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.PeriodicRegex); - this.eachUnitRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.EachUnitRegex); - this.eachDayRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.EachDayRegex); - this.setWeekDayRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.SetWeekDayRegex); - this.setEachRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.SetEachRegex); - this.beforeEachDayRegex = null; - } -} - -export class EnglishSetParserConfiguration implements ISetParserConfiguration { - readonly durationExtractor: IDateTimeExtractor; - readonly durationParser: BaseDurationParser; - readonly timeExtractor: IDateTimeExtractor; - readonly timeParser: BaseTimeParser; - readonly dateExtractor: IDateTimeExtractor; - readonly dateParser: BaseDateParser; - readonly dateTimeExtractor: IDateTimeExtractor; - readonly dateTimeParser: BaseDateTimeParser; - readonly datePeriodExtractor: IDateTimeExtractor; - readonly datePeriodParser: BaseDatePeriodParser; - readonly timePeriodExtractor: IDateTimeExtractor; - readonly timePeriodParser: BaseTimePeriodParser; - readonly dateTimePeriodExtractor: IDateTimeExtractor; - readonly dateTimePeriodParser: BaseDateTimePeriodParser; - readonly unitMap: ReadonlyMap; - readonly eachPrefixRegex: RegExp; - readonly periodicRegex: RegExp; - readonly eachUnitRegex: RegExp; - readonly eachDayRegex: RegExp; - readonly setWeekDayRegex: RegExp; - readonly setEachRegex: RegExp; - - constructor(config: ICommonDateTimeParserConfiguration) { - this.durationExtractor = config.durationExtractor; - this.timeExtractor = config.timeExtractor; - this.dateExtractor = config.dateExtractor; - this.dateTimeExtractor = config.dateTimeExtractor; - this.datePeriodExtractor = config.datePeriodExtractor; - this.timePeriodExtractor = config.timePeriodExtractor; - this.dateTimePeriodExtractor = config.dateTimePeriodExtractor; - - this.durationParser = config.durationParser; - this.timeParser = config.timeParser; - this.dateParser = config.dateParser; - this.dateTimeParser = config.dateTimeParser; - this.datePeriodParser = config.datePeriodParser; - this.timePeriodParser = config.timePeriodParser; - this.dateTimePeriodParser = config.dateTimePeriodParser; - this.unitMap = config.unitMap; - - this.eachPrefixRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.EachPrefixRegex); - this.periodicRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.PeriodicRegex); - this.eachUnitRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.EachUnitRegex); - this.eachDayRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.EachDayRegex); - this.setWeekDayRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.SetWeekDayRegex); - this.setEachRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.SetEachRegex); - } - - public getMatchedDailyTimex(text: string): { matched: boolean, timex: string } { - let timex = ""; - let trimmedText = text.trim().toLowerCase(); - if (trimmedText === "daily") { - timex = "P1D"; - } - else if (trimmedText === "weekly") { - timex = "P1W"; - } - else if (trimmedText === "biweekly") { - timex = "P2W"; - } - else if (trimmedText === "monthly") { - timex = "P1M"; - } - else if (trimmedText === "quarterly") { - timex = "P3M"; - } - else if (trimmedText === "yearly" || trimmedText === "annually" || trimmedText === "annual") { - timex = "P1Y"; - } - else { - timex = null; - return { matched: false, timex: timex }; - } - return { matched: true, timex: timex }; - } - - public getMatchedUnitTimex(text: string): { matched: boolean, timex: string } { - let timex = ""; - let trimmedText = text.trim().toLowerCase(); - if (trimmedText === "day") { - timex = "P1D"; - } - else if (trimmedText === "week") { - timex = "P1W"; - } - else if (trimmedText === "month") { - timex = "P1M"; - } - else if (trimmedText === "year") { - timex = "P1Y"; - } - else { - timex = null; - return { matched: false, timex: timex }; - } - - return { matched: true, timex: timex }; - } -} diff --git a/JavaScript/packages/recognizers-date-time/src/dateTime/english/timeConfiguration.ts b/JavaScript/packages/recognizers-date-time/src/dateTime/english/timeConfiguration.ts deleted file mode 100644 index 2c5e755557..0000000000 --- a/JavaScript/packages/recognizers-date-time/src/dateTime/english/timeConfiguration.ts +++ /dev/null @@ -1,171 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { ITimeExtractorConfiguration, ITimeParserConfiguration } from "../baseTime"; -import { RegExpUtility } from "@microsoft/recognizers-text"; -import { EnglishDateTime } from "../../resources/englishDateTime"; -import { ICommonDateTimeParserConfiguration } from "../parsers"; -import { IDateTimeUtilityConfiguration } from "../utilities"; - -export class EnglishTimeExtractorConfiguration implements ITimeExtractorConfiguration { - public static timeRegexList: RegExp[] = [ - // (three min past)? seven|7|(seven thirty) pm - RegExpUtility.getSafeRegExp(EnglishDateTime.TimeRegex1, "gis"), - // (three min past)? 3:00(:00)? (pm)? - RegExpUtility.getSafeRegExp(EnglishDateTime.TimeRegex2, "gis"), - // (three min past)? 3.00 (pm) - RegExpUtility.getSafeRegExp(EnglishDateTime.TimeRegex3, "gis"), - // (three min past) (five thirty|seven|7|7:00(:00)?) (pm)? (in the night) - RegExpUtility.getSafeRegExp(EnglishDateTime.TimeRegex4, "gis"), - // (three min past) (five thirty|seven|7|7:00(:00)?) (pm)? - RegExpUtility.getSafeRegExp(EnglishDateTime.TimeRegex5, "gis"), - // (five thirty|seven|7|7:00(:00)?) (pm)? (in the night) - RegExpUtility.getSafeRegExp(EnglishDateTime.TimeRegex6, "gis"), - // (in the night) at (five thirty|seven|7|7:00(:00)?) (pm)? - RegExpUtility.getSafeRegExp(EnglishDateTime.TimeRegex7, "gis"), - // (in the night) (five thirty|seven|7|7:00(:00)?) (pm)? - RegExpUtility.getSafeRegExp(EnglishDateTime.TimeRegex8, "gis"), - RegExpUtility.getSafeRegExp(EnglishDateTime.TimeRegex9, "gis"), - // (three min past)? 3h00 (pm)? - RegExpUtility.getSafeRegExp(EnglishDateTime.TimeRegex10, "gis"), - // at 2.30, before 6.30pm. 'at' prefix or 'am/pm' suffix is required here - RegExpUtility.getSafeRegExp(EnglishDateTime.TimeRegex11, "gis"), - // 340pm - RegExpUtility.getSafeRegExp(EnglishDateTime.ConnectNumRegex, "gis") - ]; - public static atRegex: RegExp = RegExpUtility.getSafeRegExp(EnglishDateTime.AtRegex, "gis"); - public static lessThanOneHour: RegExp = RegExpUtility.getSafeRegExp(EnglishDateTime.LessThanOneHour, "gis"); - public static timeSuffix: RegExp = RegExpUtility.getSafeRegExp(EnglishDateTime.TimeSuffix, "gis"); - public static timeSuffixFull: RegExp = RegExpUtility.getSafeRegExp(EnglishDateTime.TimeSuffixFull, "gis"); - public static ishRegex: RegExp = RegExpUtility.getSafeRegExp(EnglishDateTime.IshRegex, "gis"); - - readonly timeRegexList: RegExp[]; - readonly atRegex: RegExp; - readonly ishRegex: RegExp; - - constructor() { - this.timeRegexList = EnglishTimeExtractorConfiguration.timeRegexList; - this.atRegex = EnglishTimeExtractorConfiguration.atRegex; - this.ishRegex = EnglishTimeExtractorConfiguration.ishRegex; - } -} - -export class EnglishTimeParserConfiguration implements ITimeParserConfiguration { - readonly timeTokenPrefix: string; - readonly atRegex: RegExp - readonly timeRegexes: RegExp[]; - readonly numbers: ReadonlyMap; - readonly lunchRegex: RegExp; - readonly timeSuffixFull: RegExp; - readonly nightRegex: RegExp; - readonly utilityConfiguration: IDateTimeUtilityConfiguration; - - constructor(config: ICommonDateTimeParserConfiguration) { - this.timeTokenPrefix = EnglishDateTime.TimeTokenPrefix; - this.atRegex = EnglishTimeExtractorConfiguration.atRegex; - this.timeRegexes = EnglishTimeExtractorConfiguration.timeRegexList; - this.numbers = config.numbers; - this.lunchRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.LunchRegex); - this.timeSuffixFull = RegExpUtility.getSafeRegExp(EnglishDateTime.TimeSuffixFull); - this.nightRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.NightRegex); - this.utilityConfiguration = config.utilityConfiguration; - } - - public adjustByPrefix(prefix: string, adjust: { hour: number, min: number, hasMin: boolean }) { - let deltaMin = 0; - let trimmedPrefix = prefix.trim().toLowerCase(); - - if (trimmedPrefix.startsWith("half")) { - deltaMin = 30; - } - else if (trimmedPrefix.startsWith("a quarter") || trimmedPrefix.startsWith("quarter")) { - deltaMin = 15; - } - else if (trimmedPrefix.startsWith("three quarter")) { - deltaMin = 45; - } - else { - let match = RegExpUtility.getMatches(EnglishTimeExtractorConfiguration.lessThanOneHour, trimmedPrefix); - let minStr = match[0].groups("deltamin").value; - if (minStr) { - deltaMin = Number.parseInt(minStr, 10); - } - else { - minStr = match[0].groups("deltaminnum").value.toLowerCase(); - deltaMin = this.numbers.get(minStr); - } - } - - if (trimmedPrefix.endsWith("to")) { - deltaMin = -deltaMin; - } - - adjust.min += deltaMin; - if (adjust.min < 0) { - adjust.min += 60; - adjust.hour -= 1; - } - adjust.hasMin = true; - } - - public adjustBySuffix(suffix: string, adjust: { hour: number, min: number, hasMin: boolean, hasAm: boolean, hasPm: boolean }) { - let trimmedSuffix = suffix.trim().toLowerCase(); - let deltaHour = 0; - let matches = RegExpUtility.getMatches(EnglishTimeExtractorConfiguration.timeSuffixFull, trimmedSuffix); - if (matches.length > 0 && matches[0].index === 0 && matches[0].length === trimmedSuffix.length) { - let oclockStr = matches[0].groups("oclock").value; - if (!oclockStr) { - let amStr = matches[0].groups("am").value; - if (amStr) { - if (adjust.hour >= 12) { - deltaHour = -12; - } - else { - adjust.hasAm = true; - } - } - - let pmStr = matches[0].groups("pm").value; - if (pmStr) { - if (adjust.hour < 12) { - deltaHour = 12; - } - - if (RegExpUtility.getMatches(this.lunchRegex, pmStr).length > 0) { - // for hour>=10, <12 - if (adjust.hour >= 10 && adjust.hour <= 12) { - deltaHour = 0; - if (adjust.hour === 12) { - adjust.hasPm = true; - } - else { - adjust.hasAm = true; - } - } - else { - adjust.hasPm = true; - } - } - else if (RegExpUtility.getMatches(this.nightRegex, pmStr).length > 0) { - // for hour <=3 or === 12, we treat it as am, for example 1 in the night (midnight) === 1am - if (adjust.hour <= 3 || adjust.hour === 12) { - if (adjust.hour === 12) { - adjust.hour = 0; - } - deltaHour = 0; - adjust.hasAm = true; - } - else { - adjust.hasPm = true; - } - } - else { - adjust.hasPm = true; - } - } - } - } - - adjust.hour = (adjust.hour + deltaHour) % 24; - } -} diff --git a/JavaScript/packages/recognizers-date-time/src/dateTime/english/timePeriodConfiguration.ts b/JavaScript/packages/recognizers-date-time/src/dateTime/english/timePeriodConfiguration.ts deleted file mode 100644 index b144fc3b0e..0000000000 --- a/JavaScript/packages/recognizers-date-time/src/dateTime/english/timePeriodConfiguration.ts +++ /dev/null @@ -1,130 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { ITimePeriodExtractorConfiguration, ITimePeriodParserConfiguration } from "../baseTimePeriod"; -import { BaseTimeExtractor, BaseTimeParser } from "../baseTime"; -import { RegExpUtility, IExtractor } from "@microsoft/recognizers-text"; -import { EnglishDateTime } from "../../resources/englishDateTime"; -import { ICommonDateTimeParserConfiguration } from "../parsers"; -import { IDateTimeUtilityConfiguration, TimexUtil } from "../utilities"; -import { EnglishTimeExtractorConfiguration } from "./timeConfiguration"; -import { IDateTimeExtractor } from "../baseDateTime"; -import { EnglishIntegerExtractor } from "@microsoft/recognizers-text-number"; -import { Constants } from "../constants"; -import { ChineseDateTime } from "../../resources/chineseDateTime"; - -export class EnglishTimePeriodExtractorConfiguration implements ITimePeriodExtractorConfiguration { - readonly simpleCasesRegex: RegExp[]; - readonly tillRegex: RegExp; - readonly timeOfDayRegex: RegExp; - readonly generalEndingRegex: RegExp; - readonly singleTimeExtractor: IDateTimeExtractor; - readonly integerExtractor: IExtractor; - - constructor() { - this.simpleCasesRegex = [ - RegExpUtility.getSafeRegExp(EnglishDateTime.PureNumFromTo, "gis"), - RegExpUtility.getSafeRegExp(EnglishDateTime.PureNumBetweenAnd, "gis") - ]; - this.tillRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.TillRegex, "gis"); - this.timeOfDayRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.TimeOfDayRegex, "gis"); - this.generalEndingRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.GeneralEndingRegex, "gis"); - this.singleTimeExtractor = new BaseTimeExtractor(new EnglishTimeExtractorConfiguration()); - this.integerExtractor = new EnglishIntegerExtractor(); - } - - public getFromTokenIndex(source: string): { matched: boolean, index: number } { - let index = -1; - if (source.endsWith("from")) { - index = source.lastIndexOf("from"); - return { matched: true, index: index }; - } - return { matched: false, index: index }; - } - - public getBetweenTokenIndex(source: string): { matched: boolean, index: number } { - let index = -1; - if (source.endsWith("between")) { - index = source.lastIndexOf("between"); - return { matched: true, index: index }; - } - return { matched: false, index: index }; - } - - public hasConnectorToken(source: string): boolean { - return source === "and"; - } -} - -export class EnglishTimePeriodParserConfiguration implements ITimePeriodParserConfiguration { - timeExtractor: IDateTimeExtractor; - timeParser: BaseTimeParser; - integerExtractor: IDateTimeExtractor; - pureNumberFromToRegex: RegExp; - pureNumberBetweenAndRegex: RegExp; - timeOfDayRegex: RegExp; - tillRegex: RegExp; - numbers: ReadonlyMap; - utilityConfiguration: IDateTimeUtilityConfiguration; - specificTimeFromToRegex: RegExp; - specificTimeBetweenAndRegex: RegExp; - - constructor(config: ICommonDateTimeParserConfiguration) { - this.timeExtractor = config.timeExtractor; - this.timeParser = config.timeParser; - this.integerExtractor = config.integerExtractor; - this.pureNumberFromToRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.PureNumFromTo); - this.pureNumberBetweenAndRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.PureNumBetweenAnd); - this.timeOfDayRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.TimeOfDayRegex); - this.tillRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.TillRegex, "gis"); - this.numbers = config.numbers; - this.utilityConfiguration = config.utilityConfiguration; - this.specificTimeFromToRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.SpecificTimeFromTo); - this.specificTimeBetweenAndRegex = RegExpUtility.getSafeRegExp(EnglishDateTime.SpecificTimeBetweenAnd); - } - - getMatchedTimexRange(text: string): { - matched: boolean, timex: string, beginHour: number, endHour: number, endMin: number - } { - let trimmedText = text.trim().toLowerCase(); - if (trimmedText.endsWith("s")) { - trimmedText = trimmedText.substring(0, trimmedText.length - 1); - } - let matched = false; - let timex = null; - let beginHour = 0; - let endHour = 0; - let endMin = 0; - - let timeOfDay = ""; - if (EnglishDateTime.MorningTermList.some(o => trimmedText.endsWith(o))) { - timeOfDay = Constants.Morning; - } - else if (EnglishDateTime.AfternoonTermList.some(o => trimmedText.endsWith(o))) { - timeOfDay = Constants.Afternoon; - } - else if (EnglishDateTime.EveningTermList.some(o => trimmedText.endsWith(o))) { - timeOfDay = Constants.Evening; - } - else if (EnglishDateTime.DaytimeTermList.some(o => trimmedText.localeCompare(o) == 0)) { - timeOfDay = Constants.Daytime; - } - else if (EnglishDateTime.NightTermList.some(o => trimmedText.endsWith(o))) { - timeOfDay = Constants.Night; - } - else { - timex = null; - matched = false; - return { matched, timex, beginHour, endHour, endMin }; - } - - let parseResult = TimexUtil.parseTimeOfDay(timeOfDay); - timex = parseResult.timeX; - beginHour = parseResult.beginHour; - endHour = parseResult.endHour; - endMin = parseResult.endMin; - - matched = true; - return { matched, timex, beginHour, endHour, endMin }; - } -} diff --git a/JavaScript/packages/recognizers-date-time/src/dateTime/french/baseConfiguration.ts b/JavaScript/packages/recognizers-date-time/src/dateTime/french/baseConfiguration.ts deleted file mode 100644 index 343119591d..0000000000 --- a/JavaScript/packages/recognizers-date-time/src/dateTime/french/baseConfiguration.ts +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { RegExpUtility } from "@microsoft/recognizers-text"; -import { FrenchCardinalExtractor, FrenchIntegerExtractor, FrenchOrdinalExtractor, BaseNumberParser, FrenchNumberParserConfiguration } from "@microsoft/recognizers-text-number"; -import { IDateTimeUtilityConfiguration } from "../utilities"; -import { FrenchDateTime } from "../../resources/frenchDateTime"; -import { BaseDateParserConfiguration } from "../parsers"; -import { BaseDateTime } from "../../resources/baseDateTime"; -import { BaseDateExtractor, BaseDateParser } from "../baseDate"; -import { BaseTimeExtractor, BaseTimeParser } from "../baseTime"; -import { BaseDateTimeExtractor, BaseDateTimeParser } from "../baseDateTime"; -import { BaseDurationExtractor, BaseDurationParser } from "../baseDuration"; -import { BaseDatePeriodExtractor, BaseDatePeriodParser } from "../baseDatePeriod"; -import { BaseTimePeriodExtractor, BaseTimePeriodParser } from "../baseTimePeriod"; -import { BaseDateTimePeriodExtractor, BaseDateTimePeriodParser } from "../baseDateTimePeriod"; -import { FrenchDateExtractorConfiguration, FrenchDateParserConfiguration } from "./dateConfiguration"; -import { FrenchDateTimeExtractorConfiguration, FrenchDateTimeParserConfiguration } from "./dateTimeConfiguration"; -import { FrenchDurationExtractorConfiguration, FrenchDurationParserConfiguration } from "./durationConfiguration"; -import { FrenchDatePeriodExtractorConfiguration, FrenchDatePeriodParserConfiguration } from "./datePeriodConfiguration"; -import { FrenchTimeExtractorConfiguration, FrenchTimeParserConfiguration } from "./timeConfiguration"; -import { FrenchTimePeriodExtractorConfiguration, FrenchTimePeriodParserConfiguration } from "./timePeriodConfiguration"; -import { FrenchDateTimePeriodExtractorConfiguration, FrenchDateTimePeriodParserConfiguration } from "./dateTimePeriodConfiguration"; - -export class FrenchDateTimeUtilityConfiguration implements IDateTimeUtilityConfiguration { - readonly agoRegex: RegExp; - readonly laterRegex: RegExp; - readonly inConnectorRegex: RegExp; - readonly rangeUnitRegex: RegExp; - readonly amDescRegex: RegExp; - readonly pmDescRegex: RegExp; - readonly amPmDescRegex: RegExp; - - constructor() { - this.laterRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.LaterRegex); - this.agoRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.AgoPrefixRegex); - this.inConnectorRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.InConnectorRegex); - this.rangeUnitRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.RangeUnitRegex); - this.amDescRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.AmDescRegex); - this.pmDescRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.PmDescRegex); - this.amPmDescRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.AmPmDescRegex); - } -} - -export class FrenchCommonDateTimeParserConfiguration extends BaseDateParserConfiguration { - - constructor(dmyDateFormat: boolean) { - super(); - this.utilityConfiguration = new FrenchDateTimeUtilityConfiguration(); - - this.unitMap = FrenchDateTime.UnitMap; - this.unitValueMap = FrenchDateTime.UnitValueMap; - this.seasonMap = FrenchDateTime.SeasonMap; - this.cardinalMap = FrenchDateTime.CardinalMap; - this.dayOfWeek = FrenchDateTime.DayOfWeek; - this.monthOfYear = FrenchDateTime.MonthOfYear; - this.numbers = FrenchDateTime.Numbers; - this.doubleNumbers = FrenchDateTime.DoubleNumbers; - - this.cardinalExtractor = new FrenchCardinalExtractor(); - this.integerExtractor = new FrenchIntegerExtractor(); - this.ordinalExtractor = new FrenchOrdinalExtractor(); - - this.numberParser = new BaseNumberParser(new FrenchNumberParserConfiguration()); - this.dateExtractor = new BaseDateExtractor(new FrenchDateExtractorConfiguration(dmyDateFormat)); - this.timeExtractor = new BaseTimeExtractor(new FrenchTimeExtractorConfiguration()); - this.dateTimeExtractor = new BaseDateTimeExtractor(new FrenchDateTimeExtractorConfiguration(dmyDateFormat)); - this.durationExtractor = new BaseDurationExtractor(new FrenchDurationExtractorConfiguration()); - this.datePeriodExtractor = new BaseDatePeriodExtractor(new FrenchDatePeriodExtractorConfiguration(dmyDateFormat)); - this.timePeriodExtractor = new BaseTimePeriodExtractor(new FrenchTimePeriodExtractorConfiguration()); - this.dateTimePeriodExtractor = new BaseDateTimePeriodExtractor(new FrenchDateTimePeriodExtractorConfiguration(dmyDateFormat)); - this.durationParser = new BaseDurationParser(new FrenchDurationParserConfiguration(this)); - this.dateParser = new BaseDateParser(new FrenchDateParserConfiguration(this, dmyDateFormat)); - this.timeParser = new BaseTimeParser(new FrenchTimeParserConfiguration(this)); - this.dateTimeParser = new BaseDateTimeParser(new FrenchDateTimeParserConfiguration(this)); - this.datePeriodParser = new BaseDatePeriodParser(new FrenchDatePeriodParserConfiguration(this)); - this.timePeriodParser = new BaseTimePeriodParser(new FrenchTimePeriodParserConfiguration(this)); - this.dateTimePeriodParser = new BaseDateTimePeriodParser(new FrenchDateTimePeriodParserConfiguration(this)); - this.dayOfMonth = new Map([...BaseDateTime.DayOfMonthDictionary, ...FrenchDateTime.DayOfMonth]); - } -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-date-time/src/dateTime/french/dateConfiguration.ts b/JavaScript/packages/recognizers-date-time/src/dateTime/french/dateConfiguration.ts deleted file mode 100644 index 49b5c46c03..0000000000 --- a/JavaScript/packages/recognizers-date-time/src/dateTime/french/dateConfiguration.ts +++ /dev/null @@ -1,216 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { RegExpUtility } from "@microsoft/recognizers-text"; -import { BaseNumberExtractor, BaseNumberParser, FrenchOrdinalExtractor, FrenchIntegerExtractor, FrenchNumberParserConfiguration } from "@microsoft/recognizers-text-number"; -import { FrenchDateTime } from "../../resources/frenchDateTime"; -import { IDateExtractorConfiguration, IDateParserConfiguration } from "../baseDate"; -import { BaseDurationExtractor, BaseDurationParser } from "../baseDuration"; -import { IDateTimeUtilityConfiguration } from "../utilities"; -import { FrenchDateTimeUtilityConfiguration, FrenchCommonDateTimeParserConfiguration } from "./baseConfiguration"; -import { FrenchDurationExtractorConfiguration } from "./durationConfiguration"; -import { IDateTimeExtractor } from "../baseDateTime"; -import { Constants } from "../constants"; - -export class FrenchDateExtractorConfiguration implements IDateExtractorConfiguration { - readonly dateRegexList: RegExp[]; - readonly implicitDateList: RegExp[]; - readonly monthEnd: RegExp; - readonly ofMonth: RegExp; - readonly dateUnitRegex: RegExp; - readonly forTheRegex: RegExp; - readonly weekDayAndDayOfMonthRegex: RegExp; - readonly relativeMonthRegex: RegExp; - readonly strictRelativeRegex: RegExp; - readonly weekDayRegex: RegExp; - readonly dayOfWeek: ReadonlyMap; - readonly nonDateUnitRegex: RegExp; - readonly ordinalExtractor: BaseNumberExtractor; - readonly integerExtractor: BaseNumberExtractor; - readonly numberParser: BaseNumberParser; - readonly durationExtractor: IDateTimeExtractor; - readonly utilityConfiguration: IDateTimeUtilityConfiguration; - readonly rangeConnectorSymbolRegex : RegExp; - - constructor(dmyDateFormat: boolean) { - - let enableDmy = dmyDateFormat || FrenchDateTime.DefaultLanguageFallback === Constants.DefaultLanguageFallback_DMY; - - this.dateRegexList = [ - RegExpUtility.getSafeRegExp(FrenchDateTime.DateExtractor1, "gis"), - RegExpUtility.getSafeRegExp(FrenchDateTime.DateExtractor2, "gis"), - RegExpUtility.getSafeRegExp(FrenchDateTime.DateExtractor3, "gis"), - - enableDmy ? - RegExpUtility.getSafeRegExp(FrenchDateTime.DateExtractor5, "gis") : - RegExpUtility.getSafeRegExp(FrenchDateTime.DateExtractor4, "gis"), - - enableDmy ? - RegExpUtility.getSafeRegExp(FrenchDateTime.DateExtractor4, "gis") : - RegExpUtility.getSafeRegExp(FrenchDateTime.DateExtractor5, "gis"), - - enableDmy ? - RegExpUtility.getSafeRegExp(FrenchDateTime.DateExtractor7, "gis") : - RegExpUtility.getSafeRegExp(FrenchDateTime.DateExtractor6, "gis"), - - enableDmy ? - RegExpUtility.getSafeRegExp(FrenchDateTime.DateExtractor6, "gis") : - RegExpUtility.getSafeRegExp(FrenchDateTime.DateExtractor7, "gis"), - - RegExpUtility.getSafeRegExp(FrenchDateTime.DateExtractor8, "gis"), - RegExpUtility.getSafeRegExp(FrenchDateTime.DateExtractor9, "gis"), - RegExpUtility.getSafeRegExp(FrenchDateTime.DateExtractorA, "gis"), - ]; - this.implicitDateList = [ - RegExpUtility.getSafeRegExp(FrenchDateTime.OnRegex, "gis"), - RegExpUtility.getSafeRegExp(FrenchDateTime.RelaxedOnRegex, "gis"), - RegExpUtility.getSafeRegExp(FrenchDateTime.SpecialDayRegex, "gis"), - RegExpUtility.getSafeRegExp(FrenchDateTime.ThisRegex, "gis"), - RegExpUtility.getSafeRegExp(FrenchDateTime.LastDateRegex, "gis"), - RegExpUtility.getSafeRegExp(FrenchDateTime.NextDateRegex, "gis"), - RegExpUtility.getSafeRegExp(FrenchDateTime.StrictWeekDay, "gis"), - RegExpUtility.getSafeRegExp(FrenchDateTime.WeekDayOfMonthRegex, "gis"), - RegExpUtility.getSafeRegExp(FrenchDateTime.SpecialDate, "gis") - ]; - - this.monthEnd = RegExpUtility.getSafeRegExp(FrenchDateTime.MonthEnd, "gis"); - this.ofMonth = RegExpUtility.getSafeRegExp(FrenchDateTime.OfMonth, "gis"); - this.dateUnitRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.DateUnitRegex, "gis"); - this.forTheRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.ForTheRegex, "gis"); - this.weekDayAndDayOfMonthRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.WeekDayAndDayOfMonthRegex, "gis"); - this.relativeMonthRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.RelativeMonthRegex, "gis"); - this.strictRelativeRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.StrictRelativeRegex, "gis"); - this.weekDayRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.WeekDayRegex, "gis"); - this.dayOfWeek = FrenchDateTime.DayOfWeek; - this.ordinalExtractor = new FrenchOrdinalExtractor(); - this.integerExtractor = new FrenchIntegerExtractor(); - this.numberParser = new BaseNumberParser(new FrenchNumberParserConfiguration()); - this.durationExtractor = new BaseDurationExtractor(new FrenchDurationExtractorConfiguration()); - this.utilityConfiguration = new FrenchDateTimeUtilityConfiguration(); - this.nonDateUnitRegex = RegExpUtility.getSafeRegExp("(?heure|heures|hrs|secondes|seconde|secs|sec|minutes|minute|mins)\b", "gis"); - this.rangeConnectorSymbolRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.RangeConnectorRegex); - } -} - -export class FrenchDateParserConfiguration implements IDateParserConfiguration { - readonly ordinalExtractor: BaseNumberExtractor; - readonly integerExtractor: BaseNumberExtractor; - readonly cardinalExtractor: BaseNumberExtractor; - readonly durationExtractor: IDateTimeExtractor; - readonly durationParser: BaseDurationParser; - readonly numberParser: BaseNumberParser; - readonly monthOfYear: ReadonlyMap; - readonly dayOfMonth: ReadonlyMap; - readonly dayOfWeek: ReadonlyMap; - readonly unitMap: ReadonlyMap; - readonly cardinalMap: ReadonlyMap; - readonly dateRegex: RegExp[]; - readonly onRegex: RegExp; - readonly specialDayRegex: RegExp; - readonly specialDayWithNumRegex: RegExp; - readonly nextRegex: RegExp; - readonly unitRegex: RegExp; - readonly strictWeekDay: RegExp; - readonly monthRegex: RegExp; - readonly weekDayRegex: RegExp; - readonly lastRegex: RegExp; - readonly thisRegex: RegExp; - readonly weekDayOfMonthRegex: RegExp; - readonly forTheRegex: RegExp; - readonly weekDayAndDayOfMonthRegex: RegExp; - readonly relativeMonthRegex: RegExp; - readonly strictRelativeRegex: RegExp; - readonly relativeWeekDayRegex: RegExp; - readonly utilityConfiguration: IDateTimeUtilityConfiguration; - readonly dateTokenPrefix: string; - - constructor(config: FrenchCommonDateTimeParserConfiguration, dmyDateFormat: boolean) { - this.ordinalExtractor = config.ordinalExtractor; - this.integerExtractor = config.integerExtractor; - this.cardinalExtractor = config.cardinalExtractor; - this.durationExtractor = config.durationExtractor; - this.numberParser = config.numberParser; - this.durationParser = config.durationParser; - this.monthOfYear = config.monthOfYear; - this.dayOfMonth = config.dayOfMonth; - this.dayOfWeek = config.dayOfWeek; - this.unitMap = config.unitMap; - this.cardinalMap = config.cardinalMap; - this.dateRegex = new FrenchDateExtractorConfiguration(dmyDateFormat).dateRegexList; - this.onRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.OnRegex, "gis"); - this.specialDayRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.SpecialDayRegex, "gis"); - this.specialDayWithNumRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.SpecialDayWithNumRegex, "gis"); - this.nextRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.NextDateRegex, "gis"); - this.unitRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.DateUnitRegex, "gis"); - this.monthRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.MonthRegex, "gis"); - this.weekDayRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.WeekDayRegex, "gis"); - this.strictWeekDay = RegExpUtility.getSafeRegExp(FrenchDateTime.StrictWeekDay, "gis"); - this.lastRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.LastDateRegex, "gis"); - this.thisRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.ThisRegex, "gis"); - this.weekDayOfMonthRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.WeekDayOfMonthRegex, "gis"); - this.forTheRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.ForTheRegex, "gis"); - this.weekDayAndDayOfMonthRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.WeekDayAndDayOfMonthRegex, "gis"); - this.relativeMonthRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.RelativeMonthRegex, "gis"); - this.strictRelativeRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.StrictRelativeRegex, "gis"); - this.relativeWeekDayRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.RelativeWeekDayRegex, "gis"); - this.utilityConfiguration = config.utilityConfiguration; - this.dateTokenPrefix = FrenchDateTime.DateTokenPrefix; - } - - getSwiftDay(source: string): number { - - let trimedText = source.trim().toLowerCase(); - let swift = 0; - - if (trimedText === "aujourd'hui" || trimedText === "auj") { - swift = 0; - } - else if (trimedText === "demain" || - trimedText.endsWith("a2m1") || - trimedText.endsWith("lendemain") || - trimedText.endsWith("jour suivant")) { - swift = 1; - } - else if (trimedText === "hier") { - swift = -1; - } - else if (trimedText.endsWith("après demain") || - trimedText.endsWith("après-demain") || - trimedText.endsWith("apres-demain")) { - swift = 2; - } - else if (trimedText.endsWith("avant-hier") || - trimedText.endsWith("avant hier")) { - swift = -2; - } - else if (trimedText.endsWith("dernier")) { - swift = -1; - } - - return swift; - } - - getSwiftMonthOrYear(source: string): number { - let trimedText = source.trim().toLowerCase(); - let swift = 0; - if (trimedText.endsWith("prochaine") || trimedText.endsWith("prochain")) { - swift = 1; - } - else if (trimedText === "dernière" || - trimedText.endsWith("dernières") || - trimedText.endsWith("derniere") || - trimedText.endsWith("dernieres")) { - swift = -1; - } - - return swift; - } - - isCardinalLast(source: string): boolean { - let trimedText = source.trim().toLowerCase(); - return (trimedText.endsWith("dernière") || - trimedText.endsWith("dernières") || - trimedText.endsWith("derniere") || - trimedText.endsWith("dernieres")); - } -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-date-time/src/dateTime/french/datePeriodConfiguration.ts b/JavaScript/packages/recognizers-date-time/src/dateTime/french/datePeriodConfiguration.ts deleted file mode 100644 index 29524f49c8..0000000000 --- a/JavaScript/packages/recognizers-date-time/src/dateTime/french/datePeriodConfiguration.ts +++ /dev/null @@ -1,281 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { IExtractor, IParser, RegExpUtility } from "@microsoft/recognizers-text"; -import { BaseNumberParser, BaseNumberExtractor, FrenchIntegerExtractor, FrenchNumberParserConfiguration } from "@microsoft/recognizers-text-number"; -import { IDatePeriodExtractorConfiguration, IDatePeriodParserConfiguration } from "../baseDatePeriod"; -import { BaseDateExtractor, BaseDateParser } from "../baseDate"; -import { BaseDurationExtractor, BaseDurationParser } from "../baseDuration"; -import { FrenchDateExtractorConfiguration } from "./dateConfiguration"; -import { FrenchDurationExtractorConfiguration } from "./durationConfiguration"; -import { BaseDateTime } from "../../resources/baseDateTime"; -import { FrenchDateTime } from "../../resources/frenchDateTime"; -import { ICommonDateTimeParserConfiguration } from "../parsers"; -import { IDateTimeExtractor } from "../baseDateTime"; - -export class FrenchDatePeriodExtractorConfiguration implements IDatePeriodExtractorConfiguration { - readonly simpleCasesRegexes: RegExp[]; - readonly illegalYearRegex: RegExp; - readonly YearRegex: RegExp; - readonly tillRegex: RegExp; - readonly followedUnit: RegExp; - readonly numberCombinedWithUnit: RegExp; - readonly pastRegex: RegExp; - readonly futureRegex: RegExp; - readonly weekOfRegex: RegExp; - readonly monthOfRegex: RegExp; - readonly dateUnitRegex: RegExp; - readonly inConnectorRegex: RegExp; - readonly rangeUnitRegex: RegExp; - readonly datePointExtractor: IDateTimeExtractor; - readonly integerExtractor: BaseNumberExtractor; - readonly numberParser: BaseNumberParser; - readonly durationExtractor: IDateTimeExtractor; - - readonly fromRegex: RegExp; - readonly connectorAndRegex: RegExp; - readonly beforeRegex: RegExp; - - readonly weekDayOfMonthRegex: RegExp; - readonly nowRegex: RegExp - - constructor(dmyDateFormat: boolean) { - this.simpleCasesRegexes = [ - RegExpUtility.getSafeRegExp(FrenchDateTime.SimpleCasesRegex), - RegExpUtility.getSafeRegExp(FrenchDateTime.BetweenRegex), - RegExpUtility.getSafeRegExp(FrenchDateTime.OneWordPeriodRegex), - RegExpUtility.getSafeRegExp(FrenchDateTime.MonthWithYear), - RegExpUtility.getSafeRegExp(FrenchDateTime.MonthNumWithYear), - RegExpUtility.getSafeRegExp(FrenchDateTime.YearRegex), - RegExpUtility.getSafeRegExp(FrenchDateTime.WeekDayOfMonthRegex), - RegExpUtility.getSafeRegExp(FrenchDateTime.WeekOfYearRegex), - RegExpUtility.getSafeRegExp(FrenchDateTime.MonthFrontBetweenRegex), - RegExpUtility.getSafeRegExp(FrenchDateTime.MonthFrontSimpleCasesRegex), - RegExpUtility.getSafeRegExp(FrenchDateTime.QuarterRegex), - RegExpUtility.getSafeRegExp(FrenchDateTime.QuarterRegexYearFront), - RegExpUtility.getSafeRegExp(FrenchDateTime.AllHalfYearRegex), - RegExpUtility.getSafeRegExp(FrenchDateTime.SeasonRegex), - RegExpUtility.getSafeRegExp(FrenchDateTime.LaterEarlyPeriodRegex), - RegExpUtility.getSafeRegExp(FrenchDateTime.WeekWithWeekDayRangeRegex) - ]; - this.illegalYearRegex = RegExpUtility.getSafeRegExp(BaseDateTime.IllegalYearRegex); - this.YearRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.YearRegex); - this.tillRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.TillRegex); - this.followedUnit = RegExpUtility.getSafeRegExp(FrenchDateTime.FollowedDateUnit); - this.numberCombinedWithUnit = RegExpUtility.getSafeRegExp(FrenchDateTime.NumberCombinedWithDateUnit); - this.pastRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.PastSuffixRegex); - this.futureRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.NextSuffixRegex); - this.weekOfRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.WeekOfRegex); - this.monthOfRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.MonthOfRegex); - this.dateUnitRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.DateUnitRegex); - this.inConnectorRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.InConnectorRegex); - this.rangeUnitRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.RangeUnitRegex); - this.weekDayOfMonthRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.WeekDayOfMonthRegex); - - this.fromRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.FromRegex); - this.connectorAndRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.ConnectorAndRegex); - this.beforeRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.BeforeRegex2); - this.nowRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.NowRegex); - - this.datePointExtractor = new BaseDateExtractor(new FrenchDateExtractorConfiguration(dmyDateFormat)); - this.integerExtractor = new FrenchIntegerExtractor(); - this.numberParser = new BaseNumberParser(new FrenchNumberParserConfiguration()); - this.durationExtractor = new BaseDurationExtractor(new FrenchDurationExtractorConfiguration()); - } - - getFromTokenIndex(source: string): { matched: boolean; index: number; } { - return RegExpUtility.getFirstMatchIndex(this.fromRegex, source); - } - - getBetweenTokenIndex(source: string): { matched: boolean; index: number; } { - return RegExpUtility.getFirstMatchIndex(this.beforeRegex, source); - } - - hasConnectorToken(source: string): boolean { - return RegExpUtility.getFirstMatchIndex(this.connectorAndRegex, source).matched; - } -} - -export class FrenchDatePeriodParserConfiguration implements IDatePeriodParserConfiguration { - readonly dateExtractor: IDateTimeExtractor; - readonly dateParser: BaseDateParser; - readonly durationExtractor: IDateTimeExtractor; - readonly durationParser: BaseDurationParser; - readonly monthFrontBetweenRegex: RegExp; - readonly betweenRegex: RegExp; - readonly monthFrontSimpleCasesRegex: RegExp; - readonly simpleCasesRegex: RegExp; - readonly oneWordPeriodRegex: RegExp; - readonly monthWithYear: RegExp; - readonly monthNumWithYear: RegExp; - readonly yearRegex: RegExp; - readonly relativeRegex: RegExp; - readonly pastRegex: RegExp; - readonly futureRegex: RegExp; - readonly inConnectorRegex: RegExp; - readonly weekOfMonthRegex: RegExp; - readonly weekOfYearRegex: RegExp; - readonly quarterRegex: RegExp; - readonly quarterRegexYearFront: RegExp; - readonly allHalfYearRegex: RegExp; - readonly seasonRegex: RegExp; - readonly weekOfRegex: RegExp; - readonly monthOfRegex: RegExp; - readonly whichWeekRegex: RegExp; - readonly restOfDateRegex: RegExp; - readonly unspecificEndOfRangeRegex: RegExp; - readonly tokenBeforeDate: string; - readonly dayOfMonth: ReadonlyMap; - readonly monthOfYear: ReadonlyMap; - readonly cardinalMap: ReadonlyMap; - readonly seasonMap: ReadonlyMap; - readonly unitMap: ReadonlyMap; - - readonly nextPrefixRegex: RegExp; - readonly previousPrefixRegex: RegExp; - readonly thisPrefixRegex: RegExp; - readonly nextSuffixRegex: RegExp; - readonly pastSuffixRegex: RegExp; - readonly numberCombinedWithUnit: RegExp; - readonly laterEarlyPeriodRegex: RegExp; - readonly weekWithWeekDayRangeRegex: RegExp; - - readonly cardinalExtractor: IExtractor; - readonly integerExtractor: BaseNumberExtractor; - readonly numberParser: BaseNumberParser; - readonly nowRegex: RegExp - - constructor(config: ICommonDateTimeParserConfiguration) { - this.tokenBeforeDate = FrenchDateTime.TokenBeforeDate; - this.cardinalExtractor = config.cardinalExtractor; - this.integerExtractor = config.integerExtractor; - this.numberParser = config.numberParser; - this.durationExtractor = config.durationExtractor; - this.dateExtractor = config.dateExtractor; - this.durationParser = config.durationParser; - this.dateParser = config.dateParser; - - this.monthFrontBetweenRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.MonthFrontBetweenRegex); - this.betweenRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.BetweenRegex); - this.monthFrontSimpleCasesRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.MonthFrontSimpleCasesRegex); - this.simpleCasesRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.SimpleCasesRegex); - this.oneWordPeriodRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.OneWordPeriodRegex); - this.monthWithYear = RegExpUtility.getSafeRegExp(FrenchDateTime.MonthWithYear); - this.monthNumWithYear = RegExpUtility.getSafeRegExp(FrenchDateTime.MonthNumWithYear); - this.yearRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.YearRegex); - this.relativeRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.RelativeRegex); - this.pastRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.PastSuffixRegex); - this.futureRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.NextSuffixRegex); - this.numberCombinedWithUnit = RegExpUtility.getSafeRegExp(FrenchDateTime.NumberCombinedWithDurationUnit); - this.weekOfMonthRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.WeekOfMonthRegex); - this.weekOfYearRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.WeekOfYearRegex); - this.quarterRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.QuarterRegex); - this.quarterRegexYearFront = RegExpUtility.getSafeRegExp(FrenchDateTime.QuarterRegexYearFront); - this.allHalfYearRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.AllHalfYearRegex); - this.seasonRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.SeasonRegex); - this.whichWeekRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.WhichWeekRegex); - this.weekOfRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.WeekOfRegex); - this.monthOfRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.MonthOfRegex); - this.restOfDateRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.RestOfDateRegex); - this.unspecificEndOfRangeRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.UnspecificEndOfRangeRegex); - this.nowRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.NowRegex); - - this.nextPrefixRegex = RegExpUtility.getSafeRegExp("(prochain|prochaine)\b"); - this.previousPrefixRegex = RegExpUtility.getSafeRegExp("(dernier)\b"); - this.thisPrefixRegex = RegExpUtility.getSafeRegExp("(ce|cette)\b"); - - this.nextSuffixRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.NextSuffixRegex); - this.pastSuffixRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.PastSuffixRegex); - - this.inConnectorRegex = config.utilityConfiguration.inConnectorRegex; - this.unitMap = config.unitMap; - this.cardinalMap = config.cardinalMap; - this.dayOfMonth = config.dayOfMonth; - this.monthOfYear = config.monthOfYear; - this.seasonMap = config.seasonMap; - } - - getSwiftDayOrMonth(source: string): number { - let trimedText = source.trim().toLowerCase(); - let swift = 0; - - if (trimedText.endsWith("prochain") || trimedText.endsWith("prochaine")) { - swift = 1; - } - - if (trimedText.endsWith("dernière") || - trimedText.endsWith("dernières") || - trimedText.endsWith("derniere") || - trimedText.endsWith("dernieres")) { - swift = -1; - } - - return swift; - } - - getSwiftYear(source: string): number { - let trimedText = source.trim().toLowerCase(); - let swift = -10; - if (trimedText.endsWith("prochain") || trimedText.endsWith("prochaine")) { - swift = 1; - } - - if (trimedText.endsWith("dernières") || - trimedText.endsWith("dernière") || - trimedText.endsWith("dernieres") || - trimedText.endsWith("derniere") || - trimedText.endsWith("dernier")) { - swift = -1; - } - else if (trimedText.startsWith("cette")) { - swift = 0; - } - - return swift; - } - - isFuture(source: string): boolean { - let trimedText = source.trim().toLowerCase(); - return FrenchDateTime.FutureStartTerms.some(o => trimedText.startsWith(o)) || - FrenchDateTime.FutureEndTerms.some(o => trimedText.endsWith(o)); - } - - isYearToDate(source: string): boolean { - let trimedText = source.trim().toLowerCase(); - return FrenchDateTime.YearToDateTerms.some(o => trimedText === o); - } - - isMonthToDate(source: string): boolean { - let trimedText = source.trim().toLowerCase(); - return FrenchDateTime.MonthToDateTerms.some(o => trimedText === o); - } - - isWeekOnly(source: string): boolean { - let trimedText = source.trim().toLowerCase(); - return (FrenchDateTime.WeekTerms.some(o => trimedText.endsWith(o)) || - (FrenchDateTime.WeekTerms.some(o => trimedText.includes(o)) && - (RegExpUtility.isMatch(this.nextSuffixRegex, trimedText) || - RegExpUtility.isMatch(this.pastSuffixRegex, trimedText)))) && - !FrenchDateTime.WeekendTerms.some(o => trimedText.endsWith(o)); - } - - isWeekend(source: string): boolean { - let trimedText = source.trim().toLowerCase(); - return FrenchDateTime.WeekendTerms.some(o => trimedText.endsWith(o)); - } - - isMonthOnly(source: string): boolean { - let trimedText = source.trim().toLowerCase(); - return FrenchDateTime.MonthTerms.some(o => trimedText.endsWith(o)); - } - - isYearOnly(source: string): boolean { - let trimedText = source.trim().toLowerCase(); - return FrenchDateTime.YearTerms.some(o => trimedText.endsWith(o)); - } - - isLastCardinal(source: string): boolean { - let trimedText = source.trim().toLowerCase(); - return FrenchDateTime.LastCardinalTerms.some(o => trimedText === o); - } -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-date-time/src/dateTime/french/dateTimeConfiguration.ts b/JavaScript/packages/recognizers-date-time/src/dateTime/french/dateTimeConfiguration.ts deleted file mode 100644 index 401bfaf7be..0000000000 --- a/JavaScript/packages/recognizers-date-time/src/dateTime/french/dateTimeConfiguration.ts +++ /dev/null @@ -1,190 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { RegExpUtility } from "@microsoft/recognizers-text"; -import { IDateTimeExtractorConfiguration, IDateTimeParserConfiguration, IDateTimeExtractor } from "../baseDateTime"; -import { BaseNumberExtractor, BaseNumberParser } from "@microsoft/recognizers-text-number"; -import { BaseDateExtractor, BaseDateParser } from "../baseDate"; -import { BaseTimeExtractor, BaseTimeParser } from "../baseTime"; -import { BaseDurationExtractor, BaseDurationParser } from "../baseDuration"; -import { IDateTimeUtilityConfiguration } from "../utilities"; -import { FrenchDateExtractorConfiguration } from "./dateConfiguration"; -import { FrenchDurationExtractorConfiguration } from "./durationConfiguration"; -import { FrenchDateTimeUtilityConfiguration } from "./baseConfiguration"; -import { FrenchDateTime } from "../../resources/frenchDateTime"; -import { ICommonDateTimeParserConfiguration } from "../parsers"; -import { FrenchTimeExtractorConfiguration } from "./timeConfiguration"; - -export class FrenchDateTimeExtractorConfiguration implements IDateTimeExtractorConfiguration { - readonly datePointExtractor: BaseDateExtractor; - readonly timePointExtractor: BaseTimeExtractor; - readonly durationExtractor: BaseDurationExtractor; - readonly suffixRegex: RegExp; - readonly nowRegex: RegExp; - readonly timeOfTodayAfterRegex: RegExp; - readonly timeOfDayRegex: RegExp; - readonly specificTimeOfDayRegex: RegExp; - readonly simpleTimeOfTodayAfterRegex: RegExp; - readonly nightRegex: RegExp; - readonly timeOfTodayBeforeRegex: RegExp; - readonly simpleTimeOfTodayBeforeRegex: RegExp; - readonly specificEndOfRegex: RegExp; - readonly unspecificEndOfRegex: RegExp; - readonly unitRegex: RegExp; - readonly utilityConfiguration: IDateTimeUtilityConfiguration; - readonly prepositionRegex: RegExp; - readonly connectorRegex: RegExp; - - - constructor(dmyDateFormat: boolean) { - this.prepositionRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.PrepositionRegex, "gis"); - this.nowRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.NowRegex, "gis"); - this.suffixRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.SuffixRegex, "gis"); - - this.timeOfDayRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.TimeOfDayRegex, "gis"); - this.specificTimeOfDayRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.SpecificTimeOfDayRegex, "gis"); - this.timeOfTodayAfterRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.TimeOfTodayAfterRegex, "gis"); - this.timeOfTodayBeforeRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.TimeOfTodayBeforeRegex, "gis"); - this.simpleTimeOfTodayAfterRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.SimpleTimeOfTodayAfterRegex, "gis"); - this.simpleTimeOfTodayBeforeRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.SimpleTimeOfTodayBeforeRegex, "gis"); - this.specificEndOfRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.SpecificEndOfRegex, "gis"); - this.unspecificEndOfRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.UnspecificEndOfRegex, "gis"); - this.unitRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.TimeUnitRegex, "gis"); - this.connectorRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.ConnectorRegex, "gis"); - this.nightRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.NightRegex, "gis"); - - this.datePointExtractor = new BaseDateExtractor(new FrenchDateExtractorConfiguration(dmyDateFormat)); - this.timePointExtractor = new BaseTimeExtractor(new FrenchTimeExtractorConfiguration()); - this.durationExtractor = new BaseDurationExtractor(new FrenchDurationExtractorConfiguration()); - this.utilityConfiguration = new FrenchDateTimeUtilityConfiguration(); - } - - isConnectorToken(source: string): boolean { - - return (source === "" || - RegExpUtility.getFirstMatchIndex(this.prepositionRegex, source).matched || - RegExpUtility.getFirstMatchIndex(this.connectorRegex, source).matched); - } -} - -export class FrenchDateTimeParserConfiguration implements IDateTimeParserConfiguration { - readonly tokenBeforeDate: string; - readonly tokenBeforeTime: string; - readonly dateExtractor: IDateTimeExtractor; - readonly timeExtractor: IDateTimeExtractor; - readonly dateParser: BaseDateParser; - readonly timeParser: BaseTimeParser; - readonly cardinalExtractor: BaseNumberExtractor; - readonly numberParser: BaseNumberParser; - readonly durationExtractor: IDateTimeExtractor; - readonly durationParser: BaseDurationParser; - readonly nowRegex: RegExp; - readonly amTimeRegex: RegExp; - readonly pmTimeRegex: RegExp; - readonly simpleTimeOfTodayAfterRegex: RegExp; - readonly simpleTimeOfTodayBeforeRegex: RegExp; - readonly specificTimeOfDayRegex: RegExp; - readonly specificEndOfRegex: RegExp; - readonly unspecificEndOfRegex: RegExp; - readonly unitRegex: RegExp; - readonly unitMap: ReadonlyMap; - readonly numbers: ReadonlyMap; - readonly utilityConfiguration: IDateTimeUtilityConfiguration; - - readonly nextPrefixRegex: RegExp; - readonly previousPrefixRegex: RegExp; - - constructor(config: ICommonDateTimeParserConfiguration) { - this.tokenBeforeDate = FrenchDateTime.TokenBeforeDate; - this.tokenBeforeTime = FrenchDateTime.TokenBeforeTime; - this.nowRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.NowRegex, "gis"); - this.amTimeRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.AMTimeRegex, "gis"); - this.pmTimeRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.PMTimeRegex, "gis"); - this.simpleTimeOfTodayAfterRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.SimpleTimeOfTodayAfterRegex, "gis"); - this.simpleTimeOfTodayBeforeRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.SimpleTimeOfTodayBeforeRegex, "gis"); - this.specificTimeOfDayRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.SpecificTimeOfDayRegex, "gis"); - this.specificEndOfRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.SpecificEndOfRegex, "gis"); - this.unspecificEndOfRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.UnspecificEndOfRegex, "gis"); - this.unitRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.TimeUnitRegex, "gis"); - - this.dateExtractor = config.dateExtractor; - this.timeExtractor = config.timeExtractor; - this.dateParser = config.dateParser; - this.timeParser = config.timeParser; - this.numbers = config.numbers; - this.cardinalExtractor = config.cardinalExtractor; - this.numberParser = config.numberParser; - this.durationExtractor = config.durationExtractor; - this.durationParser = config.durationParser; - this.unitMap = config.unitMap; - this.utilityConfiguration = config.utilityConfiguration; - } - - haveAmbiguousToken(text: string, matchedText: string): boolean { - return false; - } - - getMatchedNowTimex(text: string): { matched: boolean; timex: string; } { - let trimedText = text.trim().toLowerCase(); - let timex = ""; - if (trimedText.endsWith("maintenant")) { - timex = "PRESENT_REF"; - } - else if (trimedText === "récemment" || - trimedText === "précédemment" || - trimedText === "auparavant") { - timex = "PAST_REF"; - } - else if (trimedText === "dès que possible" || - trimedText === "dqp") { - timex = "FUTURE_REF"; - } - else { - return { - matched: false, - timex: null - }; - } - - return { - matched: true, - timex: timex - }; - } - - getSwiftDay(text: string): number { - let trimedText = text.trim().toLowerCase(); - let swift = 0; - - if (trimedText.startsWith("prochain") || - trimedText.endsWith("prochain") || - trimedText.startsWith("prochaine") || - trimedText.endsWith("prochaine")) { - swift = 1; - } - else if (trimedText.startsWith("dernier") || - trimedText.startsWith("dernière") || - trimedText.endsWith("dernier") || - trimedText.endsWith("dernière")) { - swift = -1; - } - - return swift; - - } - - getHour(text: string, hour: number): number { - let trimedText = text.trim().toLowerCase(); - let result = hour; - - // TODO: Replace with a regex - if (trimedText.endsWith("matin") && hour >= 12) { - result -= 12; - } - else if (!trimedText.endsWith("matin") && hour < 12) { - result += 12; - } - - return result; - } -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-date-time/src/dateTime/french/dateTimePeriodConfiguration.ts b/JavaScript/packages/recognizers-date-time/src/dateTime/french/dateTimePeriodConfiguration.ts deleted file mode 100644 index a20d4cd694..0000000000 --- a/JavaScript/packages/recognizers-date-time/src/dateTime/french/dateTimePeriodConfiguration.ts +++ /dev/null @@ -1,242 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { IExtractor, IParser, RegExpUtility } from "@microsoft/recognizers-text"; -import { BaseNumberExtractor, FrenchCardinalExtractor } from "@microsoft/recognizers-text-number"; -import { IDateTimePeriodExtractorConfiguration, IDateTimePeriodParserConfiguration, BaseDateTimePeriodParser } from "../baseDateTimePeriod"; -import { BaseDateExtractor, BaseDateParser } from "../baseDate"; -import { BaseTimeExtractor, BaseTimeParser } from "../baseTime"; -import { BaseDateTimeExtractor, BaseDateTimeParser, IDateTimeExtractor } from "../baseDateTime"; -import { BaseDurationExtractor, BaseDurationParser } from "../baseDuration"; -import { IDateTimeParser, ICommonDateTimeParserConfiguration } from "../parsers"; -import { FrenchDateExtractorConfiguration } from "./dateConfiguration"; -import { FrenchDateTimeExtractorConfiguration } from "./dateTimeConfiguration"; -import { FrenchDurationExtractorConfiguration } from "./durationConfiguration"; -import { FrenchDateTime } from "../../resources/frenchDateTime"; -import { FrenchTimeExtractorConfiguration } from "./timeConfiguration"; -import { DateTimeResolutionResult, DateUtils, DateTimeFormatUtil } from "../utilities"; -import { BaseTimePeriodExtractor } from "../baseTimePeriod"; -import { FrenchTimePeriodExtractorConfiguration } from "./timePeriodConfiguration"; - -export class FrenchDateTimePeriodExtractorConfiguration implements IDateTimePeriodExtractorConfiguration { - readonly cardinalExtractor: BaseNumberExtractor; - readonly singleDateExtractor: IDateTimeExtractor; - readonly singleTimeExtractor: IDateTimeExtractor; - readonly singleDateTimeExtractor: IDateTimeExtractor; - readonly durationExtractor: IDateTimeExtractor; - readonly timePeriodExtractor: IDateTimeExtractor; - readonly simpleCasesRegexes: RegExp[]; - readonly prepositionRegex: RegExp; - readonly tillRegex: RegExp; - readonly specificTimeOfDayRegex: RegExp; - readonly timeOfDayRegex: RegExp; - readonly periodTimeOfDayWithDateRegex: RegExp; - readonly followedUnit: RegExp; - readonly numberCombinedWithUnit: RegExp; - readonly timeUnitRegex: RegExp; - readonly previousPrefixRegex: RegExp; - readonly nextPrefixRegex: RegExp; - readonly relativeTimeUnitRegex: RegExp; - readonly restOfDateTimeRegex: RegExp; - readonly weekDayRegex: RegExp; - readonly generalEndingRegex: RegExp; - readonly middlePauseRegex: RegExp; - - readonly fromRegex: RegExp; - readonly connectorAndRegex: RegExp; - readonly beforeRegex: RegExp; - - - constructor(dmyDateFormat: boolean) { - this.simpleCasesRegexes = [ - RegExpUtility.getSafeRegExp(FrenchDateTime.PureNumFromTo, "gis"), - RegExpUtility.getSafeRegExp(FrenchDateTime.PureNumBetweenAnd, "gis"), - RegExpUtility.getSafeRegExp(FrenchDateTime.SpecificTimeOfDayRegex, "gis") - ]; - - this.prepositionRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.PrepositionRegex); - this.tillRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.TillRegex); - this.specificTimeOfDayRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.PeriodSpecificTimeOfDayRegex); - this.timeOfDayRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.PeriodTimeOfDayRegex); - this.followedUnit = RegExpUtility.getSafeRegExp(FrenchDateTime.TimeFollowedUnit); - this.timeUnitRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.TimeUnitRegex); - this.previousPrefixRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.PastSuffixRegex); - this.nextPrefixRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.NextSuffixRegex); - this.numberCombinedWithUnit = RegExpUtility.getSafeRegExp(FrenchDateTime.TimeNumberCombinedWithUnit); - this.weekDayRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.WeekDayRegex); - this.periodTimeOfDayWithDateRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.PeriodTimeOfDayWithDateRegex); - this.relativeTimeUnitRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.RelativeTimeUnitRegex); - this.restOfDateTimeRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.RestOfDateTimeRegex); - this.generalEndingRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.GeneralEndingRegex); - this.middlePauseRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.MiddlePauseRegex); - - this.fromRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.FromRegex2); - this.connectorAndRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.ConnectorAndRegex); - this.beforeRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.BeforeRegex); - - this.cardinalExtractor = new FrenchCardinalExtractor(); - - this.singleDateExtractor = new BaseDateExtractor(new FrenchDateExtractorConfiguration(dmyDateFormat)); - this.singleTimeExtractor = new BaseTimeExtractor(new FrenchTimeExtractorConfiguration()); - this.singleDateTimeExtractor = new BaseDateTimeExtractor(new FrenchDateTimeExtractorConfiguration(dmyDateFormat)); - this.durationExtractor = new BaseDurationExtractor(new FrenchDurationExtractorConfiguration()); - this.timePeriodExtractor = new BaseTimePeriodExtractor(new FrenchTimePeriodExtractorConfiguration()); - } - - getFromTokenIndex(source: string): { matched: boolean; index: number; } { - return RegExpUtility.getFirstMatchIndex(this.fromRegex, source); - } - - getBetweenTokenIndex(source: string): { matched: boolean; index: number; } { - return RegExpUtility.getFirstMatchIndex(this.beforeRegex, source); - } - - hasConnectorToken(source: string): boolean { - return RegExpUtility.getFirstMatchIndex(this.connectorAndRegex, source).matched; - } -} - -export class FrenchDateTimePeriodParserConfiguration implements IDateTimePeriodParserConfiguration { - readonly pureNumberFromToRegex: RegExp; - readonly pureNumberBetweenAndRegex: RegExp; - readonly periodTimeOfDayWithDateRegex: RegExp; - readonly specificTimeOfDayRegex: RegExp; - readonly pastRegex: RegExp; - readonly futureRegex: RegExp; - readonly relativeTimeUnitRegex: RegExp; - readonly restOfDateTimeRegex: RegExp; - readonly timeOfDayRegex: RegExp; - readonly numberCombinedWithUnitRegex: RegExp; - readonly unitRegex: RegExp; - - readonly nextPrefixRegex: RegExp; - readonly previousPrefixRegex: RegExp; - readonly thisPrefixRegex: RegExp; - - readonly morningStartEndRegex: RegExp; - readonly afternoonStartEndRegex: RegExp; - readonly eveningStartEndRegex: RegExp; - readonly nightStartEndRegex: RegExp; - - readonly numbers: ReadonlyMap; - readonly unitMap: ReadonlyMap; - readonly dateExtractor: IDateTimeExtractor; - readonly timeExtractor: IDateTimeExtractor; - readonly dateTimeExtractor: IDateTimeExtractor; - readonly timePeriodExtractor: IDateTimeExtractor; - readonly durationExtractor: IDateTimeExtractor; - readonly dateParser: BaseDateParser; - readonly timeParser: BaseTimeParser; - readonly dateTimeParser: BaseDateTimeParser; - readonly timePeriodParser: IDateTimeParser; - readonly durationParser: BaseDurationParser; - readonly cardinalExtractor: IExtractor; - readonly numberParser: IParser; - - constructor(config: ICommonDateTimeParserConfiguration) { - this.dateExtractor = config.dateExtractor; - this.timeExtractor = config.timeExtractor; - this.dateTimeExtractor = config.dateTimeExtractor; - this.timePeriodExtractor = config.timePeriodExtractor; - this.cardinalExtractor = config.cardinalExtractor; - this.durationExtractor = config.durationExtractor; - this.numberParser = config.numberParser; - this.dateParser = config.dateParser; - this.timeParser = config.timeParser; - this.dateTimeParser = config.dateTimeParser; - this.timePeriodParser = config.timePeriodParser; - this.durationParser = config.durationParser; - this.unitMap = config.unitMap; - this.numbers = config.numbers; - - this.nextPrefixRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.NextSuffixRegex); - this.previousPrefixRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.PastSuffixRegex); - this.thisPrefixRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.ThisPrefixRegex); - - this.morningStartEndRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.MorningStartEndRegex); - this.afternoonStartEndRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.AfternoonStartEndRegex); - this.eveningStartEndRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.EveningStartEndRegex); - this.nightStartEndRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.NightStartEndRegex); - - this.pureNumberFromToRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.PureNumFromTo); - this.pureNumberBetweenAndRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.PureNumBetweenAnd); - this.specificTimeOfDayRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.SpecificTimeOfDayRegex); - this.timeOfDayRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.TimeOfDayRegex); - this.pastRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.PastSuffixRegex); - this.futureRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.NextSuffixRegex); - this.numberCombinedWithUnitRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.TimeNumberCombinedWithUnit); - this.unitRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.TimeUnitRegex); - this.periodTimeOfDayWithDateRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.PeriodTimeOfDayWithDateRegex); - this.relativeTimeUnitRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.RelativeTimeUnitRegex); - this.restOfDateTimeRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.RestOfDateTimeRegex); - } - - getMatchedTimeRange(source: string): { timeStr: string; beginHour: number; endHour: number; endMin: number; success: boolean; } { - let trimedText = source.trim().toLowerCase(); - let timeStr = ""; - let beginHour = 0; - let endHour = 0; - let endMin = 0; - - if (RegExpUtility.getFirstMatchIndex(this.morningStartEndRegex, trimedText).matched) { - timeStr = "TMO"; - beginHour = 8; - endHour = 12; - } - else if (RegExpUtility.getFirstMatchIndex(this.afternoonStartEndRegex, trimedText).matched) { - timeStr = "TAF"; - beginHour = 12; - endHour = 16; - } - else if (RegExpUtility.getFirstMatchIndex(this.eveningStartEndRegex, trimedText).matched) { - timeStr = "TEV"; - beginHour = 16; - endHour = 20; - } - else if (RegExpUtility.getFirstMatchIndex(this.nightStartEndRegex, trimedText).matched) { - timeStr = "TNI"; - beginHour = 20; - endHour = 23; - endMin = 59; - } - else { - timeStr = null; - return { - success: false, - timeStr, - beginHour, - endHour, - endMin - }; - } - - return { - success: true, - timeStr, - beginHour, - endHour, - endMin - }; - } - - getSwiftPrefix(source: string): number { - let trimedText = source.trim().toLowerCase(); - let swift = 0; - - // TODO: Replace with a regex - if (trimedText.startsWith("prochain") || - trimedText.endsWith("prochain") || - trimedText.startsWith("prochaine") || - trimedText.endsWith("prochaine")) { - swift = 1; - } - else if (trimedText.startsWith("derniere") || - trimedText.startsWith("dernier") || - trimedText.endsWith("derniere") || - trimedText.endsWith("dernier")) { - swift = -1; - } - - return swift; - } -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-date-time/src/dateTime/french/durationConfiguration.ts b/JavaScript/packages/recognizers-date-time/src/dateTime/french/durationConfiguration.ts deleted file mode 100644 index c9443e45b0..0000000000 --- a/JavaScript/packages/recognizers-date-time/src/dateTime/french/durationConfiguration.ts +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { RegExpUtility } from "@microsoft/recognizers-text"; -import { BaseNumberExtractor, BaseNumberParser, FrenchCardinalExtractor } from "@microsoft/recognizers-text-number"; -import { IDurationExtractorConfiguration, IDurationParserConfiguration } from "../baseDuration"; -import { FrenchDateTime } from "../../resources/frenchDateTime"; -import { ICommonDateTimeParserConfiguration } from "../parsers"; - -export class FrenchDurationExtractorConfiguration implements IDurationExtractorConfiguration { - readonly allRegex: RegExp; - readonly halfRegex: RegExp; - readonly followedUnit: RegExp; - readonly numberCombinedWithUnit: RegExp; - readonly anUnitRegex: RegExp; - readonly inexactNumberUnitRegex: RegExp; - readonly suffixAndRegex: RegExp; - readonly relativeDurationUnitRegex: RegExp; - readonly moreThanRegex: RegExp; - readonly lessThanRegex: RegExp; - readonly cardinalExtractor: BaseNumberExtractor; - - constructor() { - this.allRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.AllRegex, "gis"); - this.halfRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.HalfRegex, "gis"); - this.followedUnit = RegExpUtility.getSafeRegExp(FrenchDateTime.DurationFollowedUnit, "gis"); - this.numberCombinedWithUnit = RegExpUtility.getSafeRegExp(FrenchDateTime.NumberCombinedWithDurationUnit, "gis"); - this.anUnitRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.AnUnitRegex, "gis"); - this.inexactNumberUnitRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.InexactNumberUnitRegex, "gis"); - this.suffixAndRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.SuffixAndRegex, "gis"); - this.relativeDurationUnitRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.RelativeDurationUnitRegex, "gis"); - this.moreThanRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.MoreThanRegex, "gis"); - this.lessThanRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.LessThanOneHour, "gis"); - this.cardinalExtractor = new FrenchCardinalExtractor(); - } -} - -export class FrenchDurationParserConfiguration implements IDurationParserConfiguration { - readonly cardinalExtractor: BaseNumberExtractor; - readonly numberParser: BaseNumberParser; - readonly followedUnit: RegExp; - readonly suffixAndRegex: RegExp; - readonly numberCombinedWithUnit: RegExp; - readonly anUnitRegex: RegExp; - readonly allDateUnitRegex: RegExp; - readonly halfDateUnitRegex: RegExp; - readonly inexactNumberUnitRegex: RegExp; - readonly unitMap: ReadonlyMap; - readonly unitValueMap: ReadonlyMap; - readonly doubleNumbers: ReadonlyMap; - - constructor(config: ICommonDateTimeParserConfiguration) { - this.cardinalExtractor = config.cardinalExtractor; - this.numberParser = config.numberParser; - this.followedUnit = RegExpUtility.getSafeRegExp(FrenchDateTime.DurationFollowedUnit); - this.suffixAndRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.SuffixAndRegex); - this.numberCombinedWithUnit = RegExpUtility.getSafeRegExp(FrenchDateTime.NumberCombinedWithDurationUnit); - this.anUnitRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.AnUnitRegex); - this.allDateUnitRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.AllRegex); - this.halfDateUnitRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.HalfRegex); - this.inexactNumberUnitRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.InexactNumberUnitRegex); - this.unitMap = config.unitMap; - this.unitValueMap = config.unitValueMap; - this.doubleNumbers = config.doubleNumbers; - } -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-date-time/src/dateTime/french/holidayConfiguration.ts b/JavaScript/packages/recognizers-date-time/src/dateTime/french/holidayConfiguration.ts deleted file mode 100644 index 321056f916..0000000000 --- a/JavaScript/packages/recognizers-date-time/src/dateTime/french/holidayConfiguration.ts +++ /dev/null @@ -1,208 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { IHolidayExtractorConfiguration, BaseHolidayParserConfiguration } from "../baseHoliday"; -import { RegExpUtility } from "@microsoft/recognizers-text"; -import { DateUtils } from "../utilities"; -import { FrenchDateTime } from "../../resources/frenchDateTime"; - -export class FrenchHolidayExtractorConfiguration implements IHolidayExtractorConfiguration { - readonly holidayRegexes: RegExp[]; - - constructor() { - this.holidayRegexes = [ - RegExpUtility.getSafeRegExp(FrenchDateTime.HolidayRegex1, "gis"), - RegExpUtility.getSafeRegExp(FrenchDateTime.HolidayRegex2, "gis"), - RegExpUtility.getSafeRegExp(FrenchDateTime.HolidayRegex3, "gis"), - RegExpUtility.getSafeRegExp(FrenchDateTime.HolidayRegex4, "gis") - ]; - } -} - -export class FrenchHolidayParserConfiguration extends BaseHolidayParserConfiguration { - - constructor() { - super(); - - this.holidayRegexList = [ - RegExpUtility.getSafeRegExp(FrenchDateTime.HolidayRegex1, "gis"), - RegExpUtility.getSafeRegExp(FrenchDateTime.HolidayRegex2, "gis"), - RegExpUtility.getSafeRegExp(FrenchDateTime.HolidayRegex3, "gis"), - RegExpUtility.getSafeRegExp(FrenchDateTime.HolidayRegex4, "gis") - ]; - - this.holidayNames = FrenchDateTime.HolidayNames; - this.holidayFuncDictionary = this.initHolidayFuncs(); - } - - protected initHolidayFuncs(): ReadonlyMap Date> { - return new Map Date>( - [ - ...super.initHolidayFuncs(), - ["maosbirthday", FrenchHolidayParserConfiguration.MaoBirthday], - ["yuandan", FrenchHolidayParserConfiguration.NewYear], - ["teachersday", FrenchHolidayParserConfiguration.TeacherDay], - ["singleday", FrenchHolidayParserConfiguration.SinglesDay], - ["allsaintsday", FrenchHolidayParserConfiguration.HalloweenDay], - ["youthday", FrenchHolidayParserConfiguration.YouthDay], - ["childrenday", FrenchHolidayParserConfiguration.ChildrenDay], - ["femaleday", FrenchHolidayParserConfiguration.FemaleDay], - ["treeplantingday", FrenchHolidayParserConfiguration.TreePlantDay], - ["arborday", FrenchHolidayParserConfiguration.TreePlantDay], - ["girlsday", FrenchHolidayParserConfiguration.GirlsDay], - ["whiteloverday", FrenchHolidayParserConfiguration.WhiteLoverDay], - ["loverday", FrenchHolidayParserConfiguration.ValentinesDay], - ["christmas", FrenchHolidayParserConfiguration.ChristmasDay], - ["xmas", FrenchHolidayParserConfiguration.ChristmasDay], - ["newyear", FrenchHolidayParserConfiguration.NewYear], - ["newyearday", FrenchHolidayParserConfiguration.NewYear], - ["newyearsday", FrenchHolidayParserConfiguration.NewYear], - ["inaugurationday", FrenchHolidayParserConfiguration.InaugurationDay], - ["groundhougday", FrenchHolidayParserConfiguration.GroundhogDay], - ["valentinesday", FrenchHolidayParserConfiguration.ValentinesDay], - ["stpatrickday", FrenchHolidayParserConfiguration.StPatrickDay], - ["aprilfools", FrenchHolidayParserConfiguration.FoolDay], - ["stgeorgeday", FrenchHolidayParserConfiguration.StGeorgeDay], - ["mayday", FrenchHolidayParserConfiguration.Mayday], - ["cincodemayoday", FrenchHolidayParserConfiguration.CincoDeMayoday], - ["baptisteday", FrenchHolidayParserConfiguration.BaptisteDay], - ["usindependenceday", FrenchHolidayParserConfiguration.UsaIndependenceDay], - ["independenceday", FrenchHolidayParserConfiguration.UsaIndependenceDay], - ["bastilleday", FrenchHolidayParserConfiguration.BastilleDay], - ["halloweenday", FrenchHolidayParserConfiguration.HalloweenDay], - ["allhallowday", FrenchHolidayParserConfiguration.AllHallowDay], - ["allsoulsday", FrenchHolidayParserConfiguration.AllSoulsday], - ["guyfawkesday", FrenchHolidayParserConfiguration.GuyFawkesDay], - ["veteransday", FrenchHolidayParserConfiguration.Veteransday], - ["christmaseve", FrenchHolidayParserConfiguration.ChristmasEve], - ["newyeareve", FrenchHolidayParserConfiguration.NewYearEve], - ["fathersday", FrenchHolidayParserConfiguration.FathersDay], - ["mothersday", FrenchHolidayParserConfiguration.MothersDay], - ["labourday", FrenchHolidayParserConfiguration.LabourDay] - ]); - } - - // All JavaScript dates are zero-based (-1) - private static NewYear(year: number): Date { - return new Date(year, 1 - 1, 1); - } - private static NewYearEve(year: number): Date { - return new Date(year, 12 - 1, 31); - } - private static ChristmasDay(year: number): Date { - return new Date(year, 12 - 1, 25); - } - private static ChristmasEve(year: number): Date { - return new Date(year, 12 - 1, 24); - } - private static FemaleDay(year: number): Date { - return new Date(year, 3 - 1, 8); - } - private static ChildrenDay(year: number): Date { - return new Date(year, 6 - 1, 1); - } - private static HalloweenDay(year: number): Date { - return new Date(year, 10 - 1, 31); - } - private static EasterDay(year: number): Date { - return DateUtils.minValue(); - } - - private static ValentinesDay(year: number): Date { - return new Date(year, 2, 14); - } - private static WhiteLoverDay(year: number): Date { - return new Date(year, 3, 14); - } - private static FoolDay(year: number): Date { - return new Date(year, 4, 1); - } - private static GirlsDay(year: number): Date { - return new Date(year, 3, 7); - } - private static TreePlantDay(year: number): Date { - return new Date(year, 3, 12); - } - private static YouthDay(year: number): Date { - return new Date(year, 5, 4); - } - private static TeacherDay(year: number): Date { - return new Date(year, 9, 10); - } - private static SinglesDay(year: number): Date { - return new Date(year, 11, 11); - } - private static MaoBirthday(year: number): Date { - return new Date(year, 12, 26); - } - private static InaugurationDay(year: number): Date { - return new Date(year, 1, 20); - } - private static GroundhogDay(year: number): Date { - return new Date(year, 2, 2); - } - private static StPatrickDay(year: number): Date { - return new Date(year, 3, 17); - } - private static StGeorgeDay(year: number): Date { - return new Date(year, 4, 23); - } - private static Mayday(year: number): Date { - return new Date(year, 5, 1); - } - private static CincoDeMayoday(year: number): Date { - return new Date(year, 5, 5); - } - private static BaptisteDay(year: number): Date { - return new Date(year, 6, 24); - } - private static UsaIndependenceDay(year: number): Date { - return new Date(year, 7, 4); - } - private static BastilleDay(year: number): Date { - return new Date(year, 7, 14); - } - private static AllHallowDay(year: number): Date { - return new Date(year, 11, 1); - } - private static AllSoulsday(year: number): Date { - return new Date(year, 11, 2); - } - private static GuyFawkesDay(year: number): Date { - return new Date(year, 11, 5); - } - private static Veteransday(year: number): Date { - return new Date(year, 11, 11); - } - protected static FathersDay(year: number): Date { - return new Date(year, 6, 17); - } - protected static MothersDay(year: number): Date { - return new Date(year, 5, 27); - } - protected static LabourDay(year: number): Date { - return new Date(year, 5, 1); - } - - getSwiftYear(text: string): number { - let trimedText = text.trim().toLowerCase(); - let swift = -10; - - if (trimedText.endsWith("prochain")) { // next - 'l'annee prochain') - swift = 1; - } - else if (trimedText.endsWith("dernier")) { // last - 'l'annee dernier' - swift = -1; - } - else if (trimedText.startsWith("cette")) { // this - 'cette annees' - swift = 0; - } - - return swift; - } - - sanitizeHolidayToken(holiday: string): string { - return holiday.replace(/ /g, "") - .replace(/'/g, ""); - } -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-date-time/src/dateTime/french/mergedConfiguration.ts b/JavaScript/packages/recognizers-date-time/src/dateTime/french/mergedConfiguration.ts deleted file mode 100644 index 47cd408b19..0000000000 --- a/JavaScript/packages/recognizers-date-time/src/dateTime/french/mergedConfiguration.ts +++ /dev/null @@ -1,106 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { RegExpUtility } from "@microsoft/recognizers-text"; -import { BaseNumberExtractor, FrenchIntegerExtractor } from "@microsoft/recognizers-text-number"; -import { IMergedExtractorConfiguration, IMergedParserConfiguration } from "../baseMerged"; -import { BaseDateExtractor, BaseDateParser } from "../baseDate"; -import { BaseTimeExtractor, BaseTimeParser } from "../baseTime"; -import { IDateTimeExtractor, BaseDateTimeExtractor, BaseDateTimeParser } from "../baseDateTime"; -import { BaseDatePeriodExtractor, BaseDatePeriodParser } from "../baseDatePeriod"; -import { BaseTimePeriodExtractor, BaseTimePeriodParser } from "../baseTimePeriod"; -import { BaseDateTimePeriodExtractor, BaseDateTimePeriodParser } from "../baseDateTimePeriod"; -import { BaseHolidayExtractor, BaseHolidayParser } from "../baseHoliday"; -import { BaseDurationExtractor, BaseDurationParser } from "../baseDuration"; -import { BaseSetExtractor, BaseSetParser } from "../baseSet"; -import { FrenchDateTime } from "../../resources/frenchDateTime"; -import { FrenchDateExtractorConfiguration } from "./dateConfiguration"; -import { FrenchDateTimeExtractorConfiguration } from "./dateTimeConfiguration"; -import { FrenchDatePeriodExtractorConfiguration, FrenchDatePeriodParserConfiguration } from "./datePeriodConfiguration"; -import { FrenchDurationExtractorConfiguration } from "./durationConfiguration"; -import { FrenchHolidayExtractorConfiguration, FrenchHolidayParserConfiguration } from "./holidayConfiguration"; -import { FrenchCommonDateTimeParserConfiguration } from "./baseConfiguration"; -import { FrenchTimeExtractorConfiguration } from "./timeConfiguration"; -import { FrenchTimePeriodExtractorConfiguration, FrenchTimePeriodParserConfiguration } from "./timePeriodConfiguration"; -import { FrenchDateTimePeriodExtractorConfiguration, FrenchDateTimePeriodParserConfiguration } from "./dateTimePeriodConfiguration"; -import { FrenchSetExtractorConfiguration, FrenchSetParserConfiguration } from "./setConfiguration"; -import { DefinitionLoader } from "../utilities"; - -export class FrenchMergedExtractorConfiguration implements IMergedExtractorConfiguration { - readonly dateExtractor: IDateTimeExtractor; - readonly timeExtractor: IDateTimeExtractor; - readonly dateTimeExtractor: IDateTimeExtractor; - readonly datePeriodExtractor: IDateTimeExtractor; - readonly timePeriodExtractor: IDateTimeExtractor; - readonly dateTimePeriodExtractor: IDateTimeExtractor; - readonly holidayExtractor: IDateTimeExtractor; - readonly durationExtractor: IDateTimeExtractor; - readonly setExtractor: IDateTimeExtractor; - readonly integerExtractor: BaseNumberExtractor; - readonly afterRegex: RegExp; - readonly beforeRegex: RegExp; - readonly sinceRegex: RegExp; - readonly fromToRegex: RegExp; - readonly singleAmbiguousMonthRegex: RegExp; - readonly prepositionSuffixRegex: RegExp; - readonly ambiguousRangeModifierPrefix: RegExp; - readonly potentialAmbiguousRangeRegex: RegExp; - readonly numberEndingPattern: RegExp; - readonly unspecificDatePeriodRegex: RegExp; - readonly filterWordRegexList: RegExp[]; - readonly AmbiguityFiltersDict: Map - - constructor(dmyDateFormat: boolean = false) { - this.beforeRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.BeforeRegex); - this.afterRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.AfterRegex); - this.sinceRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.SinceRegex); - this.fromToRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.FromToRegex); - this.singleAmbiguousMonthRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.SingleAmbiguousMonthRegex); - this.prepositionSuffixRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.PrepositionSuffixRegex); - this.ambiguousRangeModifierPrefix = null; - this.potentialAmbiguousRangeRegex = null; - this.numberEndingPattern = RegExpUtility.getSafeRegExp(FrenchDateTime.NumberEndingPattern); - this.unspecificDatePeriodRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.UnspecificDatePeriodRegex); - - this.dateExtractor = new BaseDateExtractor(new FrenchDateExtractorConfiguration(dmyDateFormat)); - this.timeExtractor = new BaseTimeExtractor(new FrenchTimeExtractorConfiguration()); - this.dateTimeExtractor = new BaseDateTimeExtractor(new FrenchDateTimeExtractorConfiguration(dmyDateFormat)); - this.datePeriodExtractor = new BaseDatePeriodExtractor(new FrenchDatePeriodExtractorConfiguration(dmyDateFormat)); - this.timePeriodExtractor = new BaseTimePeriodExtractor(new FrenchTimePeriodExtractorConfiguration()); - this.dateTimePeriodExtractor = new BaseDateTimePeriodExtractor(new FrenchDateTimePeriodExtractorConfiguration(dmyDateFormat)); - this.durationExtractor = new BaseDurationExtractor(new FrenchDurationExtractorConfiguration()); - this.setExtractor = new BaseSetExtractor(new FrenchSetExtractorConfiguration(dmyDateFormat)); - this.holidayExtractor = new BaseHolidayExtractor(new FrenchHolidayExtractorConfiguration()); - this.integerExtractor = new FrenchIntegerExtractor(); - this.filterWordRegexList = []; - this.AmbiguityFiltersDict = DefinitionLoader.LoadAmbiguityFilters(FrenchDateTime.AmbiguityFiltersDict); - } -} - -export class FrenchMergedParserConfiguration extends FrenchCommonDateTimeParserConfiguration implements IMergedParserConfiguration { - readonly beforeRegex: RegExp; - readonly afterRegex: RegExp; - readonly sinceRegex: RegExp; - readonly dateParser: BaseDateParser; - readonly holidayParser: BaseHolidayParser; - readonly timeParser: BaseTimeParser; - readonly dateTimeParser: BaseDateTimeParser; - readonly datePeriodParser: BaseDatePeriodParser; - readonly timePeriodParser: BaseTimePeriodParser; - readonly dateTimePeriodParser: BaseDateTimePeriodParser; - readonly durationParser: BaseDurationParser; - readonly setParser: BaseSetParser; - - constructor(dmyDateFormat: boolean = false) { - super(dmyDateFormat); - - this.beforeRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.BeforeRegex); - this.afterRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.AfterRegex); - this.sinceRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.SinceRegex); - - this.datePeriodParser = new BaseDatePeriodParser(new FrenchDatePeriodParserConfiguration(this)); - this.timePeriodParser = new BaseTimePeriodParser(new FrenchTimePeriodParserConfiguration(this)); - this.setParser = new BaseSetParser(new FrenchSetParserConfiguration(this)); - this.holidayParser = new BaseHolidayParser(new FrenchHolidayParserConfiguration()); - } -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-date-time/src/dateTime/french/setConfiguration.ts b/JavaScript/packages/recognizers-date-time/src/dateTime/french/setConfiguration.ts deleted file mode 100644 index d68bc11550..0000000000 --- a/JavaScript/packages/recognizers-date-time/src/dateTime/french/setConfiguration.ts +++ /dev/null @@ -1,171 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { RegExpUtility } from "@microsoft/recognizers-text"; -import { ISetExtractorConfiguration, ISetParserConfiguration } from "../baseSet"; -import { BaseDurationExtractor, BaseDurationParser } from "../baseDuration"; -import { BaseTimeExtractor, BaseTimeParser } from "../baseTime"; -import { BaseDateExtractor, BaseDateParser } from "../baseDate"; -import { IDateTimeExtractor, BaseDateTimeExtractor, BaseDateTimeParser } from "../baseDateTime"; -import { BaseDatePeriodExtractor, BaseDatePeriodParser } from "../baseDatePeriod"; -import { BaseTimePeriodExtractor, BaseTimePeriodParser } from "../baseTimePeriod"; -import { BaseDateTimePeriodExtractor, BaseDateTimePeriodParser } from "../baseDateTimePeriod"; -import { FrenchDateTime } from "../../resources/frenchDateTime"; -import { FrenchDurationExtractorConfiguration } from "./durationConfiguration"; -import { FrenchDateExtractorConfiguration } from "./dateConfiguration"; -import { FrenchDateTimeExtractorConfiguration } from "./dateTimeConfiguration"; -import { FrenchDatePeriodExtractorConfiguration } from "./datePeriodConfiguration"; -import { FrenchDateTimePeriodExtractorConfiguration } from "./dateTimePeriodConfiguration"; -import { ICommonDateTimeParserConfiguration } from "../parsers"; -import { FrenchTimeExtractorConfiguration } from "./timeConfiguration"; -import { FrenchTimePeriodExtractorConfiguration } from "./timePeriodConfiguration"; - -export class FrenchSetExtractorConfiguration implements ISetExtractorConfiguration { - readonly lastRegex: RegExp; - readonly eachPrefixRegex: RegExp; - readonly periodicRegex: RegExp; - readonly eachUnitRegex: RegExp; - readonly eachDayRegex: RegExp; - readonly beforeEachDayRegex: RegExp; - readonly setWeekDayRegex: RegExp; - readonly setEachRegex: RegExp; - readonly durationExtractor: IDateTimeExtractor; - readonly timeExtractor: IDateTimeExtractor; - readonly dateExtractor: IDateTimeExtractor; - readonly dateTimeExtractor: IDateTimeExtractor; - readonly datePeriodExtractor: IDateTimeExtractor; - readonly timePeriodExtractor: IDateTimeExtractor; - readonly dateTimePeriodExtractor: IDateTimeExtractor; - - constructor(dmyDateFormat: boolean) { - this.lastRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.SetLastRegex, "gis"); - this.periodicRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.PeriodicRegex, "gis"); - this.eachUnitRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.EachUnitRegex, "gis"); - this.eachPrefixRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.EachPrefixRegex, "gis"); - this.eachDayRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.EachDayRegex, "gis"); - this.beforeEachDayRegex = null; - this.setEachRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.SetEachRegex, "gis"); - this.setWeekDayRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.SetWeekDayRegex, "gis"); - - this.durationExtractor = new BaseDurationExtractor(new FrenchDurationExtractorConfiguration()); - this.timeExtractor = new BaseTimeExtractor(new FrenchTimeExtractorConfiguration()); - this.dateExtractor = new BaseDateExtractor(new FrenchDateExtractorConfiguration(dmyDateFormat)); - this.dateTimeExtractor = new BaseDateTimeExtractor(new FrenchDateTimeExtractorConfiguration(dmyDateFormat)); - this.datePeriodExtractor = new BaseDatePeriodExtractor(new FrenchDatePeriodExtractorConfiguration(dmyDateFormat)); - this.timePeriodExtractor = new BaseTimePeriodExtractor(new FrenchTimePeriodExtractorConfiguration()); - this.dateTimePeriodExtractor = new BaseDateTimePeriodExtractor(new FrenchDateTimePeriodExtractorConfiguration(dmyDateFormat)); - } -} - -export class FrenchSetParserConfiguration implements ISetParserConfiguration { - readonly durationExtractor: IDateTimeExtractor; - readonly durationParser: BaseDurationParser; - readonly timeExtractor: IDateTimeExtractor; - readonly timeParser: BaseTimeParser; - readonly dateExtractor: IDateTimeExtractor; - readonly dateParser: BaseDateParser; - readonly dateTimeExtractor: IDateTimeExtractor; - readonly dateTimeParser: BaseDateTimeParser; - readonly datePeriodExtractor: IDateTimeExtractor; - readonly datePeriodParser: BaseDatePeriodParser; - readonly timePeriodExtractor: IDateTimeExtractor; - readonly timePeriodParser: BaseTimePeriodParser; - readonly dateTimePeriodExtractor: IDateTimeExtractor; - readonly dateTimePeriodParser: BaseDateTimePeriodParser; - readonly unitMap: ReadonlyMap; - readonly eachPrefixRegex: RegExp; - readonly periodicRegex: RegExp; - readonly eachUnitRegex: RegExp; - readonly eachDayRegex: RegExp; - readonly setWeekDayRegex: RegExp; - readonly setEachRegex: RegExp; - - constructor(config: ICommonDateTimeParserConfiguration) { - this.durationExtractor = config.durationExtractor; - this.timeExtractor = config.timeExtractor; - this.dateExtractor = config.dateExtractor; - this.dateTimeExtractor = config.dateTimeExtractor; - this.datePeriodExtractor = config.datePeriodExtractor; - this.timePeriodExtractor = config.timePeriodExtractor; - this.dateTimePeriodExtractor = config.dateTimePeriodExtractor; - this.durationParser = config.durationParser; - this.timeParser = config.timeParser; - this.dateParser = config.dateParser; - this.dateTimeParser = config.dateTimeParser; - this.datePeriodParser = config.datePeriodParser; - this.timePeriodParser = config.timePeriodParser; - this.dateTimePeriodParser = config.dateTimePeriodParser; - this.unitMap = config.unitMap; - - this.eachPrefixRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.EachPrefixRegex, "gis"); - this.periodicRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.PeriodicRegex, "gis"); - this.eachUnitRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.EachUnitRegex, "gis"); - this.eachDayRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.EachDayRegex, "gis"); - this.setWeekDayRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.SetWeekDayRegex, "gis"); - this.setEachRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.SetEachRegex, "gis"); - } - - getMatchedDailyTimex(text: string): { matched: boolean; timex: string; } { - let trimedText = text.trim().toLowerCase(); - let timex = ""; - - if (trimedText === "quotidien" || trimedText === "quotidienne" || - trimedText === "jours" || trimedText === "journellement") { - timex = "P1D"; - } - else if (trimedText === "hebdomadaire") { - timex = "P1W"; - } - else if (trimedText === "bihebdomadaire") { - timex = "P2W"; - } - else if (trimedText === "mensuel" || trimedText === "mensuelle") { - timex = "P1M"; - } - else if (trimedText === "annuel" || trimedText === "annuellement") { - timex = "P1Y"; - } - else { - timex = null; - return { - timex, - matched: false - }; - } - - return { - timex, - matched: true - }; - } - - getMatchedUnitTimex(text: string): { matched: boolean; timex: string; } { - let trimedText = text.trim().toLowerCase(); - let timex = ""; - - if (trimedText === "jour" || trimedText === "journee") { - timex = "P1D"; - } - else if (trimedText === "semaine") { - timex = "P1W"; - } - else if (trimedText === "mois") { - timex = "P1M"; - } - else if (trimedText === "an" || trimedText === "annee") { - timex = "P1Y"; - } - else { - timex = null; - return { - matched: false, - timex - }; - } - - return { - matched: true, - timex - }; - } -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-date-time/src/dateTime/french/timeConfiguration.ts b/JavaScript/packages/recognizers-date-time/src/dateTime/french/timeConfiguration.ts deleted file mode 100644 index e8b15309f0..0000000000 --- a/JavaScript/packages/recognizers-date-time/src/dateTime/french/timeConfiguration.ts +++ /dev/null @@ -1,145 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { IExtractor } from "@microsoft/recognizers-text"; -import { RegExpUtility } from "@microsoft/recognizers-text"; -import { ITimeExtractorConfiguration, ITimeParserConfiguration } from "../baseTime"; -import { FrenchDateTime } from "../../resources/frenchDateTime"; -import { BaseDurationExtractor } from "../baseDuration"; -import { FrenchDurationExtractorConfiguration } from "./durationConfiguration"; -import { ICommonDateTimeParserConfiguration } from "../parsers"; -import { IDateTimeUtilityConfiguration } from "../utilities"; -import { IDateTimeExtractor } from "../baseDateTime"; - -export class FrenchTimeExtractorConfiguration implements ITimeExtractorConfiguration { - readonly timeRegexList: RegExp[]; - readonly atRegex: RegExp; - readonly ishRegex: RegExp; - - readonly durationExtractor: IDateTimeExtractor; - - constructor() { - this.atRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.AtRegex, "gis"); - this.ishRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.IshRegex, "gis");; - this.timeRegexList = FrenchTimeExtractorConfiguration.getTimeRegexList(); - - this.durationExtractor = new BaseDurationExtractor(new FrenchDurationExtractorConfiguration()); - } - - static getTimeRegexList(): RegExp[] { - return [ - RegExpUtility.getSafeRegExp(FrenchDateTime.TimeRegex1, "gis"), - RegExpUtility.getSafeRegExp(FrenchDateTime.TimeRegex2, "gis"), - RegExpUtility.getSafeRegExp(FrenchDateTime.TimeRegex3, "gis"), - RegExpUtility.getSafeRegExp(FrenchDateTime.TimeRegex4, "gis"), - RegExpUtility.getSafeRegExp(FrenchDateTime.TimeRegex5, "gis"), - RegExpUtility.getSafeRegExp(FrenchDateTime.TimeRegex6, "gis"), - RegExpUtility.getSafeRegExp(FrenchDateTime.TimeRegex7, "gis"), - RegExpUtility.getSafeRegExp(FrenchDateTime.TimeRegex8, "gis"), - RegExpUtility.getSafeRegExp(FrenchDateTime.TimeRegex9, "gis"), - RegExpUtility.getSafeRegExp(FrenchDateTime.TimeRegex10, "gis"), - RegExpUtility.getSafeRegExp(FrenchDateTime.ConnectNumRegex, "gis") - ]; - } -} - -export class FrenchTimeParserConfiguration implements ITimeParserConfiguration { - - readonly timeTokenPrefix: string; - readonly atRegex: RegExp; - readonly timeRegexes: RegExp[]; - readonly lessThanOneHour: RegExp; - readonly timeSuffix: RegExp; - readonly numbers: ReadonlyMap; - readonly utilityConfiguration: IDateTimeUtilityConfiguration; - - constructor(config: ICommonDateTimeParserConfiguration) { - - this.timeTokenPrefix = FrenchDateTime.TimeTokenPrefix; - this.atRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.AtRegex, "gis"); - this.timeRegexes = FrenchTimeExtractorConfiguration.getTimeRegexList(); - this.lessThanOneHour = RegExpUtility.getSafeRegExp(FrenchDateTime.LessThanOneHour, "gis"); - this.timeSuffix = RegExpUtility.getSafeRegExp(FrenchDateTime.TimeSuffix, "gis"); - - this.utilityConfiguration = config.utilityConfiguration; - this.numbers = config.numbers; - } - - adjustByPrefix(prefix: string, adjust: { hour: number; min: number; hasMin: boolean; }) { - let deltaMin = 0; - let trimedPrefix = prefix.trim().toLowerCase(); - - // @todo Move hardcoded strings to resource YAML file. - if (trimedPrefix.endsWith("demie")) { - deltaMin = 30; - } - else if (trimedPrefix.endsWith("un quart") || trimedPrefix.endsWith("quart")) { - deltaMin = 15; - } - else if (trimedPrefix.endsWith("trois quarts")) { - deltaMin = 45; - } - else { - let matches = RegExpUtility.getMatches(this.lessThanOneHour, trimedPrefix); - if (matches.length) { - let match = matches[0]; - let minStr = match.groups("deltamin").value; - if (minStr) { - deltaMin = parseInt(minStr, 10); - } - else { - minStr = match.groups("deltaminnum").value.toLowerCase(); - if (this.numbers.has(minStr)) { - deltaMin = this.numbers.get(minStr); - } - } - } - } - - if (trimedPrefix.endsWith("à") || trimedPrefix.includes("moins")) { - deltaMin = -deltaMin; - } - - adjust.min += deltaMin; - if (adjust.min < 0) { - adjust.min += 60; - adjust.hour -= 1; - } - - adjust.hasMin = true; - } - - adjustBySuffix(suffix: string, adjust: { hour: number; min: number; hasMin: boolean; hasAm: boolean; hasPm: boolean; }) { - let trimedSuffix = suffix.trim().toLowerCase(); - - let deltaHour = 0; - let matches = RegExpUtility.getMatches(this.timeSuffix, trimedSuffix); - if (matches.length) { - let match = matches[0]; - if (match.index === 0 && match.length === trimedSuffix.length) { - let oclockStr = match.groups("heures").value; - if (!oclockStr) { - let amStr = match.groups("am").value; - if (amStr) { - if (adjust.hour >= 12) { - deltaHour = -12; - } - - adjust.hasAm = true; - } - - let pmStr = match.groups("pm").value; - if (pmStr) { - if (adjust.hour < 12) { - deltaHour = 12; - } - - adjust.hasPm = true; - } - } - } - } - - adjust.hour = (adjust.hour + deltaHour) % 24; - } -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-date-time/src/dateTime/french/timeParser.ts b/JavaScript/packages/recognizers-date-time/src/dateTime/french/timeParser.ts deleted file mode 100644 index a99f1d601f..0000000000 --- a/JavaScript/packages/recognizers-date-time/src/dateTime/french/timeParser.ts +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { RegExpUtility } from "@microsoft/recognizers-text"; -import { BaseTimeParser, ITimeParserConfiguration } from "../baseTime"; -import { DateTimeResolutionResult, DateUtils, DateTimeFormatUtil } from "../utilities"; -import { FrenchDateTime } from "../../resources/frenchDateTime"; - -export class FrenchTimeParser extends BaseTimeParser { - constructor(config: ITimeParserConfiguration) { - super(config); - } - - internalParse(text: string, referenceTime: Date): DateTimeResolutionResult { - - let ret = super.internalParse(text, referenceTime); - if (!ret.success) { - ret = this.parseIsh(text, referenceTime); - } - - return ret; - } - - parseIsh(text: string, referenceTime: Date): DateTimeResolutionResult { - let ret = new DateTimeResolutionResult(); - let trimedText = text.trim().toLowerCase(); - - let matches = RegExpUtility.getMatches(RegExpUtility.getSafeRegExp(FrenchDateTime.IshRegex), text); - if (matches.length && matches[0].index === 0 && matches[0].length === trimedText.length) { - let hourStr = matches[0].groups("hour").value; - let hour = 12; - if (hourStr) { - hour = parseInt(hourStr, 10); - } - - ret.timex = "T" + DateTimeFormatUtil.toString(hour, 2); - ret.futureValue = - ret.pastValue = - DateUtils.safeCreateFromMinValue(referenceTime.getFullYear(), referenceTime.getMonth(), referenceTime.getDate(), hour, 0, 0); - ret.success = true; - } - - return ret; - } -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-date-time/src/dateTime/french/timePeriodConfiguration.ts b/JavaScript/packages/recognizers-date-time/src/dateTime/french/timePeriodConfiguration.ts deleted file mode 100644 index be8294fadd..0000000000 --- a/JavaScript/packages/recognizers-date-time/src/dateTime/french/timePeriodConfiguration.ts +++ /dev/null @@ -1,147 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { RegExpUtility, IExtractor } from "@microsoft/recognizers-text"; -import { ITimePeriodExtractorConfiguration, ITimePeriodParserConfiguration } from "../baseTimePeriod"; -import { BaseTimeExtractor, BaseTimeParser } from "../baseTime"; -import { IDateTimeUtilityConfiguration, TimexUtil } from "../utilities"; -import { FrenchTimeExtractorConfiguration } from "./timeConfiguration"; -import { FrenchDateTimeUtilityConfiguration } from "./baseConfiguration"; -import { FrenchDateTime } from "../../resources/frenchDateTime"; -import { ICommonDateTimeParserConfiguration } from "../parsers"; -import { IDateTimeExtractor } from "../baseDateTime"; -import { EnglishIntegerExtractor, NumberMode } from "@microsoft/recognizers-text-number"; -import { Constants } from "../constants"; -import { EnglishDateTime } from "../../resources/englishDateTime"; - -export class FrenchTimePeriodExtractorConfiguration implements ITimePeriodExtractorConfiguration { - readonly simpleCasesRegex: RegExp[]; - readonly tillRegex: RegExp; - readonly timeOfDayRegex: RegExp; - readonly generalEndingRegex: RegExp; - readonly singleTimeExtractor: IDateTimeExtractor; - readonly integerExtractor: IExtractor; - readonly utilityConfiguration: FrenchDateTimeUtilityConfiguration; - - readonly fromRegex: RegExp; - readonly connectorAndRegex: RegExp; - readonly beforeRegex: RegExp; - - constructor() { - this.singleTimeExtractor = new BaseTimeExtractor(new FrenchTimeExtractorConfiguration()); - this.integerExtractor = new EnglishIntegerExtractor(); - this.utilityConfiguration = new FrenchDateTimeUtilityConfiguration(); - - this.simpleCasesRegex = [ - RegExpUtility.getSafeRegExp(FrenchDateTime.PureNumFromTo, "gis"), - RegExpUtility.getSafeRegExp(FrenchDateTime.PureNumBetweenAnd, "gis"), - RegExpUtility.getSafeRegExp(FrenchDateTime.PmRegex, "gis"), - RegExpUtility.getSafeRegExp(FrenchDateTime.AmRegex, "gis") - ]; - - this.tillRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.TillRegex, "gis"); - this.timeOfDayRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.TimeOfDayRegex, "gis"); - this.generalEndingRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.GeneralEndingRegex, "gis"); - - this.fromRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.FromRegex2, "gis"); - this.connectorAndRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.ConnectorAndRegex, "gis"); - this.beforeRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.BeforeRegex2, "gis"); - } - - getFromTokenIndex(text: string): { matched: boolean; index: number; } { - return RegExpUtility.getFirstMatchIndex(this.fromRegex, text); - } - - hasConnectorToken(text: string): boolean { - return RegExpUtility.getFirstMatchIndex(this.connectorAndRegex, text).matched; - } - - getBetweenTokenIndex(text: string): { matched: boolean; index: number; } { - return RegExpUtility.getFirstMatchIndex(this.beforeRegex, text); - } -} - -export class FrenchTimePeriodParserConfiguration implements ITimePeriodParserConfiguration { - readonly timeExtractor: IDateTimeExtractor; - readonly timeParser: BaseTimeParser; - readonly integerExtractor: IExtractor; - readonly pureNumberFromToRegex: RegExp; - readonly pureNumberBetweenAndRegex: RegExp; - readonly timeOfDayRegex: RegExp; - readonly tillRegex: RegExp; - readonly numbers: ReadonlyMap; - readonly utilityConfiguration: IDateTimeUtilityConfiguration; - readonly specificTimeFromToRegex: RegExp; - readonly specificTimeBetweenAndRegex: RegExp; - - constructor(config: ICommonDateTimeParserConfiguration) { - this.timeExtractor = config.timeExtractor; - this.timeParser = config.timeParser; - this.integerExtractor = config.integerExtractor; - this.numbers = config.numbers; - this.utilityConfiguration = config.utilityConfiguration; - this.pureNumberFromToRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.PureNumFromTo, "gis"); - this.pureNumberBetweenAndRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.PureNumBetweenAnd, "gis"); - this.timeOfDayRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.TimeOfDayRegex, "gis"); - this.tillRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.TillRegex, "gis"); - this.specificTimeFromToRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.SpecificTimeFromTo); - this.specificTimeBetweenAndRegex = RegExpUtility.getSafeRegExp(FrenchDateTime.SpecificTimeBetweenAnd); - } - - getMatchedTimexRange(text: string): { matched: boolean; timex: string; beginHour: number; endHour: number; endMin: number; } { - - let trimmedText = text.trim().toLowerCase(); - - if (trimmedText.endsWith("s")) { - trimmedText = trimmedText.substring(0, trimmedText.length - 1); - } - - let beginHour = 0; - let endHour = 0; - let endMin = 0; - let timex = ""; - - let timeOfDay = ""; - if (FrenchDateTime.MorningTermList.some(o => trimmedText.endsWith(o))) { - timeOfDay = Constants.Morning; - } - else if (FrenchDateTime.AfternoonTermList.some(o => trimmedText.endsWith(o))) { - timeOfDay = Constants.Afternoon; - } - else if (FrenchDateTime.EveningTermList.some(o => trimmedText.endsWith(o))) { - timeOfDay = Constants.Evening; - } - else if (trimmedText === FrenchDateTime.DaytimeTermList[0] || - trimmedText.endsWith(FrenchDateTime.DaytimeTermList[1]) || - trimmedText.endsWith(FrenchDateTime.DaytimeTermList[2])) { - timeOfDay = Constants.Daytime; - } - else if (FrenchDateTime.NightTermList.some(o => trimmedText.endsWith(o))) { - timeOfDay = Constants.Night; - } - else { - timex = null; - return { - matched: false, - timex, - beginHour, - endHour, - endMin - }; - } - - let parseResult = TimexUtil.parseTimeOfDay(timeOfDay); - timex = parseResult.timeX; - beginHour = parseResult.beginHour; - endHour = parseResult.endHour; - endMin = parseResult.endMin; - - return { - matched: true, - timex, - beginHour, - endHour, - endMin - }; - } -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-date-time/src/dateTime/models.ts b/JavaScript/packages/recognizers-date-time/src/dateTime/models.ts deleted file mode 100644 index 2c077afc6d..0000000000 --- a/JavaScript/packages/recognizers-date-time/src/dateTime/models.ts +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { IModel, ModelResult, IExtractor, ParseResult, QueryProcessor } from "@microsoft/recognizers-text"; -import { IDateTimeParser, DateTimeParseResult } from "./parsers"; -import { IDateTimeExtractor } from "./baseDateTime"; - -export class DateTimeModelResult extends ModelResult { - timexStr: string -} - -export interface IDateTimeModel extends IModel { - parse(query: string, referenceDate?: Date): ModelResult[] -} - -export class DateTimeModel implements IDateTimeModel { - modelTypeName: string = "datetime"; - - protected readonly extractor: IDateTimeExtractor; - protected readonly parser: IDateTimeParser; - - constructor(parser: IDateTimeParser, extractor: IDateTimeExtractor) { - this.extractor = extractor; - this.parser = parser; - } - - parse(query: string, referenceDate: Date = new Date()): ModelResult[] { - - query = QueryProcessor.preProcess(query); - let parseDates = new Array(); - - try { - let extractResults = this.extractor.extract(query, referenceDate); - for (let result of extractResults) { - let parseResult = this.parser.parse(result, referenceDate); - if (Array.isArray(parseResult.value)) { - parseDates.push(...parseResult.value); - } - else { - parseDates.push(parseResult); - } - } - } - catch (err) { - // Nothing to do. Exceptions in parse should not break users of recognizers. - // No result. - } - finally { - return parseDates - .map(o => ({ - start: o.start, - end: o.start + o.length - 1, - resolution: o.value, // TODO: convert to proper resolution - text: o.text, - typeName: o.type - })); - } - } -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-date-time/src/dateTime/parsers.ts b/JavaScript/packages/recognizers-date-time/src/dateTime/parsers.ts deleted file mode 100644 index 0bee24a4c2..0000000000 --- a/JavaScript/packages/recognizers-date-time/src/dateTime/parsers.ts +++ /dev/null @@ -1,93 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { IParser, ParseResult, ExtractResult, RegExpUtility, Match, StringUtility } from "@microsoft/recognizers-text"; -import { BaseNumberParser, BaseNumberExtractor } from "@microsoft/recognizers-text-number"; -import { IDateTimeUtilityConfiguration, DateTimeFormatUtil, DateTimeResolutionResult, DateUtils, DayOfWeek, MatchingUtil, AgoLaterUtil } from "./utilities"; -import { BaseDateTime } from "../resources/baseDateTime"; -import { Constants, TimeTypeConstants } from "./constants"; -import { BaseDateExtractor, BaseDateParser } from "./baseDate"; -import { BaseTimeExtractor, BaseTimeParser } from "./baseTime"; -import { BaseDatePeriodExtractor, BaseDatePeriodParser } from "./baseDatePeriod"; -import { BaseTimePeriodExtractor, BaseTimePeriodParser } from "./baseTimePeriod"; -import { IDateTimeExtractor, BaseDateTimeExtractor, BaseDateTimeParser } from "./baseDateTime"; -import { BaseDateTimePeriodExtractor, BaseDateTimePeriodParser } from "./baseDateTimePeriod"; -import { BaseSetExtractor, BaseSetParser } from "./baseSet"; -import { BaseDurationExtractor, BaseDurationParser } from "./baseDuration"; -import { BaseHolidayExtractor, BaseHolidayParser } from "./baseHoliday"; - -export class DateTimeParseResult extends ParseResult { - // TimexStr is only used in extractors related with date and time - // It will output the TIMEX representation of a time string. - timexStr: string -} - -export interface IDateTimeParser extends IParser { - parse(extResult: ExtractResult, referenceDate?: Date): DateTimeParseResult | null; -} - -export interface ICommonDateTimeParserConfiguration { - cardinalExtractor: BaseNumberExtractor; - integerExtractor: BaseNumberExtractor; - ordinalExtractor: BaseNumberExtractor; - numberParser: BaseNumberParser; - dateExtractor: IDateTimeExtractor; - timeExtractor: IDateTimeExtractor; - dateTimeExtractor: IDateTimeExtractor; - durationExtractor: IDateTimeExtractor; - datePeriodExtractor: IDateTimeExtractor; - timePeriodExtractor: IDateTimeExtractor; - dateTimePeriodExtractor: IDateTimeExtractor; - dateParser: BaseDateParser; - timeParser: BaseTimeParser; - dateTimeParser: BaseDateTimeParser; - durationParser: BaseDurationParser; - datePeriodParser: BaseDatePeriodParser; - timePeriodParser: BaseTimePeriodParser; - dateTimePeriodParser: BaseDateTimePeriodParser; - monthOfYear: ReadonlyMap; - numbers: ReadonlyMap; - unitValueMap: ReadonlyMap; - seasonMap: ReadonlyMap; - unitMap: ReadonlyMap; - cardinalMap: ReadonlyMap; - dayOfMonth: ReadonlyMap; - dayOfWeek: ReadonlyMap; - doubleNumbers: ReadonlyMap; - utilityConfiguration: IDateTimeUtilityConfiguration; -} - -export abstract class BaseDateParserConfiguration implements ICommonDateTimeParserConfiguration { - cardinalExtractor: BaseNumberExtractor; - integerExtractor: BaseNumberExtractor; - ordinalExtractor: BaseNumberExtractor; - numberParser: BaseNumberParser; - dateExtractor: IDateTimeExtractor; - timeExtractor: IDateTimeExtractor; - dateTimeExtractor: IDateTimeExtractor; - durationExtractor: IDateTimeExtractor; - datePeriodExtractor: IDateTimeExtractor; - timePeriodExtractor: IDateTimeExtractor; - dateTimePeriodExtractor: IDateTimeExtractor; - dateParser: BaseDateParser; - timeParser: BaseTimeParser; - dateTimeParser: BaseDateTimeParser; - durationParser: BaseDurationParser; - datePeriodParser: BaseDatePeriodParser; - timePeriodParser: BaseTimePeriodParser; - dateTimePeriodParser: BaseDateTimePeriodParser; - monthOfYear: ReadonlyMap; - numbers: ReadonlyMap; - unitValueMap: ReadonlyMap; - seasonMap: ReadonlyMap; - unitMap: ReadonlyMap; - cardinalMap: ReadonlyMap; - dayOfMonth: ReadonlyMap; - dayOfWeek: ReadonlyMap; - doubleNumbers: ReadonlyMap; - utilityConfiguration: IDateTimeUtilityConfiguration; - - constructor() { - this.dayOfMonth = BaseDateTime.DayOfMonthDictionary; - } -} diff --git a/JavaScript/packages/recognizers-date-time/src/dateTime/spanish/baseConfiguration.ts b/JavaScript/packages/recognizers-date-time/src/dateTime/spanish/baseConfiguration.ts deleted file mode 100644 index 298dbe06bc..0000000000 --- a/JavaScript/packages/recognizers-date-time/src/dateTime/spanish/baseConfiguration.ts +++ /dev/null @@ -1,80 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { RegExpUtility } from "@microsoft/recognizers-text"; -import { SpanishCardinalExtractor, SpanishIntegerExtractor, SpanishOrdinalExtractor, BaseNumberParser, SpanishNumberParserConfiguration } from "@microsoft/recognizers-text-number"; -import { IDateTimeUtilityConfiguration } from "../utilities"; -import { SpanishDateTime } from "../../resources/spanishDateTime"; -import { BaseDateParserConfiguration } from "../parsers"; -import { BaseDateTime } from "../../resources/baseDateTime"; -import { BaseDateExtractor, BaseDateParser } from "../baseDate"; -import { BaseTimeExtractor, BaseTimeParser } from "../baseTime"; -import { BaseDateTimeExtractor, BaseDateTimeParser } from "../baseDateTime"; -import { BaseDurationExtractor, BaseDurationParser } from "../baseDuration"; -import { BaseDatePeriodExtractor, BaseDatePeriodParser } from "../baseDatePeriod"; -import { BaseTimePeriodExtractor, BaseTimePeriodParser } from "../baseTimePeriod"; -import { BaseDateTimePeriodExtractor, BaseDateTimePeriodParser } from "../baseDateTimePeriod"; -import { SpanishDateExtractorConfiguration, SpanishDateParserConfiguration } from "./dateConfiguration"; -import { SpanishDateTimeExtractorConfiguration, SpanishDateTimeParserConfiguration } from "./dateTimeConfiguration"; -import { SpanishDurationExtractorConfiguration, SpanishDurationParserConfiguration } from "./durationConfiguration"; -import { SpanishDatePeriodExtractorConfiguration, SpanishDatePeriodParserConfiguration } from "./datePeriodConfiguration"; -import { SpanishTimeExtractorConfiguration, SpanishTimeParserConfiguration } from "./timeConfiguration"; -import { SpanishTimePeriodExtractorConfiguration, SpanishTimePeriodParserConfiguration } from "./timePeriodConfiguration"; -import { SpanishDateTimePeriodExtractorConfiguration, SpanishDateTimePeriodParserConfiguration } from "./dateTimePeriodConfiguration"; - -export class SpanishDateTimeUtilityConfiguration implements IDateTimeUtilityConfiguration { - readonly agoRegex: RegExp; - readonly laterRegex: RegExp; - readonly inConnectorRegex: RegExp; - readonly rangeUnitRegex: RegExp; - readonly amDescRegex: RegExp; - readonly pmDescRegex: RegExp; - readonly amPmDescRegex: RegExp; - - constructor() { - this.laterRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.LaterRegex); - this.agoRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.AgoRegex); - this.inConnectorRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.InConnectorRegex); - this.rangeUnitRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.RangeUnitRegex); - this.amDescRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.AmDescRegex); - this.pmDescRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.PmDescRegex); - this.amPmDescRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.AmPmDescRegex); - } -} - -export class SpanishCommonDateTimeParserConfiguration extends BaseDateParserConfiguration { - - constructor(dmyDateFormat: boolean) { - super(); - this.utilityConfiguration = new SpanishDateTimeUtilityConfiguration(); - - this.unitMap = SpanishDateTime.UnitMap; - this.unitValueMap = SpanishDateTime.UnitValueMap; - this.seasonMap = SpanishDateTime.SeasonMap; - this.cardinalMap = SpanishDateTime.CardinalMap; - this.dayOfWeek = SpanishDateTime.DayOfWeek; - this.monthOfYear = SpanishDateTime.MonthOfYear; - this.numbers = SpanishDateTime.Numbers; - this.doubleNumbers = SpanishDateTime.DoubleNumbers; - - this.cardinalExtractor = new SpanishCardinalExtractor(); - this.integerExtractor = new SpanishIntegerExtractor(); - this.ordinalExtractor = new SpanishOrdinalExtractor(); - - this.numberParser = new BaseNumberParser(new SpanishNumberParserConfiguration()); - this.dateExtractor = new BaseDateExtractor(new SpanishDateExtractorConfiguration(dmyDateFormat)); - this.timeExtractor = new BaseTimeExtractor(new SpanishTimeExtractorConfiguration()); - this.dateTimeExtractor = new BaseDateTimeExtractor(new SpanishDateTimeExtractorConfiguration(dmyDateFormat)); - this.durationExtractor = new BaseDurationExtractor(new SpanishDurationExtractorConfiguration()); - this.datePeriodExtractor = new BaseDatePeriodExtractor(new SpanishDatePeriodExtractorConfiguration(dmyDateFormat)); - this.timePeriodExtractor = new BaseTimePeriodExtractor(new SpanishTimePeriodExtractorConfiguration()); - this.dateTimePeriodExtractor = new BaseDateTimePeriodExtractor(new SpanishDateTimePeriodExtractorConfiguration(dmyDateFormat)); - this.durationParser = new BaseDurationParser(new SpanishDurationParserConfiguration(this)); - this.dateParser = new BaseDateParser(new SpanishDateParserConfiguration(this, dmyDateFormat)); - this.timeParser = new BaseTimeParser(new SpanishTimeParserConfiguration(this)); - this.dateTimeParser = new BaseDateTimeParser(new SpanishDateTimeParserConfiguration(this)); - this.datePeriodParser = new BaseDatePeriodParser(new SpanishDatePeriodParserConfiguration(this)); - this.timePeriodParser = new BaseTimePeriodParser(new SpanishTimePeriodParserConfiguration(this)); - this.dateTimePeriodParser = new BaseDateTimePeriodParser(new SpanishDateTimePeriodParserConfiguration(this)); - } -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-date-time/src/dateTime/spanish/dateConfiguration.ts b/JavaScript/packages/recognizers-date-time/src/dateTime/spanish/dateConfiguration.ts deleted file mode 100644 index 534110f6e0..0000000000 --- a/JavaScript/packages/recognizers-date-time/src/dateTime/spanish/dateConfiguration.ts +++ /dev/null @@ -1,227 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { RegExpUtility } from "@microsoft/recognizers-text"; -import { BaseNumberExtractor, BaseNumberParser, SpanishOrdinalExtractor, SpanishIntegerExtractor, SpanishNumberParserConfiguration } from "@microsoft/recognizers-text-number"; -import { SpanishDateTime } from "../../resources/spanishDateTime"; -import { IDateExtractorConfiguration, IDateParserConfiguration } from "../baseDate"; -import { BaseDurationExtractor, BaseDurationParser } from "../baseDuration"; -import { IDateTimeUtilityConfiguration } from "../utilities"; -import { SpanishDateTimeUtilityConfiguration, SpanishCommonDateTimeParserConfiguration } from "./baseConfiguration"; -import { SpanishDurationExtractorConfiguration } from "./durationConfiguration"; -import { IDateTimeExtractor } from "../baseDateTime"; -import { Constants } from "../constants"; - -export class SpanishDateExtractorConfiguration implements IDateExtractorConfiguration { - readonly dateRegexList: RegExp[]; - readonly implicitDateList: RegExp[]; - readonly monthEnd: RegExp; - readonly ofMonth: RegExp; - readonly dateUnitRegex: RegExp; - readonly forTheRegex: RegExp; - readonly weekDayAndDayOfMonthRegex: RegExp; - readonly relativeMonthRegex: RegExp; - readonly strictRelativeRegex: RegExp; - readonly weekDayRegex: RegExp; - readonly dayOfWeek: ReadonlyMap; - readonly ordinalExtractor: BaseNumberExtractor; - readonly integerExtractor: BaseNumberExtractor; - readonly numberParser: BaseNumberParser; - readonly durationExtractor: IDateTimeExtractor; - readonly utilityConfiguration: IDateTimeUtilityConfiguration; - readonly rangeConnectorSymbolRegex : RegExp; - - constructor(dmyDateFormat: boolean) { - - let enableDmy = dmyDateFormat || SpanishDateTime.DefaultLanguageFallback === Constants.DefaultLanguageFallback_DMY; - - this.dateRegexList = [ - RegExpUtility.getSafeRegExp(SpanishDateTime.DateExtractor1, "gis"), - RegExpUtility.getSafeRegExp(SpanishDateTime.DateExtractor2, "gis"), - RegExpUtility.getSafeRegExp(SpanishDateTime.DateExtractor3, "gis"), - - enableDmy ? - RegExpUtility.getSafeRegExp(SpanishDateTime.DateExtractor5, "gis") : - RegExpUtility.getSafeRegExp(SpanishDateTime.DateExtractor4, "gis"), - - enableDmy ? - RegExpUtility.getSafeRegExp(SpanishDateTime.DateExtractor4, "gis") : - RegExpUtility.getSafeRegExp(SpanishDateTime.DateExtractor5, "gis"), - - enableDmy ? - RegExpUtility.getSafeRegExp(SpanishDateTime.DateExtractor8, "gis") : - RegExpUtility.getSafeRegExp(SpanishDateTime.DateExtractor6, "gis"), - - enableDmy ? - RegExpUtility.getSafeRegExp(SpanishDateTime.DateExtractor6, "gis") : - RegExpUtility.getSafeRegExp(SpanishDateTime.DateExtractor8, "gis"), - - enableDmy ? - RegExpUtility.getSafeRegExp(SpanishDateTime.DateExtractor9, "gis") : - RegExpUtility.getSafeRegExp(SpanishDateTime.DateExtractor7, "gis"), - - enableDmy ? - RegExpUtility.getSafeRegExp(SpanishDateTime.DateExtractor7, "gis") : - RegExpUtility.getSafeRegExp(SpanishDateTime.DateExtractor9, "gis"), - - RegExpUtility.getSafeRegExp(SpanishDateTime.DateExtractor10, "gis"), - ]; - this.implicitDateList = [ - RegExpUtility.getSafeRegExp(SpanishDateTime.OnRegex, "gis"), - RegExpUtility.getSafeRegExp(SpanishDateTime.RelaxedOnRegex, "gis"), - RegExpUtility.getSafeRegExp(SpanishDateTime.SpecialDayRegex, "gis"), - RegExpUtility.getSafeRegExp(SpanishDateTime.ThisRegex, "gis"), - RegExpUtility.getSafeRegExp(SpanishDateTime.LastDateRegex, "gis"), - RegExpUtility.getSafeRegExp(SpanishDateTime.NextDateRegex, "gis"), - RegExpUtility.getSafeRegExp(SpanishDateTime.WeekDayRegex, "gis"), - RegExpUtility.getSafeRegExp(SpanishDateTime.WeekDayOfMonthRegex, "gis"), - RegExpUtility.getSafeRegExp(SpanishDateTime.SpecialDateRegex, "gis") - ]; - - this.monthEnd = RegExpUtility.getSafeRegExp(SpanishDateTime.MonthEndRegex, "gis"); - this.ofMonth = RegExpUtility.getSafeRegExp(SpanishDateTime.OfMonthRegex, "gis"); - this.dateUnitRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.DateUnitRegex, "gis"); - this.forTheRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.ForTheRegex, "gis"); - this.weekDayAndDayOfMonthRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.WeekDayAndDayOfMonthRegex, "gis"); - this.relativeMonthRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.RelativeMonthRegex, "gis"); - this.strictRelativeRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.StrictRelativeRegex, "gis"); - this.weekDayRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.WeekDayRegex, "gis"); - this.dayOfWeek = SpanishDateTime.DayOfWeek; - this.ordinalExtractor = new SpanishOrdinalExtractor(); - this.integerExtractor = new SpanishIntegerExtractor(); - this.numberParser = new BaseNumberParser(new SpanishNumberParserConfiguration()); - this.durationExtractor = new BaseDurationExtractor(new SpanishDurationExtractorConfiguration()); - this.utilityConfiguration = new SpanishDateTimeUtilityConfiguration(); - this.rangeConnectorSymbolRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.RangeConnectorRegex); - } -} - -export class SpanishDateParserConfiguration implements IDateParserConfiguration { - readonly ordinalExtractor: BaseNumberExtractor; - readonly integerExtractor: BaseNumberExtractor; - readonly cardinalExtractor: BaseNumberExtractor; - readonly durationExtractor: IDateTimeExtractor; - readonly durationParser: BaseDurationParser; - readonly numberParser: BaseNumberParser; - readonly monthOfYear: ReadonlyMap; - readonly dayOfMonth: ReadonlyMap; - readonly dayOfWeek: ReadonlyMap; - readonly unitMap: ReadonlyMap; - readonly cardinalMap: ReadonlyMap; - readonly dateRegex: RegExp[]; - readonly onRegex: RegExp; - readonly specialDayRegex: RegExp; - readonly specialDayWithNumRegex: RegExp; - readonly nextRegex: RegExp; - readonly unitRegex: RegExp; - readonly monthRegex: RegExp; - readonly weekDayRegex: RegExp; - readonly lastRegex: RegExp; - readonly thisRegex: RegExp; - readonly weekDayOfMonthRegex: RegExp; - readonly forTheRegex: RegExp; - readonly weekDayAndDayOfMonthRegex: RegExp; - readonly relativeMonthRegex: RegExp; - readonly strictRelativeRegex: RegExp; - readonly relativeWeekDayRegex: RegExp; - readonly utilityConfiguration: IDateTimeUtilityConfiguration; - readonly dateTokenPrefix: string; - - // TODO: implement the relative day regex if needed. If yes, they should be abstracted - static readonly relativeDayRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.RelativeDayRegex); - static readonly nextPrefixRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.NextPrefixRegex); - static readonly previousPrefixRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.PreviousPrefixRegex); - - constructor(config: SpanishCommonDateTimeParserConfiguration, dmyDateFormat: boolean) { - this.ordinalExtractor = config.ordinalExtractor; - this.integerExtractor = config.integerExtractor; - this.cardinalExtractor = config.cardinalExtractor; - this.durationExtractor = config.durationExtractor; - this.numberParser = config.numberParser; - this.durationParser = config.durationParser; - this.monthOfYear = config.monthOfYear; - this.dayOfMonth = config.dayOfMonth; - this.dayOfWeek = config.dayOfWeek; - this.unitMap = config.unitMap; - this.cardinalMap = config.cardinalMap; - this.dateRegex = new SpanishDateExtractorConfiguration(dmyDateFormat).dateRegexList; - this.onRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.OnRegex, "gis"); - this.specialDayRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.SpecialDayRegex, "gis"); - this.specialDayWithNumRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.SpecialDayWithNumRegex, "gis"); - this.nextRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.NextDateRegex, "gis"); - this.unitRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.DateUnitRegex, "gis"); - this.monthRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.MonthRegex, "gis"); - this.weekDayRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.WeekDayRegex, "gis"); - this.lastRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.LastDateRegex, "gis"); - this.thisRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.ThisRegex, "gis"); - this.weekDayOfMonthRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.WeekDayOfMonthRegex, "gis"); - this.forTheRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.ForTheRegex, "gis"); - this.weekDayAndDayOfMonthRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.WeekDayAndDayOfMonthRegex, "gis"); - this.relativeMonthRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.RelativeMonthRegex, "gis"); - this.strictRelativeRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.StrictRelativeRegex, "gis"); - this.relativeWeekDayRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.RelativeWeekDayRegex, "gis"); - this.utilityConfiguration = config.utilityConfiguration; - this.dateTokenPrefix = SpanishDateTime.DateTokenPrefix; - } - - getSwiftDay(source: string): number { - - let trimedText = SpanishDateParserConfiguration.normalize(source.trim().toLowerCase()); - let swift = 0; - - // TODO: add the relative day logic if needed. If yes, the whole method should be abstracted. - if (trimedText === "hoy" || trimedText === "el dia") { - swift = 0; - } - else if (trimedText === "mañana" || - trimedText.endsWith("dia siguiente") || - trimedText.endsWith("el dia de mañana") || - trimedText.endsWith("proximo dia")) { - swift = 1; - } - else if (trimedText === "ayer") { - swift = -1; - } - else if (trimedText.endsWith("pasado mañana") || - trimedText.endsWith("dia despues de mañana")) { - swift = 2; - } - else if (trimedText.endsWith("anteayer") || - trimedText.endsWith("dia antes de ayer")) { - swift = -2; - } - else if (trimedText.endsWith("ultimo dia")) { - swift = -1; - } - - return swift; - } - - getSwiftMonthOrYear(source: string): number { - let trimedText = source.trim().toLowerCase(); - let swift = 0; - if (RegExpUtility.getMatches(SpanishDateParserConfiguration.nextPrefixRegex, trimedText).length) { - swift = 1; - } - - if (RegExpUtility.getMatches(SpanishDateParserConfiguration.previousPrefixRegex, trimedText).length) { - swift = -1; - } - - return swift; - } - - isCardinalLast(source: string): boolean { - let trimedText = source.trim().toLowerCase(); - return RegExpUtility.getMatches(SpanishDateParserConfiguration.previousPrefixRegex, trimedText).length > 0; - } - - private static normalize(source: string): string { - return source - .replace(/á/g, "a") - .replace(/é/g, "e") - .replace(/í/g, "i") - .replace(/ó/g, "o") - .replace(/ú/g, "u"); - } -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-date-time/src/dateTime/spanish/datePeriodConfiguration.ts b/JavaScript/packages/recognizers-date-time/src/dateTime/spanish/datePeriodConfiguration.ts deleted file mode 100644 index 4c6978f6db..0000000000 --- a/JavaScript/packages/recognizers-date-time/src/dateTime/spanish/datePeriodConfiguration.ts +++ /dev/null @@ -1,268 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { IExtractor, IParser, RegExpUtility } from "@microsoft/recognizers-text"; -import { BaseNumberParser, BaseNumberExtractor, SpanishIntegerExtractor, SpanishNumberParserConfiguration } from "@microsoft/recognizers-text-number"; -import { IDatePeriodExtractorConfiguration, IDatePeriodParserConfiguration } from "../baseDatePeriod"; -import { BaseDateExtractor, BaseDateParser } from "../baseDate"; -import { BaseDurationExtractor, BaseDurationParser } from "../baseDuration"; -import { SpanishDateExtractorConfiguration } from "./dateConfiguration"; -import { SpanishDurationExtractorConfiguration } from "./durationConfiguration"; -import { BaseDateTime } from "../../resources/baseDateTime"; -import { SpanishDateTime } from "../../resources/spanishDateTime"; -import { ICommonDateTimeParserConfiguration } from "../parsers"; -import { IDateTimeExtractor } from "../baseDateTime"; - -export class SpanishDatePeriodExtractorConfiguration implements IDatePeriodExtractorConfiguration { - readonly simpleCasesRegexes: RegExp[]; - readonly illegalYearRegex: RegExp; - readonly YearRegex: RegExp; - readonly tillRegex: RegExp; - readonly followedUnit: RegExp; - readonly numberCombinedWithUnit: RegExp; - readonly pastRegex: RegExp; - readonly futureRegex: RegExp; - readonly weekOfRegex: RegExp; - readonly monthOfRegex: RegExp; - readonly dateUnitRegex: RegExp; - readonly inConnectorRegex: RegExp; - readonly rangeUnitRegex: RegExp; - readonly datePointExtractor: IDateTimeExtractor; - readonly integerExtractor: BaseNumberExtractor; - readonly numberParser: BaseNumberParser; - readonly durationExtractor: IDateTimeExtractor; - - readonly fromRegex: RegExp; - readonly RangeConnectorRegex: RegExp; - readonly betweenRegex: RegExp; - readonly nowRegex: RegExp - - constructor(dmyDateFormat: boolean) { - this.simpleCasesRegexes = [ - RegExpUtility.getSafeRegExp(SpanishDateTime.SimpleCasesRegex), - RegExpUtility.getSafeRegExp(SpanishDateTime.DayBetweenRegex), - RegExpUtility.getSafeRegExp(SpanishDateTime.SimpleCasesRegex), - RegExpUtility.getSafeRegExp(SpanishDateTime.DayBetweenRegex), - RegExpUtility.getSafeRegExp(SpanishDateTime.OneWordPeriodRegex), - RegExpUtility.getSafeRegExp(SpanishDateTime.MonthWithYearRegex), - RegExpUtility.getSafeRegExp(SpanishDateTime.MonthNumWithYearRegex), - RegExpUtility.getSafeRegExp(SpanishDateTime.YearRegex), - RegExpUtility.getSafeRegExp(SpanishDateTime.WeekOfMonthRegex), - RegExpUtility.getSafeRegExp(SpanishDateTime.WeekOfYearRegex), - RegExpUtility.getSafeRegExp(SpanishDateTime.MonthFrontBetweenRegex), - RegExpUtility.getSafeRegExp(SpanishDateTime.MonthFrontSimpleCasesRegex), - RegExpUtility.getSafeRegExp(SpanishDateTime.QuarterRegex), - RegExpUtility.getSafeRegExp(SpanishDateTime.QuarterRegexYearFront), - RegExpUtility.getSafeRegExp(SpanishDateTime.AllHalfYearRegex), - RegExpUtility.getSafeRegExp(SpanishDateTime.SeasonRegex), - RegExpUtility.getSafeRegExp(SpanishDateTime.RestOfDateRegex), - RegExpUtility.getSafeRegExp(SpanishDateTime.LaterEarlyPeriodRegex), - RegExpUtility.getSafeRegExp(SpanishDateTime.WeekWithWeekDayRangeRegex) - ]; - this.illegalYearRegex = RegExpUtility.getSafeRegExp(BaseDateTime.IllegalYearRegex); - this.YearRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.YearRegex); - this.tillRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.TillRegex); - this.followedUnit = RegExpUtility.getSafeRegExp(SpanishDateTime.FollowedDateUnit); - this.numberCombinedWithUnit = RegExpUtility.getSafeRegExp(SpanishDateTime.NumberCombinedWithDateUnit); - this.pastRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.PastRegex); - this.futureRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.FutureRegex); - this.weekOfRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.WeekOfRegex); - this.monthOfRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.MonthOfRegex); - this.dateUnitRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.DateUnitRegex); - this.inConnectorRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.InConnectorRegex); - this.rangeUnitRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.RangeUnitRegex); - - this.fromRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.FromRegex); - this.RangeConnectorRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.RangeConnectorRegex); - this.betweenRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.BetweenRegex); - this.nowRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.NowRegex); - - this.datePointExtractor = new BaseDateExtractor(new SpanishDateExtractorConfiguration(dmyDateFormat)); - this.integerExtractor = new SpanishIntegerExtractor(); - this.numberParser = new BaseNumberParser(new SpanishNumberParserConfiguration()); - this.durationExtractor = new BaseDurationExtractor(new SpanishDurationExtractorConfiguration()); - } - - getFromTokenIndex(source: string): { matched: boolean; index: number; } { - return RegExpUtility.getFirstMatchIndex(this.fromRegex, source); - } - - getBetweenTokenIndex(source: string): { matched: boolean; index: number; } { - return RegExpUtility.getFirstMatchIndex(this.betweenRegex, source); - } - - hasConnectorToken(source: string): boolean { - return RegExpUtility.getFirstMatchIndex(this.RangeConnectorRegex, source).matched; - } -} - -export class SpanishDatePeriodParserConfiguration implements IDatePeriodParserConfiguration { - readonly dateExtractor: IDateTimeExtractor; - readonly dateParser: BaseDateParser; - readonly durationExtractor: IDateTimeExtractor; - readonly durationParser: BaseDurationParser; - readonly monthFrontBetweenRegex: RegExp; - readonly betweenRegex: RegExp; - readonly monthFrontSimpleCasesRegex: RegExp; - readonly simpleCasesRegex: RegExp; - readonly oneWordPeriodRegex: RegExp; - readonly monthWithYear: RegExp; - readonly monthNumWithYear: RegExp; - readonly yearRegex: RegExp; - readonly pastRegex: RegExp; - readonly relativeRegex: RegExp; - readonly futureRegex: RegExp; - readonly inConnectorRegex: RegExp; - readonly weekOfMonthRegex: RegExp; - readonly weekOfYearRegex: RegExp; - readonly quarterRegex: RegExp; - readonly quarterRegexYearFront: RegExp; - readonly allHalfYearRegex: RegExp; - readonly seasonRegex: RegExp; - readonly weekOfRegex: RegExp; - readonly monthOfRegex: RegExp; - readonly whichWeekRegex: RegExp; - readonly restOfDateRegex: RegExp; - readonly laterEarlyPeriodRegex: RegExp; - readonly weekWithWeekDayRangeRegex: RegExp; - readonly unspecificEndOfRangeRegex: RegExp; - readonly tokenBeforeDate: string; - readonly dayOfMonth: ReadonlyMap; - readonly monthOfYear: ReadonlyMap; - readonly cardinalMap: ReadonlyMap; - readonly seasonMap: ReadonlyMap; - readonly unitMap: ReadonlyMap; - - readonly nextPrefixRegex: RegExp; - readonly previousPrefixRegex: RegExp; - readonly thisPrefixRegex: RegExp; - readonly numberCombinedWithUnit: RegExp; - - readonly cardinalExtractor: IExtractor; - readonly integerExtractor: BaseNumberExtractor; - readonly numberParser: BaseNumberParser; - readonly nowRegex: RegExp - - constructor(config: ICommonDateTimeParserConfiguration) { - this.tokenBeforeDate = SpanishDateTime.TokenBeforeDate; - this.cardinalExtractor = config.cardinalExtractor; - this.integerExtractor = config.integerExtractor; - this.numberParser = config.numberParser; - this.durationExtractor = config.durationExtractor; - this.dateExtractor = config.dateExtractor; - this.durationParser = config.durationParser; - this.dateParser = config.dateParser; - - this.monthFrontBetweenRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.MonthFrontBetweenRegex); - this.betweenRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.DayBetweenRegex); - this.monthFrontSimpleCasesRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.MonthFrontSimpleCasesRegex); - this.simpleCasesRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.SimpleCasesRegex); - this.oneWordPeriodRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.OneWordPeriodRegex); - this.monthWithYear = RegExpUtility.getSafeRegExp(SpanishDateTime.MonthWithYearRegex); - this.monthNumWithYear = RegExpUtility.getSafeRegExp(SpanishDateTime.MonthNumWithYearRegex); - this.yearRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.YearRegex); - this.relativeRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.RelativeRegex); - this.pastRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.PastRegex); - this.futureRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.FutureRegex); - this.numberCombinedWithUnit = RegExpUtility.getSafeRegExp(SpanishDateTime.DurationNumberCombinedWithUnit); - this.weekOfMonthRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.WeekOfMonthRegex); - this.weekOfYearRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.WeekOfYearRegex); - this.quarterRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.QuarterRegex); - this.quarterRegexYearFront = RegExpUtility.getSafeRegExp(SpanishDateTime.QuarterRegexYearFront); - this.allHalfYearRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.AllHalfYearRegex); - this.seasonRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.SeasonRegex); - this.whichWeekRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.WhichWeekRegex); - this.weekOfRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.WeekOfRegex); - this.monthOfRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.MonthOfRegex); - this.restOfDateRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.RestOfDateRegex); - this.laterEarlyPeriodRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.LaterEarlyPeriodRegex); - this.weekWithWeekDayRangeRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.WeekWithWeekDayRangeRegex); - this.unspecificEndOfRangeRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.UnspecificEndOfRangeRegex); - - this.nextPrefixRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.NextPrefixRegex); - this.previousPrefixRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.PreviousPrefixRegex); - this.thisPrefixRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.ThisPrefixRegex); - this.nowRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.NowRegex); - - this.inConnectorRegex = config.utilityConfiguration.inConnectorRegex; - this.unitMap = config.unitMap; - this.cardinalMap = config.cardinalMap; - this.dayOfMonth = config.dayOfMonth; - this.monthOfYear = config.monthOfYear; - this.seasonMap = config.seasonMap; - } - - getSwiftDayOrMonth(source: string): number { - let trimedText = source.trim().toLowerCase(); - let swift = 0; - - if (RegExpUtility.getFirstMatchIndex(this.nextPrefixRegex, trimedText).matched) { - swift = 1; - } - - if (RegExpUtility.getFirstMatchIndex(this.previousPrefixRegex, trimedText).matched) { - swift = -1; - } - - return swift; - } - - getSwiftYear(source: string): number { - let trimedText = source.trim().toLowerCase(); - let swift = -10; - if (RegExpUtility.getFirstMatchIndex(this.nextPrefixRegex, trimedText).matched) { - swift = 1; - } - - if (RegExpUtility.getFirstMatchIndex(this.previousPrefixRegex, trimedText).matched) { - swift = -1; - } - else if (RegExpUtility.getFirstMatchIndex(this.thisPrefixRegex, trimedText).matched) { - swift = 0; - } - - return swift; - } - - isFuture(source: string): boolean { - let trimedText = source.trim().toLowerCase(); - return RegExpUtility.getFirstMatchIndex(this.thisPrefixRegex, trimedText).matched || - RegExpUtility.getFirstMatchIndex(this.nextPrefixRegex, trimedText).matched; - } - - isYearToDate(source: string): boolean { - let trimedText = source.trim().toLowerCase(); - return SpanishDateTime.YearToDateTerms.some(o => trimedText === o); - } - - isMonthToDate(source: string): boolean { - let trimedText = source.trim().toLowerCase(); - return SpanishDateTime.MonthToDateTerms.some(o => trimedText === o); - } - - isWeekOnly(source: string): boolean { - let trimedText = source.trim().toLowerCase(); - return SpanishDateTime.WeekTerms.some(o => trimedText.endsWith(o)) && - !SpanishDateTime.WeekendTerms.some(o => trimedText.endsWith(o)); - } - - isWeekend(source: string): boolean { - let trimedText = source.trim().toLowerCase(); - return SpanishDateTime.WeekendTerms.some(o => trimedText.endsWith(o)); - } - - isMonthOnly(source: string): boolean { - let trimedText = source.trim().toLowerCase(); - return SpanishDateTime.MonthTerms.some(o => trimedText.endsWith(o)); - } - - isYearOnly(source: string): boolean { - let trimedText = source.trim().toLowerCase(); - return SpanishDateTime.YearTerms.some(o => trimedText.endsWith(o)); - } - - isLastCardinal(source: string): boolean { - let trimedText = source.trim().toLowerCase(); - return RegExpUtility.getFirstMatchIndex(this.previousPrefixRegex, trimedText).matched; - } -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-date-time/src/dateTime/spanish/dateTimeConfiguration.ts b/JavaScript/packages/recognizers-date-time/src/dateTime/spanish/dateTimeConfiguration.ts deleted file mode 100644 index a9a7d141ff..0000000000 --- a/JavaScript/packages/recognizers-date-time/src/dateTime/spanish/dateTimeConfiguration.ts +++ /dev/null @@ -1,189 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { RegExpUtility } from "@microsoft/recognizers-text"; -import { IDateTimeExtractorConfiguration, IDateTimeParserConfiguration, IDateTimeExtractor } from "../baseDateTime"; -import { BaseNumberExtractor, BaseNumberParser } from "@microsoft/recognizers-text-number"; -import { BaseDateExtractor, BaseDateParser } from "../baseDate"; -import { BaseTimeExtractor, BaseTimeParser } from "../baseTime"; -import { BaseDurationExtractor, BaseDurationParser } from "../baseDuration"; -import { IDateTimeUtilityConfiguration } from "../utilities"; -import { SpanishDateExtractorConfiguration } from "./dateConfiguration"; -import { SpanishDurationExtractorConfiguration } from "./durationConfiguration"; -import { SpanishDateTimeUtilityConfiguration } from "./baseConfiguration"; -import { SpanishDateTime } from "../../resources/spanishDateTime"; -import { ICommonDateTimeParserConfiguration } from "../parsers"; -import { SpanishTimeExtractorConfiguration } from "./timeConfiguration"; - -export class SpanishDateTimeExtractorConfiguration implements IDateTimeExtractorConfiguration { - readonly datePointExtractor: IDateTimeExtractor; - readonly timePointExtractor: IDateTimeExtractor; - readonly durationExtractor: IDateTimeExtractor; - readonly suffixRegex: RegExp; - readonly nowRegex: RegExp; - readonly timeOfTodayAfterRegex: RegExp; - readonly timeOfDayRegex: RegExp; - readonly specificTimeOfDayRegex: RegExp; - readonly simpleTimeOfTodayAfterRegex: RegExp; - readonly nightRegex: RegExp; - readonly timeOfTodayBeforeRegex: RegExp; - readonly simpleTimeOfTodayBeforeRegex: RegExp; - readonly specificEndOfRegex: RegExp; - readonly unspecificEndOfRegex: RegExp; - readonly unitRegex: RegExp; - readonly utilityConfiguration: IDateTimeUtilityConfiguration; - readonly prepositionRegex: RegExp; - readonly connectorRegex: RegExp; - - - constructor(dmyDateFormat: boolean) { - this.prepositionRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.PrepositionRegex, "gis"); - this.nowRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.NowRegex, "gis"); - this.suffixRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.SuffixRegex, "gis"); - - this.timeOfDayRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.TimeOfDayRegex, "gis"); - this.specificTimeOfDayRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.SpecificTimeOfDayRegex, "gis"); - this.timeOfTodayAfterRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.TimeOfTodayAfterRegex, "gis"); - this.timeOfTodayBeforeRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.TimeOfTodayBeforeRegex, "gis"); - this.simpleTimeOfTodayAfterRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.SimpleTimeOfTodayAfterRegex, "gis"); - this.simpleTimeOfTodayBeforeRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.SimpleTimeOfTodayBeforeRegex, "gis"); - this.specificEndOfRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.SpecificEndOfRegex, "gis"); - this.unspecificEndOfRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.UnspecificEndOfRegex, "gis"); - this.unitRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.UnitRegex, "gis"); - this.connectorRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.ConnectorRegex, "gis"); - this.nightRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.NightRegex, "gis"); - - this.datePointExtractor = new BaseDateExtractor(new SpanishDateExtractorConfiguration(dmyDateFormat)); - this.timePointExtractor = new BaseTimeExtractor(new SpanishTimeExtractorConfiguration()); - this.durationExtractor = new BaseDurationExtractor(new SpanishDurationExtractorConfiguration()); - this.utilityConfiguration = new SpanishDateTimeUtilityConfiguration(); - } - - isConnectorToken(source: string): boolean { - let trimmed = source.trim(); - return trimmed === "" - || RegExpUtility.getFirstMatchIndex(this.prepositionRegex, source).matched - || RegExpUtility.getFirstMatchIndex(this.connectorRegex, source).matched; - } -} - -export class SpanishDateTimeParserConfiguration implements IDateTimeParserConfiguration { - readonly tokenBeforeDate: string; - readonly tokenBeforeTime: string; - readonly dateExtractor: IDateTimeExtractor; - readonly timeExtractor: IDateTimeExtractor; - readonly dateParser: BaseDateParser; - readonly timeParser: BaseTimeParser; - readonly cardinalExtractor: BaseNumberExtractor; - readonly numberParser: BaseNumberParser; - readonly durationExtractor: IDateTimeExtractor; - readonly durationParser: BaseDurationParser; - readonly nowRegex: RegExp; - readonly amTimeRegex: RegExp; - readonly pmTimeRegex: RegExp; - readonly simpleTimeOfTodayAfterRegex: RegExp; - readonly simpleTimeOfTodayBeforeRegex: RegExp; - readonly specificTimeOfDayRegex: RegExp; - readonly specificEndOfRegex: RegExp; - readonly unspecificEndOfRegex: RegExp; - readonly unitRegex: RegExp; - readonly unitMap: ReadonlyMap; - readonly numbers: ReadonlyMap; - readonly utilityConfiguration: IDateTimeUtilityConfiguration; - - readonly nextPrefixRegex: RegExp; - readonly previousPrefixRegex: RegExp; - readonly lastNightTimeRegex: RegExp; - - constructor(config: ICommonDateTimeParserConfiguration) { - this.tokenBeforeDate = SpanishDateTime.TokenBeforeDate; - this.tokenBeforeTime = SpanishDateTime.TokenBeforeTime; - this.nowRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.NowRegex, "gis"); - this.amTimeRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.AmTimeRegex, "gis"); - this.pmTimeRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.PmTimeRegex, "gis"); - this.simpleTimeOfTodayAfterRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.SimpleTimeOfTodayAfterRegex, "gis"); - this.simpleTimeOfTodayBeforeRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.SimpleTimeOfTodayBeforeRegex, "gis"); - this.specificTimeOfDayRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.SpecificTimeOfDayRegex, "gis"); - this.specificEndOfRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.SpecificEndOfRegex, "gis"); - this.unspecificEndOfRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.UnspecificEndOfRegex, "gis"); - this.unitRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.UnitRegex, "gis"); - - this.nextPrefixRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.NextPrefixRegex, "gis"); - this.previousPrefixRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.PreviousPrefixRegex, "gis"); - this.lastNightTimeRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.LastNightTimeRegex, "gis"); - - this.dateExtractor = config.dateExtractor; - this.timeExtractor = config.timeExtractor; - this.dateParser = config.dateParser; - this.timeParser = config.timeParser; - this.numbers = config.numbers; - this.cardinalExtractor = config.cardinalExtractor; - this.numberParser = config.numberParser; - this.durationExtractor = config.durationExtractor; - this.durationParser = config.durationParser; - this.unitMap = config.unitMap; - this.utilityConfiguration = config.utilityConfiguration; - } - - haveAmbiguousToken(text: string, matchedText: string): boolean { - return text.toLowerCase().includes("esta mañana") - && matchedText.toLocaleLowerCase().includes("mañana"); - } - - getMatchedNowTimex(text: string): { matched: boolean; timex: string; } { - let trimedText = text.trim().toLowerCase(); - let timex = ""; - if (trimedText.endsWith("ahora") || trimedText.endsWith("mismo") || trimedText.endsWith("momento")) { - timex = "PRESENT_REF"; - } - else if (trimedText.endsWith("posible") || trimedText.endsWith("pueda") || - trimedText.endsWith("puedas") || trimedText.endsWith("podamos") || trimedText.endsWith("puedan")) { - timex = "FUTURE_REF"; - } - else if (trimedText.endsWith("mente")) { - timex = "PAST_REF"; - } - else { - return { - matched: false, - timex: null - }; - } - - return { - matched: true, - timex: timex - }; - } - - getSwiftDay(text: string): number { - let trimedText = text.trim().toLowerCase(); - let swift = 0; - - if (RegExpUtility.getFirstMatchIndex(this.previousPrefixRegex, trimedText).matched || - RegExpUtility.getFirstMatchIndex(this.lastNightTimeRegex, trimedText).matched) { - swift = -1; - } - else if (RegExpUtility.getFirstMatchIndex(this.nextPrefixRegex, trimedText).matched) { - swift = 1; - } - - return swift; - - } - - getHour(text: string, hour: number): number { - let trimedText = text.trim().toLowerCase(); - let result = hour; - - // TODO: Replace with a regex - if ((trimedText.endsWith("mañana") || trimedText.endsWith("madrugada")) && hour >= 12) { - result -= 12; - } - else if (!(trimedText.endsWith("mañana") || trimedText.endsWith("madrugada")) && hour < 12) { - result += 12; - } - - return result; - } -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-date-time/src/dateTime/spanish/dateTimePeriodConfiguration.ts b/JavaScript/packages/recognizers-date-time/src/dateTime/spanish/dateTimePeriodConfiguration.ts deleted file mode 100644 index 14ffea866c..0000000000 --- a/JavaScript/packages/recognizers-date-time/src/dateTime/spanish/dateTimePeriodConfiguration.ts +++ /dev/null @@ -1,231 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { IExtractor, IParser, RegExpUtility } from "@microsoft/recognizers-text"; -import { BaseNumberExtractor, SpanishCardinalExtractor } from "@microsoft/recognizers-text-number"; -import { IDateTimePeriodExtractorConfiguration, IDateTimePeriodParserConfiguration, BaseDateTimePeriodParser } from "../baseDateTimePeriod"; -import { BaseDateExtractor, BaseDateParser } from "../baseDate"; -import { BaseTimeExtractor, BaseTimeParser } from "../baseTime"; -import { BaseDateTimeExtractor, BaseDateTimeParser, IDateTimeExtractor } from "../baseDateTime"; -import { BaseDurationExtractor, BaseDurationParser } from "../baseDuration"; -import { IDateTimeParser, ICommonDateTimeParserConfiguration } from "../parsers"; -import { SpanishDateExtractorConfiguration } from "./dateConfiguration"; -import { SpanishDateTimeExtractorConfiguration } from "./dateTimeConfiguration"; -import { SpanishDurationExtractorConfiguration } from "./durationConfiguration"; -import { SpanishDateTime } from "../../resources/spanishDateTime"; -import { SpanishTimeExtractorConfiguration } from "./timeConfiguration"; -import { DateTimeResolutionResult, DateUtils, DateTimeFormatUtil } from "../utilities"; -import { BaseTimePeriodExtractor } from "../baseTimePeriod"; -import { SpanishTimePeriodExtractorConfiguration } from "./timePeriodConfiguration"; - -export class SpanishDateTimePeriodExtractorConfiguration implements IDateTimePeriodExtractorConfiguration { - readonly cardinalExtractor: BaseNumberExtractor; - readonly singleDateExtractor: IDateTimeExtractor; - readonly singleTimeExtractor: IDateTimeExtractor; - readonly singleDateTimeExtractor: IDateTimeExtractor; - readonly durationExtractor: IDateTimeExtractor; - readonly timePeriodExtractor: IDateTimeExtractor; - readonly simpleCasesRegexes: RegExp[]; - readonly prepositionRegex: RegExp; - readonly tillRegex: RegExp; - readonly specificTimeOfDayRegex: RegExp; - readonly timeOfDayRegex: RegExp; - readonly periodTimeOfDayWithDateRegex: RegExp; - readonly followedUnit: RegExp; - readonly numberCombinedWithUnit: RegExp; - readonly timeUnitRegex: RegExp; - readonly previousPrefixRegex: RegExp; - readonly nextPrefixRegex: RegExp; - readonly relativeTimeUnitRegex: RegExp; - readonly restOfDateTimeRegex: RegExp; - readonly weekDayRegex: RegExp; - readonly generalEndingRegex: RegExp; - readonly middlePauseRegex: RegExp; - - readonly fromRegex: RegExp; - readonly RangeConnectorRegex: RegExp; - readonly betweenRegex: RegExp; - - - constructor(dmyDateFormat: boolean) { - this.simpleCasesRegexes = [ - RegExpUtility.getSafeRegExp(SpanishDateTime.PureNumFromTo), - RegExpUtility.getSafeRegExp(SpanishDateTime.PureNumBetweenAnd) - ]; - - this.prepositionRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.PrepositionRegex); - this.tillRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.TillRegex); - this.specificTimeOfDayRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.SpecificTimeOfDayRegex); - this.timeOfDayRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.TimeOfDayRegex); - this.followedUnit = RegExpUtility.getSafeRegExp(SpanishDateTime.FollowedUnit); - this.timeUnitRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.UnitRegex); - this.previousPrefixRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.PastRegex); - this.nextPrefixRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.FutureRegex); - this.numberCombinedWithUnit = RegExpUtility.getSafeRegExp(SpanishDateTime.DateTimePeriodNumberCombinedWithUnit); - this.weekDayRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.WeekDayRegex); - this.periodTimeOfDayWithDateRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.PeriodTimeOfDayWithDateRegex); - this.relativeTimeUnitRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.RelativeTimeUnitRegex); - this.restOfDateTimeRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.RestOfDateTimeRegex); - this.generalEndingRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.GeneralEndingRegex); - this.middlePauseRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.MiddlePauseRegex); - - this.fromRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.FromRegex); - this.RangeConnectorRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.RangeConnectorRegex); - this.betweenRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.BetweenRegex); - - this.cardinalExtractor = new SpanishCardinalExtractor(); - - this.singleDateExtractor = new BaseDateExtractor(new SpanishDateExtractorConfiguration(dmyDateFormat)); - this.singleTimeExtractor = new BaseTimeExtractor(new SpanishTimeExtractorConfiguration()); - this.singleDateTimeExtractor = new BaseDateTimeExtractor(new SpanishDateTimeExtractorConfiguration(dmyDateFormat)); - this.durationExtractor = new BaseDurationExtractor(new SpanishDurationExtractorConfiguration()); - this.timePeriodExtractor = new BaseTimePeriodExtractor(new SpanishTimePeriodExtractorConfiguration()); - } - - getFromTokenIndex(source: string): { matched: boolean; index: number; } { - return RegExpUtility.getFirstMatchIndex(this.fromRegex, source); - } - - getBetweenTokenIndex(source: string): { matched: boolean; index: number; } { - return RegExpUtility.getFirstMatchIndex(this.betweenRegex, source); - } - - hasConnectorToken(source: string): boolean { - return RegExpUtility.getFirstMatchIndex(this.RangeConnectorRegex, source).matched; - } -} - -export class SpanishDateTimePeriodParserConfiguration implements IDateTimePeriodParserConfiguration { - readonly pureNumberFromToRegex: RegExp; - readonly pureNumberBetweenAndRegex: RegExp; - readonly periodTimeOfDayWithDateRegex: RegExp; - readonly specificTimeOfDayRegex: RegExp; - readonly pastRegex: RegExp; - readonly futureRegex: RegExp; - readonly relativeTimeUnitRegex: RegExp; - readonly restOfDateTimeRegex: RegExp; - readonly timeOfDayRegex: RegExp; - readonly numberCombinedWithUnitRegex: RegExp; - readonly unitRegex: RegExp; - - readonly nextPrefixRegex: RegExp; - readonly previousPrefixRegex: RegExp; - readonly thisPrefixRegex: RegExp; - - readonly numbers: ReadonlyMap; - readonly unitMap: ReadonlyMap; - readonly dateExtractor: IDateTimeExtractor; - readonly timeExtractor: IDateTimeExtractor; - readonly dateTimeExtractor: IDateTimeExtractor; - readonly timePeriodExtractor: IDateTimeExtractor; - readonly durationExtractor: IDateTimeExtractor; - readonly dateParser: BaseDateParser; - readonly timeParser: BaseTimeParser; - readonly dateTimeParser: BaseDateTimeParser; - readonly timePeriodParser: IDateTimeParser; - readonly durationParser: BaseDurationParser; - readonly cardinalExtractor: IExtractor; - readonly numberParser: IParser; - - constructor(config: ICommonDateTimeParserConfiguration) { - this.dateExtractor = config.dateExtractor; - this.timeExtractor = config.timeExtractor; - this.dateTimeExtractor = config.dateTimeExtractor; - this.timePeriodExtractor = config.timePeriodExtractor; - this.cardinalExtractor = config.cardinalExtractor; - this.durationExtractor = config.durationExtractor; - this.numberParser = config.numberParser; - this.dateParser = config.dateParser; - this.timeParser = config.timeParser; - this.dateTimeParser = config.dateTimeParser; - this.timePeriodParser = config.timePeriodParser; - this.durationParser = config.durationParser; - this.unitMap = config.unitMap; - this.numbers = config.numbers; - - this.nextPrefixRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.NextPrefixRegex); - this.previousPrefixRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.PreviousPrefixRegex); - this.thisPrefixRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.ThisPrefixRegex); - - this.pureNumberFromToRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.PureNumFromTo); - this.pureNumberBetweenAndRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.PureNumBetweenAnd); - this.specificTimeOfDayRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.SpecificTimeOfDayRegex); - this.timeOfDayRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.TimeOfDayRegex); - this.pastRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.PastRegex); - this.futureRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.FutureRegex); - this.numberCombinedWithUnitRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.DateTimePeriodNumberCombinedWithUnit); - this.unitRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.UnitRegex); - this.periodTimeOfDayWithDateRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.PeriodTimeOfDayWithDateRegex); - this.relativeTimeUnitRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.RelativeTimeUnitRegex); - this.restOfDateTimeRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.RestOfDateTimeRegex); - } - - getMatchedTimeRange(source: string): { timeStr: string; beginHour: number; endHour: number; endMin: number; success: boolean; } { - let trimedText = source.trim().toLowerCase(); - let timeStr = ""; - let beginHour = 0; - let endHour = 0; - let endMin = 0; - - if (trimedText.endsWith("madrugada")) { - timeStr = "TDA"; - beginHour = 4; - endHour = 8; - } - else if (trimedText.endsWith("mañana")) { - timeStr = "TMO"; - beginHour = 8; - endHour = 12; - } - else if (trimedText.includes("pasado mediodia") || trimedText.includes("pasado el mediodia")) { - timeStr = "TAF"; - beginHour = 12; - endHour = 16; - } - else if (trimedText.endsWith("tarde")) { - timeStr = "TEV"; - beginHour = 16; - endHour = 20; - } - else if (trimedText.endsWith("noche")) { - timeStr = "TNI"; - beginHour = 20; - endHour = 23; - endMin = 59; - } - else { - timeStr = null; - return { - success: false, - timeStr, - beginHour, - endHour, - endMin - }; - } - - return { - success: true, - timeStr, - beginHour, - endHour, - endMin - }; - } - - getSwiftPrefix(source: string): number { - let trimedText = source.trim().toLowerCase(); - let swift = 0; - - // TODO: Replace with a regex - if (RegExpUtility.getFirstMatchIndex(this.previousPrefixRegex, trimedText).matched || - trimedText === "anoche") { - swift = -1; - } - else if (RegExpUtility.getFirstMatchIndex(this.nextPrefixRegex, trimedText).matched) { - swift = 1; - } - - return swift; - } -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-date-time/src/dateTime/spanish/dateTimePeriodParser.ts b/JavaScript/packages/recognizers-date-time/src/dateTime/spanish/dateTimePeriodParser.ts deleted file mode 100644 index 6eea3a5be8..0000000000 --- a/JavaScript/packages/recognizers-date-time/src/dateTime/spanish/dateTimePeriodParser.ts +++ /dev/null @@ -1,89 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { RegExpUtility } from "@microsoft/recognizers-text"; -import { BaseDateTimePeriodParser, IDateTimePeriodParserConfiguration } from "../baseDateTimePeriod"; -import { DateTimeResolutionResult, DateUtils, DateTimeFormatUtil } from "../utilities"; -import { SpanishDateTime } from "../../resources/spanishDateTime"; - -export class SpanishDateTimePeriodParser extends BaseDateTimePeriodParser { - constructor(config: IDateTimePeriodParserConfiguration) { - super(config); - } - - protected parseSpecificTimeOfDay(source: string, referenceDate: Date): DateTimeResolutionResult { - - let ret = new DateTimeResolutionResult(); - let trimedText = source.trim().toLowerCase(); - - // handle morning, afternoon.. - let match = this.config.getMatchedTimeRange(trimedText); - let beginHour = match.beginHour; - let endHour = match.endHour; - let endMin = match.endMin; - let timeStr = match.timeStr; - if (!match.success) { - return ret; - } - - let matches = RegExpUtility.getMatches(this.config.specificTimeOfDayRegex, trimedText); - if (matches.length && matches[0].index === 0 && matches[0].length === trimedText.length) { - let swift = this.config.getSwiftPrefix(trimedText); - - let date = DateUtils.addDays(referenceDate, swift); - date.setHours(0, 0, 0, 0); - let day = date.getDate(); - let month = date.getMonth(); - let year = date.getFullYear();; - - ret.timex = DateTimeFormatUtil.formatDate(date) + timeStr; - - ret.pastValue = ret.futureValue = [ - DateUtils.safeCreateFromValue(DateUtils.minValue(), year, month, day, beginHour, 0, 0), - DateUtils.safeCreateFromValue(DateUtils.minValue(), year, month, day, endHour, endMin, endMin), - ]; - - ret.success = true; - return ret; - } - - let startIndex = trimedText.indexOf(SpanishDateTime.Tomorrow) === 0 ? SpanishDateTime.Tomorrow.length : 0; - - // handle Date followed by morning, afternoon - // Add handling code to handle morning, afternoon followed by Date - // Add handling code to handle early/late morning, afternoon - // TODO: use regex from config: match = this.config.TimeOfDayRegex.Match(trimedText.Substring(startIndex)); - matches = RegExpUtility.getMatches(RegExpUtility.getSafeRegExp(SpanishDateTime.TimeOfDayRegex), trimedText.substring(startIndex)); - if (matches.length) { - let match = matches[0]; - let beforeStr = trimedText.substring(0, match.index + startIndex).trim(); - let ers = this.config.dateExtractor.extract(beforeStr, referenceDate); - if (ers.length === 0) { - return ret; - } - - let pr = this.config.dateParser.parse(ers[0], referenceDate); - - let futureDate = (pr.value as DateTimeResolutionResult).futureValue; - let pastDate = (pr.value as DateTimeResolutionResult).pastValue; - - ret.timex = pr.timexStr + timeStr; - - ret.futureValue = [ - DateUtils.safeCreateFromValue(DateUtils.minValue(), futureDate.getFullYear(), futureDate.getMonth(), futureDate.getDate(), beginHour, 0, 0), - DateUtils.safeCreateFromValue(DateUtils.minValue(), futureDate.getFullYear(), futureDate.getMonth(), futureDate.getDate(), endHour, endMin, endMin) - ]; - - ret.pastValue = [ - DateUtils.safeCreateFromValue(DateUtils.minValue(), pastDate.getFullYear(), pastDate.getMonth(), pastDate.getDate(), beginHour, 0, 0), - DateUtils.safeCreateFromValue(DateUtils.minValue(), pastDate.getFullYear(), pastDate.getMonth(), pastDate.getDate(), endHour, endMin, endMin) - ]; - - ret.success = true; - - return ret; - } - - return ret; - } -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-date-time/src/dateTime/spanish/durationConfiguration.ts b/JavaScript/packages/recognizers-date-time/src/dateTime/spanish/durationConfiguration.ts deleted file mode 100644 index 4c0f5006be..0000000000 --- a/JavaScript/packages/recognizers-date-time/src/dateTime/spanish/durationConfiguration.ts +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { RegExpUtility } from "@microsoft/recognizers-text"; -import { BaseNumberExtractor, BaseNumberParser, SpanishCardinalExtractor } from "@microsoft/recognizers-text-number"; -import { IDurationExtractorConfiguration, IDurationParserConfiguration } from "../baseDuration"; -import { SpanishDateTime } from "../../resources/spanishDateTime"; -import { ICommonDateTimeParserConfiguration } from "../parsers"; - -export class SpanishDurationExtractorConfiguration implements IDurationExtractorConfiguration { - readonly allRegex: RegExp; - readonly halfRegex: RegExp; - readonly followedUnit: RegExp; - readonly numberCombinedWithUnit: RegExp; - readonly anUnitRegex: RegExp; - readonly inexactNumberUnitRegex: RegExp; - readonly suffixAndRegex: RegExp; - readonly relativeDurationUnitRegex: RegExp; - readonly moreThanRegex: RegExp; - readonly lessThanRegex: RegExp; - readonly cardinalExtractor: BaseNumberExtractor; - - constructor() { - this.allRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.AllRegex, "gis"); - this.halfRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.HalfRegex, "gis"); - this.followedUnit = RegExpUtility.getSafeRegExp(SpanishDateTime.FollowedUnit, "gis"); - this.numberCombinedWithUnit = RegExpUtility.getSafeRegExp(SpanishDateTime.DurationNumberCombinedWithUnit, "gis"); - this.anUnitRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.AnUnitRegex, "gis"); - this.inexactNumberUnitRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.InexactNumberUnitRegex, "gis"); - this.suffixAndRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.SuffixAndRegex, "gis"); - this.relativeDurationUnitRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.RelativeDurationUnitRegex, "gis"); - this.moreThanRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.MoreThanRegex, "gis"); - this.lessThanRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.LessThanOneHour, "gis"); - this.cardinalExtractor = new SpanishCardinalExtractor(); - } -} - -export class SpanishDurationParserConfiguration implements IDurationParserConfiguration { - readonly cardinalExtractor: BaseNumberExtractor; - readonly numberParser: BaseNumberParser; - readonly followedUnit: RegExp; - readonly suffixAndRegex: RegExp; - readonly numberCombinedWithUnit: RegExp; - readonly anUnitRegex: RegExp; - readonly allDateUnitRegex: RegExp; - readonly halfDateUnitRegex: RegExp; - readonly inexactNumberUnitRegex: RegExp; - readonly unitMap: ReadonlyMap; - readonly unitValueMap: ReadonlyMap; - readonly doubleNumbers: ReadonlyMap; - - constructor(config: ICommonDateTimeParserConfiguration) { - this.cardinalExtractor = config.cardinalExtractor; - this.numberParser = config.numberParser; - this.followedUnit = RegExpUtility.getSafeRegExp(SpanishDateTime.FollowedUnit); - this.suffixAndRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.SuffixAndRegex); - this.numberCombinedWithUnit = RegExpUtility.getSafeRegExp(SpanishDateTime.DurationNumberCombinedWithUnit); - this.anUnitRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.AnUnitRegex); - this.allDateUnitRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.AllRegex); - this.halfDateUnitRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.HalfRegex); - this.inexactNumberUnitRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.InexactNumberUnitRegex); - this.unitMap = config.unitMap; - this.unitValueMap = config.unitValueMap; - this.doubleNumbers = config.doubleNumbers; - } -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-date-time/src/dateTime/spanish/holidayConfiguration.ts b/JavaScript/packages/recognizers-date-time/src/dateTime/spanish/holidayConfiguration.ts deleted file mode 100644 index fe84cd5de6..0000000000 --- a/JavaScript/packages/recognizers-date-time/src/dateTime/spanish/holidayConfiguration.ts +++ /dev/null @@ -1,123 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { IHolidayExtractorConfiguration, BaseHolidayParserConfiguration } from "../baseHoliday"; -import { RegExpUtility } from "@microsoft/recognizers-text"; -import { DateUtils, HolidayFunctions } from "../utilities"; -import { SpanishDateTime } from "../../resources/spanishDateTime"; - -export class SpanishHolidayExtractorConfiguration implements IHolidayExtractorConfiguration { - readonly holidayRegexes: RegExp[]; - - constructor() { - this.holidayRegexes = [ - RegExpUtility.getSafeRegExp(SpanishDateTime.HolidayRegex1, "gis"), - RegExpUtility.getSafeRegExp(SpanishDateTime.HolidayRegex2, "gis"), - RegExpUtility.getSafeRegExp(SpanishDateTime.HolidayRegex3, "gis") - ]; - } -} - -export class SpanishHolidayParserConfiguration extends BaseHolidayParserConfiguration { - - readonly nextPrefixRegex: RegExp; - readonly previousPrefixRegex: RegExp; - readonly thisPrefixRegex: RegExp; - - constructor() { - super(); - - this.holidayRegexList = [ - RegExpUtility.getSafeRegExp(SpanishDateTime.HolidayRegex1, "gis"), - RegExpUtility.getSafeRegExp(SpanishDateTime.HolidayRegex2, "gis"), - RegExpUtility.getSafeRegExp(SpanishDateTime.HolidayRegex3, "gis") - ]; - - this.holidayNames = SpanishDateTime.HolidayNames; - this.holidayFuncDictionary = this.initHolidayFuncs(); - this.variableHolidaysTimexDictionary = SpanishDateTime.VariableHolidaysTimexDictionary; - - this.nextPrefixRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.NextPrefixRegex); - this.previousPrefixRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.PreviousPrefixRegex); - this.thisPrefixRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.ThisPrefixRegex); - } - - protected initHolidayFuncs(): ReadonlyMap Date> { - return new Map Date>( - [ - ...super.initHolidayFuncs(), - ["padres", SpanishHolidayParserConfiguration.FathersDay], - ["madres", SpanishHolidayParserConfiguration.MothersDay], - ["acciondegracias", SpanishHolidayParserConfiguration.ThanksgivingDay], - ["trabajador", SpanishHolidayParserConfiguration.InternationalWorkersDay], - ["delaraza", SpanishHolidayParserConfiguration.ColumbusDay], - ["memoria", SpanishHolidayParserConfiguration.MemorialDay], - ["pascuas", SpanishHolidayParserConfiguration.EasterDay], - ["navidad", SpanishHolidayParserConfiguration.ChristmasDay], - ["nochebuena", SpanishHolidayParserConfiguration.ChristmasEve], - ["añonuevo", SpanishHolidayParserConfiguration.NewYear], - ["nochevieja", SpanishHolidayParserConfiguration.NewYearEve], - ["yuandan", SpanishHolidayParserConfiguration.NewYear], - ["maestro", SpanishHolidayParserConfiguration.TeacherDay], - ["todoslossantos", SpanishHolidayParserConfiguration.HalloweenDay], - ["niño", SpanishHolidayParserConfiguration.ChildrenDay], - ["mujer", SpanishHolidayParserConfiguration.FemaleDay] - ]); - } - - // All JavaScript dates are zero-based (-1) - private static NewYear(year: number): Date { - return new Date(year, 1 - 1, 1); - } - private static NewYearEve(year: number): Date { - return new Date(year, 12 - 1, 31); - } - private static ChristmasDay(year: number): Date { - return new Date(year, 12 - 1, 25); - } - private static ChristmasEve(year: number): Date { - return new Date(year, 12 - 1, 24); - } - private static FemaleDay(year: number): Date { - return new Date(year, 3 - 1, 8); - } - private static ChildrenDay(year: number): Date { - return new Date(year, 6 - 1, 1); - } - private static HalloweenDay(year: number): Date { - return new Date(year, 10 - 1, 31); - } - private static TeacherDay(year: number): Date { - return new Date(year, 9 - 1, 11); - } - private static EasterDay(year: number): Date { - return HolidayFunctions.calculateHolidayByEaster(year); - } - - getSwiftYear(text: string): number { - let trimedText = text.trim().toLowerCase(); - let swift = -10; - - if (RegExpUtility.getFirstMatchIndex(this.nextPrefixRegex, trimedText).matched) { - swift = 1; - } - - if (RegExpUtility.getFirstMatchIndex(this.previousPrefixRegex, trimedText).matched) { - swift = -1; - } - else if (RegExpUtility.getFirstMatchIndex(this.thisPrefixRegex, trimedText).matched) { - swift = 0; - } - - return swift; - } - - sanitizeHolidayToken(holiday: string): string { - return holiday.replace(/ /g, "") - .replace(/á/g, "a") - .replace(/é/g, "e") - .replace(/í/g, "i") - .replace(/ó/g, "o") - .replace(/ú/g, "u"); - } -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-date-time/src/dateTime/spanish/mergedConfiguration.ts b/JavaScript/packages/recognizers-date-time/src/dateTime/spanish/mergedConfiguration.ts deleted file mode 100644 index 5308562424..0000000000 --- a/JavaScript/packages/recognizers-date-time/src/dateTime/spanish/mergedConfiguration.ts +++ /dev/null @@ -1,108 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { RegExpUtility } from "@microsoft/recognizers-text"; -import { BaseNumberExtractor, SpanishIntegerExtractor } from "@microsoft/recognizers-text-number"; -import { IMergedExtractorConfiguration, IMergedParserConfiguration } from "../baseMerged"; -import { BaseDateExtractor, BaseDateParser } from "../baseDate"; -import { BaseTimeExtractor, BaseTimeParser } from "../baseTime"; -import { BaseDateTimeExtractor, BaseDateTimeParser, IDateTimeExtractor } from "../baseDateTime"; -import { BaseDatePeriodExtractor, BaseDatePeriodParser } from "../baseDatePeriod"; -import { BaseTimePeriodExtractor, BaseTimePeriodParser } from "../baseTimePeriod"; -import { BaseDateTimePeriodExtractor, BaseDateTimePeriodParser } from "../baseDateTimePeriod"; -import { BaseHolidayExtractor, BaseHolidayParser } from "../baseHoliday"; -import { BaseDurationExtractor, BaseDurationParser } from "../baseDuration"; -import { BaseSetExtractor, BaseSetParser } from "../baseSet"; -import { SpanishDateTime } from "../../resources/spanishDateTime"; -import { SpanishDateExtractorConfiguration } from "./dateConfiguration"; -import { SpanishDateTimeExtractorConfiguration } from "./dateTimeConfiguration"; -import { SpanishDatePeriodExtractorConfiguration, SpanishDatePeriodParserConfiguration } from "./datePeriodConfiguration"; -import { SpanishDurationExtractorConfiguration } from "./durationConfiguration"; -import { SpanishHolidayExtractorConfiguration, SpanishHolidayParserConfiguration } from "./holidayConfiguration"; -import { SpanishCommonDateTimeParserConfiguration } from "./baseConfiguration"; -import { SpanishTimeExtractorConfiguration } from "./timeConfiguration"; -import { SpanishTimePeriodExtractorConfiguration, SpanishTimePeriodParserConfiguration } from "./timePeriodConfiguration"; -import { SpanishDateTimePeriodExtractorConfiguration, SpanishDateTimePeriodParserConfiguration } from "./dateTimePeriodConfiguration"; -import { SpanishSetExtractorConfiguration, SpanishSetParserConfiguration } from "./setConfiguration"; -import { SpanishDateTimePeriodParser } from "./dateTimePeriodParser"; -import { DefinitionLoader } from "../utilities"; - -export class SpanishMergedExtractorConfiguration implements IMergedExtractorConfiguration { - readonly dateExtractor: IDateTimeExtractor; - readonly timeExtractor: IDateTimeExtractor; - readonly dateTimeExtractor: IDateTimeExtractor; - readonly datePeriodExtractor: IDateTimeExtractor; - readonly timePeriodExtractor: IDateTimeExtractor; - readonly dateTimePeriodExtractor: IDateTimeExtractor; - readonly holidayExtractor: IDateTimeExtractor; - readonly durationExtractor: IDateTimeExtractor; - readonly setExtractor: IDateTimeExtractor; - readonly integerExtractor: BaseNumberExtractor; - readonly afterRegex: RegExp; - readonly beforeRegex: RegExp; - readonly sinceRegex: RegExp; - readonly fromToRegex: RegExp; - readonly singleAmbiguousMonthRegex: RegExp; - readonly prepositionSuffixRegex: RegExp; - readonly ambiguousRangeModifierPrefix: RegExp; - readonly potentialAmbiguousRangeRegex: RegExp; - readonly numberEndingPattern: RegExp; - readonly unspecificDatePeriodRegex: RegExp; - readonly filterWordRegexList: RegExp[]; - readonly AmbiguityFiltersDict: Map - - constructor(dmyDateFormat: boolean = false) { - this.beforeRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.BeforeRegex); - this.afterRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.AfterRegex); - this.sinceRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.SinceRegex); - this.fromToRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.FromToRegex); - this.singleAmbiguousMonthRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.SingleAmbiguousMonthRegex); - this.prepositionSuffixRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.PrepositionSuffixRegex); - this.ambiguousRangeModifierPrefix = null; - this.potentialAmbiguousRangeRegex = null; - this.numberEndingPattern = RegExpUtility.getSafeRegExp(SpanishDateTime.NumberEndingPattern); - this.unspecificDatePeriodRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.UnspecificDatePeriodRegex); - - this.dateExtractor = new BaseDateExtractor(new SpanishDateExtractorConfiguration(dmyDateFormat)); - this.timeExtractor = new BaseTimeExtractor(new SpanishTimeExtractorConfiguration()); - this.dateTimeExtractor = new BaseDateTimeExtractor(new SpanishDateTimeExtractorConfiguration(dmyDateFormat)); - this.datePeriodExtractor = new BaseDatePeriodExtractor(new SpanishDatePeriodExtractorConfiguration(dmyDateFormat)); - this.timePeriodExtractor = new BaseTimePeriodExtractor(new SpanishTimePeriodExtractorConfiguration()); - this.dateTimePeriodExtractor = new BaseDateTimePeriodExtractor(new SpanishDateTimePeriodExtractorConfiguration(dmyDateFormat)); - this.durationExtractor = new BaseDurationExtractor(new SpanishDurationExtractorConfiguration()); - this.setExtractor = new BaseSetExtractor(new SpanishSetExtractorConfiguration(dmyDateFormat)); - this.holidayExtractor = new BaseHolidayExtractor(new SpanishHolidayExtractorConfiguration()); - this.integerExtractor = new SpanishIntegerExtractor(); - this.filterWordRegexList = []; - this.AmbiguityFiltersDict = DefinitionLoader.LoadAmbiguityFilters(SpanishDateTime.AmbiguityFiltersDict); - } -} - -export class SpanishMergedParserConfiguration extends SpanishCommonDateTimeParserConfiguration implements IMergedParserConfiguration { - readonly beforeRegex: RegExp; - readonly afterRegex: RegExp; - readonly sinceRegex: RegExp; - readonly dateParser: BaseDateParser; - readonly holidayParser: BaseHolidayParser; - readonly timeParser: BaseTimeParser; - readonly dateTimeParser: BaseDateTimeParser; - readonly datePeriodParser: BaseDatePeriodParser; - readonly timePeriodParser: BaseTimePeriodParser; - readonly dateTimePeriodParser: BaseDateTimePeriodParser; - readonly durationParser: BaseDurationParser; - readonly setParser: BaseSetParser; - - constructor(dmyDateFormat: boolean = false) { - super(dmyDateFormat); - - this.beforeRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.BeforeRegex); - this.afterRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.AfterRegex); - this.sinceRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.SinceRegex); - - this.datePeriodParser = new BaseDatePeriodParser(new SpanishDatePeriodParserConfiguration(this)); - this.timePeriodParser = new BaseTimePeriodParser(new SpanishTimePeriodParserConfiguration(this)); - this.dateTimePeriodParser = new SpanishDateTimePeriodParser(new SpanishDateTimePeriodParserConfiguration(this)); - this.setParser = new BaseSetParser(new SpanishSetParserConfiguration(this)); - this.holidayParser = new BaseHolidayParser(new SpanishHolidayParserConfiguration()); - } -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-date-time/src/dateTime/spanish/setConfiguration.ts b/JavaScript/packages/recognizers-date-time/src/dateTime/spanish/setConfiguration.ts deleted file mode 100644 index 30b59aa960..0000000000 --- a/JavaScript/packages/recognizers-date-time/src/dateTime/spanish/setConfiguration.ts +++ /dev/null @@ -1,171 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { RegExpUtility } from "@microsoft/recognizers-text"; -import { ISetExtractorConfiguration, ISetParserConfiguration } from "../baseSet"; -import { BaseDurationExtractor, BaseDurationParser } from "../baseDuration"; -import { BaseTimeExtractor, BaseTimeParser } from "../baseTime"; -import { BaseDateExtractor, BaseDateParser } from "../baseDate"; -import { BaseDateTimeExtractor, BaseDateTimeParser, IDateTimeExtractor } from "../baseDateTime"; -import { BaseDatePeriodExtractor, BaseDatePeriodParser } from "../baseDatePeriod"; -import { BaseTimePeriodExtractor, BaseTimePeriodParser } from "../baseTimePeriod"; -import { BaseDateTimePeriodExtractor, BaseDateTimePeriodParser } from "../baseDateTimePeriod"; -import { SpanishDateTime } from "../../resources/spanishDateTime"; -import { SpanishDurationExtractorConfiguration } from "./durationConfiguration"; -import { SpanishDateExtractorConfiguration } from "./dateConfiguration"; -import { SpanishDateTimeExtractorConfiguration } from "./dateTimeConfiguration"; -import { SpanishDatePeriodExtractorConfiguration } from "./datePeriodConfiguration"; -import { SpanishDateTimePeriodExtractorConfiguration } from "./dateTimePeriodConfiguration"; -import { ICommonDateTimeParserConfiguration } from "../parsers"; -import { SpanishTimeExtractorConfiguration } from "./timeConfiguration"; -import { SpanishTimePeriodExtractorConfiguration } from "./timePeriodConfiguration"; - -export class SpanishSetExtractorConfiguration implements ISetExtractorConfiguration { - readonly lastRegex: RegExp; - readonly eachPrefixRegex: RegExp; - readonly periodicRegex: RegExp; - readonly eachUnitRegex: RegExp; - readonly eachDayRegex: RegExp; - readonly beforeEachDayRegex: RegExp; - readonly setWeekDayRegex: RegExp; - readonly setEachRegex: RegExp; - readonly durationExtractor: IDateTimeExtractor; - readonly timeExtractor: IDateTimeExtractor; - readonly dateExtractor: IDateTimeExtractor; - readonly dateTimeExtractor: IDateTimeExtractor; - readonly datePeriodExtractor: IDateTimeExtractor; - readonly timePeriodExtractor: IDateTimeExtractor; - readonly dateTimePeriodExtractor: IDateTimeExtractor; - - constructor(dmyDateFormat: boolean) { - this.lastRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.LastDateRegex, "gis"); - this.periodicRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.PeriodicRegex, "gis"); - this.eachUnitRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.EachUnitRegex, "gis"); - this.eachPrefixRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.EachPrefixRegex, "gis"); - this.eachDayRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.EachDayRegex, "gis"); - this.beforeEachDayRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.BeforeEachDayRegex, "gis"); - this.setEachRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.SetEachRegex, "gis"); - this.setWeekDayRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.SetWeekDayRegex, "gis"); - - this.durationExtractor = new BaseDurationExtractor(new SpanishDurationExtractorConfiguration()); - this.timeExtractor = new BaseTimeExtractor(new SpanishTimeExtractorConfiguration()); - this.dateExtractor = new BaseDateExtractor(new SpanishDateExtractorConfiguration(dmyDateFormat)); - this.dateTimeExtractor = new BaseDateTimeExtractor(new SpanishDateTimeExtractorConfiguration(dmyDateFormat)); - this.datePeriodExtractor = new BaseDatePeriodExtractor(new SpanishDatePeriodExtractorConfiguration(dmyDateFormat)); - this.timePeriodExtractor = new BaseTimePeriodExtractor(new SpanishTimePeriodExtractorConfiguration()); - this.dateTimePeriodExtractor = new BaseDateTimePeriodExtractor(new SpanishDateTimePeriodExtractorConfiguration(dmyDateFormat)); - } -} - -export class SpanishSetParserConfiguration implements ISetParserConfiguration { - readonly durationExtractor: IDateTimeExtractor; - readonly durationParser: BaseDurationParser; - readonly timeExtractor: IDateTimeExtractor; - readonly timeParser: BaseTimeParser; - readonly dateExtractor: IDateTimeExtractor; - readonly dateParser: BaseDateParser; - readonly dateTimeExtractor: IDateTimeExtractor; - readonly dateTimeParser: BaseDateTimeParser; - readonly datePeriodExtractor: IDateTimeExtractor; - readonly datePeriodParser: BaseDatePeriodParser; - readonly timePeriodExtractor: IDateTimeExtractor; - readonly timePeriodParser: BaseTimePeriodParser; - readonly dateTimePeriodExtractor: IDateTimeExtractor; - readonly dateTimePeriodParser: BaseDateTimePeriodParser; - readonly unitMap: ReadonlyMap; - readonly eachPrefixRegex: RegExp; - readonly periodicRegex: RegExp; - readonly eachUnitRegex: RegExp; - readonly eachDayRegex: RegExp; - readonly setWeekDayRegex: RegExp; - readonly setEachRegex: RegExp; - - constructor(config: ICommonDateTimeParserConfiguration) { - this.durationExtractor = config.durationExtractor; - this.timeExtractor = config.timeExtractor; - this.dateExtractor = config.dateExtractor; - this.dateTimeExtractor = config.dateTimeExtractor; - this.datePeriodExtractor = config.datePeriodExtractor; - this.timePeriodExtractor = config.timePeriodExtractor; - this.dateTimePeriodExtractor = config.dateTimePeriodExtractor; - this.durationParser = config.durationParser; - this.timeParser = config.timeParser; - this.dateParser = config.dateParser; - this.dateTimeParser = config.dateTimeParser; - this.datePeriodParser = config.datePeriodParser; - this.timePeriodParser = config.timePeriodParser; - this.dateTimePeriodParser = config.dateTimePeriodParser; - this.unitMap = config.unitMap; - - this.eachPrefixRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.EachPrefixRegex, "gis"); - this.periodicRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.PeriodicRegex, "gis"); - this.eachUnitRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.EachUnitRegex, "gis"); - this.eachDayRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.EachDayRegex, "gis"); - this.setWeekDayRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.SetWeekDayRegex, "gis"); - this.setEachRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.SetEachRegex, "gis"); - } - - getMatchedDailyTimex(text: string): { matched: boolean; timex: string; } { - let trimedText = text.trim().toLowerCase(); - let timex = ""; - - if (trimedText.endsWith("diario") || trimedText.endsWith("diariamente")) { - timex = "P1D"; - } - else if (trimedText === "semanalmente") { - timex = "P1W"; - } - else if (trimedText === "quincenalmente") { - timex = "P2W"; - } - else if (trimedText === "mensualmente") { - timex = "P1M"; - } - else if (trimedText === "anualmente") { - timex = "P1Y"; - } - else { - timex = null; - return { - timex, - matched: false - }; - } - - return { - timex, - matched: true - }; - } - - getMatchedUnitTimex(text: string): { matched: boolean; timex: string; } { - let trimedText = text.trim().toLowerCase(); - let timex = ""; - - if (trimedText === "día" || trimedText === "dia" || - trimedText === "días" || trimedText === "dias") { - timex = "P1D"; - } - else if (trimedText === "semana" || trimedText === "semanas") { - timex = "P1W"; - } - else if (trimedText === "mes" || trimedText === "meses") { - timex = "P1M"; - } - else if (trimedText === "año" || trimedText === "años") { - timex = "P1Y"; - } - else { - timex = null; - return { - matched: false, - timex - }; - } - - return { - matched: true, - timex - }; - } -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-date-time/src/dateTime/spanish/timeConfiguration.ts b/JavaScript/packages/recognizers-date-time/src/dateTime/spanish/timeConfiguration.ts deleted file mode 100644 index 05987b6235..0000000000 --- a/JavaScript/packages/recognizers-date-time/src/dateTime/spanish/timeConfiguration.ts +++ /dev/null @@ -1,152 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { IExtractor } from "@microsoft/recognizers-text"; -import { RegExpUtility } from "@microsoft/recognizers-text"; -import { ITimeExtractorConfiguration, ITimeParserConfiguration } from "../baseTime"; -import { SpanishDateTime } from "../../resources/spanishDateTime"; -import { BaseDurationExtractor } from "../baseDuration"; -import { SpanishDurationExtractorConfiguration } from "./durationConfiguration"; -import { ICommonDateTimeParserConfiguration } from "../parsers"; -import { IDateTimeUtilityConfiguration } from "../utilities"; -import { IDateTimeExtractor } from "../baseDateTime"; - -export class SpanishTimeExtractorConfiguration implements ITimeExtractorConfiguration { - readonly timeRegexList: RegExp[]; - readonly atRegex: RegExp; - readonly ishRegex: RegExp; - - readonly durationExtractor: IDateTimeExtractor; - - constructor() { - this.atRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.AtRegex, "gis"); - this.ishRegex = null; - this.timeRegexList = SpanishTimeExtractorConfiguration.getTimeRegexList(); - - this.durationExtractor = new BaseDurationExtractor(new SpanishDurationExtractorConfiguration()); - } - - static getTimeRegexList(): RegExp[] { - return [ - RegExpUtility.getSafeRegExp(SpanishDateTime.TimeRegex1, "gis"), - RegExpUtility.getSafeRegExp(SpanishDateTime.TimeRegex2, "gis"), - RegExpUtility.getSafeRegExp(SpanishDateTime.TimeRegex3, "gis"), - RegExpUtility.getSafeRegExp(SpanishDateTime.TimeRegex4, "gis"), - RegExpUtility.getSafeRegExp(SpanishDateTime.TimeRegex5, "gis"), - RegExpUtility.getSafeRegExp(SpanishDateTime.TimeRegex6, "gis"), - RegExpUtility.getSafeRegExp(SpanishDateTime.TimeRegex7, "gis"), - RegExpUtility.getSafeRegExp(SpanishDateTime.TimeRegex8, "gis"), - RegExpUtility.getSafeRegExp(SpanishDateTime.TimeRegex9, "gis"), - RegExpUtility.getSafeRegExp(SpanishDateTime.TimeRegex11, "gis"), - RegExpUtility.getSafeRegExp(SpanishDateTime.TimeRegex12, "gis"), - RegExpUtility.getSafeRegExp(SpanishDateTime.ConnectNumRegex, "gis") - ]; - } -} - -export class SpanishTimeParserConfiguration implements ITimeParserConfiguration { - - readonly timeTokenPrefix: string; - readonly atRegex: RegExp; - readonly timeRegexes: RegExp[]; - readonly lessThanOneHour: RegExp; - readonly timeSuffix: RegExp; - readonly numbers: ReadonlyMap; - readonly utilityConfiguration: IDateTimeUtilityConfiguration; - - constructor(config: ICommonDateTimeParserConfiguration) { - - this.timeTokenPrefix = SpanishDateTime.TimeTokenPrefix; - this.atRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.AtRegex, "gis"); - this.timeRegexes = SpanishTimeExtractorConfiguration.getTimeRegexList(); - this.lessThanOneHour = RegExpUtility.getSafeRegExp(SpanishDateTime.LessThanOneHour, "gis"); - this.timeSuffix = RegExpUtility.getSafeRegExp(SpanishDateTime.TimeSuffix, "gis"); - - this.utilityConfiguration = config.utilityConfiguration; - this.numbers = config.numbers; - } - - adjustByPrefix(prefix: string, adjust: { hour: number; min: number; hasMin: boolean; }) { - let deltaMin = 0; - let trimedPrefix = prefix.trim().toLowerCase(); - - if (trimedPrefix.startsWith("cuarto") || trimedPrefix.startsWith("y cuarto")) { - deltaMin = 15; - } - else if (trimedPrefix.startsWith("menos cuarto")) { - deltaMin = -15; - } - else if (trimedPrefix.startsWith("media") || trimedPrefix.startsWith("y media")) { - deltaMin = 30; - } - else { - let matches = RegExpUtility.getMatches(this.lessThanOneHour, trimedPrefix); - if (matches.length) { - let match = matches[0]; - let minStr = match.groups("deltamin").value; - if (minStr) { - deltaMin = parseInt(minStr, 10); - } - else { - minStr = match.groups("deltaminnum").value.toLowerCase(); - if (this.numbers.has(minStr)) { - deltaMin = this.numbers.get(minStr); - } - } - } - } - - if (trimedPrefix.endsWith("pasadas") || trimedPrefix.endsWith("pasados") || - trimedPrefix.endsWith("pasadas las") || trimedPrefix.endsWith("pasados las") || - trimedPrefix.endsWith("pasadas de las") || trimedPrefix.endsWith("pasados de las")) { - // deltaMin it's positive - } - else if (trimedPrefix.endsWith("para la") || trimedPrefix.endsWith("para las") || - trimedPrefix.endsWith("antes de la") || trimedPrefix.endsWith("antes de las")) { - deltaMin = -deltaMin; - } - - adjust.min += deltaMin; - if (adjust.min < 0) { - adjust.min += 60; - adjust.hour -= 1; - } - - adjust.hasMin = adjust.hasMin || adjust.min !== 0; - } - - adjustBySuffix(suffix: string, adjust: { hour: number; min: number; hasMin: boolean; hasAm: boolean; hasPm: boolean; }) { - let trimedSuffix = suffix.trim().toLowerCase(); - this.adjustByPrefix(trimedSuffix, adjust); - - let deltaHour = 0; - let matches = RegExpUtility.getMatches(this.timeSuffix, trimedSuffix); - if (matches.length) { - let match = matches[0]; - if (match.index === 0 && match.length === trimedSuffix.length) { - let oclockStr = match.groups("oclock").value; - if (!oclockStr) { - let amStr = match.groups("am").value; - if (amStr) { - if (adjust.hour >= 12) { - deltaHour = -12; - } - - adjust.hasAm = true; - } - - let pmStr = match.groups("pm").value; - if (pmStr) { - if (adjust.hour < 12) { - deltaHour = 12; - } - - adjust.hasPm = true; - } - } - } - } - - adjust.hour = (adjust.hour + deltaHour) % 24; - } -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-date-time/src/dateTime/spanish/timePeriodConfiguration.ts b/JavaScript/packages/recognizers-date-time/src/dateTime/spanish/timePeriodConfiguration.ts deleted file mode 100644 index ed81719fb1..0000000000 --- a/JavaScript/packages/recognizers-date-time/src/dateTime/spanish/timePeriodConfiguration.ts +++ /dev/null @@ -1,138 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { RegExpUtility, IExtractor } from "@microsoft/recognizers-text"; -import { ITimePeriodExtractorConfiguration, ITimePeriodParserConfiguration } from "../baseTimePeriod"; -import { BaseTimeExtractor, BaseTimeParser } from "../baseTime"; -import { IDateTimeUtilityConfiguration, TimexUtil } from "../utilities"; -import { SpanishTimeExtractorConfiguration } from "./timeConfiguration"; -import { SpanishDateTimeUtilityConfiguration } from "./baseConfiguration"; -import { SpanishDateTime } from "../../resources/spanishDateTime"; -import { ICommonDateTimeParserConfiguration } from "../parsers"; -import { IDateTimeExtractor } from "../baseDateTime"; -import { EnglishIntegerExtractor, NumberMode } from "@microsoft/recognizers-text-number"; -import { Constants } from "../constants"; - -export class SpanishTimePeriodExtractorConfiguration implements ITimePeriodExtractorConfiguration { - readonly simpleCasesRegex: RegExp[]; - readonly tillRegex: RegExp; - readonly timeOfDayRegex: RegExp; - readonly generalEndingRegex: RegExp; - readonly singleTimeExtractor: IDateTimeExtractor; - readonly integerExtractor: IExtractor; - readonly utilityConfiguration: SpanishDateTimeUtilityConfiguration; - - readonly fromRegex: RegExp; - readonly RangeConnectorRegex: RegExp; - readonly betweenRegex: RegExp; - - constructor() { - this.singleTimeExtractor = new BaseTimeExtractor(new SpanishTimeExtractorConfiguration()); - this.integerExtractor = new EnglishIntegerExtractor(); - this.utilityConfiguration = new SpanishDateTimeUtilityConfiguration(); - - this.simpleCasesRegex = [ - RegExpUtility.getSafeRegExp(SpanishDateTime.PureNumFromTo, "gis"), - RegExpUtility.getSafeRegExp(SpanishDateTime.PureNumBetweenAnd, "gis") - ]; - - this.tillRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.TillRegex, "gis"); - this.timeOfDayRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.TimeOfDayRegex, "gis"); - this.generalEndingRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.GeneralEndingRegex, "gis"); - - this.fromRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.FromRegex, "gis"); - this.RangeConnectorRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.RangeConnectorRegex, "gis"); - this.betweenRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.BetweenRegex, "gis"); - } - - getFromTokenIndex(text: string): { matched: boolean; index: number; } { - return RegExpUtility.getFirstMatchIndex(this.fromRegex, text); - } - - hasConnectorToken(text: string): boolean { - return RegExpUtility.getFirstMatchIndex(this.RangeConnectorRegex, text).matched; - } - - getBetweenTokenIndex(text: string): { matched: boolean; index: number; } { - return RegExpUtility.getFirstMatchIndex(this.betweenRegex, text); - } -} - -export class SpanishTimePeriodParserConfiguration implements ITimePeriodParserConfiguration { - readonly timeExtractor: IDateTimeExtractor; - readonly timeParser: BaseTimeParser; - readonly integerExtractor: IExtractor; - readonly pureNumberFromToRegex: RegExp; - readonly pureNumberBetweenAndRegex: RegExp; - readonly timeOfDayRegex: RegExp; - readonly tillRegex: RegExp; - readonly numbers: ReadonlyMap; - readonly utilityConfiguration: IDateTimeUtilityConfiguration; - readonly specificTimeFromToRegex: RegExp; - readonly specificTimeBetweenAndRegex: RegExp; - - constructor(config: ICommonDateTimeParserConfiguration) { - this.timeExtractor = config.timeExtractor; - this.timeParser = config.timeParser; - this.integerExtractor = config.integerExtractor; - this.numbers = config.numbers; - this.utilityConfiguration = config.utilityConfiguration; - this.pureNumberFromToRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.PureNumFromTo, "gis"); - this.pureNumberBetweenAndRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.PureNumBetweenAnd, "gis"); - this.timeOfDayRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.TimeOfDayRegex, "gis"); - this.tillRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.TillRegex, "gis"); - this.specificTimeFromToRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.SpecificTimeFromTo); - this.specificTimeBetweenAndRegex = RegExpUtility.getSafeRegExp(SpanishDateTime.SpecificTimeBetweenAnd); - } - - getMatchedTimexRange(text: string): { matched: boolean; timex: string; beginHour: number; endHour: number; endMin: number; } { - - let trimmedText = text.trim().toLowerCase(); - - let beginHour = 0; - let endHour = 0; - let endMin = 0; - let timex = ""; - - let timeOfDay = ""; - if (SpanishDateTime.EarlyMorningTermList.some(o => trimmedText.endsWith(o))) { - timeOfDay = Constants.EarlyMorning; - } - else if (SpanishDateTime.MorningTermList.some(o => trimmedText.endsWith(o))) { - timeOfDay = Constants.Morning; - } - else if (SpanishDateTime.AfternoonTermList.some(o => trimmedText.includes(o))) { - timeOfDay = Constants.Afternoon; - } - else if (SpanishDateTime.EveningTermList.some(o => trimmedText.endsWith(o))) { - timeOfDay = Constants.Evening; - } - else if (SpanishDateTime.NightTermList.some(o => trimmedText.endsWith(o))) { - timeOfDay = Constants.Night; - } - else { - timex = null; - return { - matched: false, - timex, - beginHour, - endHour, - endMin - }; - } - - let parseResult = TimexUtil.parseTimeOfDay(timeOfDay); - timex = parseResult.timeX; - beginHour = parseResult.beginHour; - endHour = parseResult.endHour; - endMin = parseResult.endMin; - - return { - matched: true, - timex, - beginHour, - endHour, - endMin - }; - } -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-date-time/src/dateTime/utilities.ts b/JavaScript/packages/recognizers-date-time/src/dateTime/utilities.ts deleted file mode 100644 index a171507a4a..0000000000 --- a/JavaScript/packages/recognizers-date-time/src/dateTime/utilities.ts +++ /dev/null @@ -1,998 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { IExtractor, IParser, ExtractResult, QueryProcessor, MetaData, Match, StringUtility } from "@microsoft/recognizers-text"; -import { RegExpUtility } from "@microsoft/recognizers-text"; -import { IDateTimeParser, DateTimeParseResult } from "../dateTime/parsers"; -import { Constants, TimeTypeConstants } from "../dateTime/constants"; -import { IDateTimeExtractor } from "./baseDateTime"; -import { BaseNumberParser } from "@microsoft/recognizers-text-number"; -import { BaseDateTime } from "../resources/baseDateTime"; - -export class Token { - constructor(start: number, end: number, metaData: MetaData = null) { - this.start = start; - this.end = end; - this.metaData = metaData; - } - - start: number; - end: number; - metaData: MetaData; - - get length(): number { - return this.end - this.start; - } - - static mergeAllTokens(tokens: Token[], source: string, extractorName: string): ExtractResult[] { - let ret: ExtractResult[] = []; - let mergedTokens: Token[] = []; - tokens = tokens.sort((a, b) => { - return a.start < b.start ? -1 : 1; - }); - tokens.forEach(token => { - if (token) { - let bAdd = true; - for (let index = 0; index < mergedTokens.length && bAdd; index++) { - let mergedToken = mergedTokens[index]; - if (token.start >= mergedToken.start && token.end <= mergedToken.end) { - bAdd = false; - } - if (token.start > mergedToken.start && token.start < mergedToken.end) { - bAdd = false; - } - if (token.start <= mergedToken.start && token.end >= mergedToken.end) { - bAdd = false; - mergedTokens[index] = token; - } - } - if (bAdd) { - mergedTokens.push(token); - } - } - }); - mergedTokens.forEach(token => { - ret.push({ - start: token.start, - length: token.length, - text: source.substr(token.start, token.length), - type: extractorName, - metaData: token.metaData - }); - }); - return ret; - } -} - -export interface IDateTimeUtilityConfiguration { - agoRegex: RegExp - laterRegex: RegExp - inConnectorRegex: RegExp - rangeUnitRegex: RegExp - amDescRegex: RegExp - pmDescRegex: RegExp - amPmDescRegex: RegExp -} - -export enum AgoLaterMode { - Date, DateTime -} - -export class AgoLaterUtil { - static extractorDurationWithBeforeAndAfter(source: string, er: ExtractResult, ret: Token[], config: IDateTimeUtilityConfiguration): Token[] { - let pos = er.start + er.length; - if (pos <= source.length) { - let afterString = source.substring(pos); - let beforeString = source.substring(0, er.start); - let index = -1; - let value = MatchingUtil.getAgoLaterIndex(afterString, config.agoRegex); - if (value.matched) { - ret.push(new Token(er.start, er.start + er.length + value.index)); - } - else { - value = MatchingUtil.getAgoLaterIndex(afterString, config.laterRegex); - if (value.matched) { - ret.push(new Token(er.start, er.start + er.length + value.index)); - } - else { - value = MatchingUtil.getInIndex(beforeString, config.inConnectorRegex); - // for range unit like "week, month, year", it should output dateRange or datetimeRange - if (RegExpUtility.getMatches(config.rangeUnitRegex, er.text).length > 0) { - return ret; - } - if (value.matched && er.start && er.length && er.start >= value.index) { - ret.push(new Token(er.start - value.index, er.start + er.length)); - } - } - } - } - return ret; - } - - static parseDurationWithAgoAndLater(source: string, referenceDate: Date, durationExtractor: IDateTimeExtractor, durationParser: IDateTimeParser, unitMap: ReadonlyMap, unitRegex: RegExp, utilityConfiguration: IDateTimeUtilityConfiguration, mode: AgoLaterMode): DateTimeResolutionResult { - let result = new DateTimeResolutionResult(); - let duration = durationExtractor.extract(source, referenceDate).pop(); - if (!duration) { - return result; - } - let pr = durationParser.parse(duration, referenceDate); - if (!pr) { - return result; - } - let match = RegExpUtility.getMatches(unitRegex, source).pop(); - if (!match) { - return result; - } - let afterStr = source.substr(duration.start + duration.length); - let beforeStr = source.substr(0, duration.start); - let srcUnit = match.groups('unit').value; - let durationResult: DateTimeResolutionResult = pr.value; - let numStr = durationResult.timex.substr(0, durationResult.timex.length - 1) - .replace('P', '') - .replace('T', ''); - let num = Number.parseInt(numStr, 10); - if (!num) { - return result; - } - return AgoLaterUtil.getAgoLaterResult(pr, num, unitMap, srcUnit, afterStr, beforeStr, referenceDate, utilityConfiguration, mode); - } - - static getAgoLaterResult(durationParseResult: DateTimeParseResult, num: number, unitMap: ReadonlyMap, srcUnit: string, afterStr: string, beforeStr: string, referenceDate: Date, utilityConfiguration: IDateTimeUtilityConfiguration, mode: AgoLaterMode) { - let result = new DateTimeResolutionResult(); - let unitStr = unitMap.get(srcUnit); - if (!unitStr) { - return result; - } - let numStr = num.toString(); - let containsAgo = MatchingUtil.containsAgoLaterIndex(afterStr, utilityConfiguration.agoRegex); - let containsLaterOrIn = MatchingUtil.containsAgoLaterIndex(afterStr, utilityConfiguration.laterRegex) || MatchingUtil.containsInIndex(beforeStr, utilityConfiguration.inConnectorRegex); - if (containsAgo) { - result = AgoLaterUtil.getDateResult(unitStr, num, referenceDate, false, mode); - durationParseResult.value.mod = TimeTypeConstants.beforeMod; - result.subDateTimeEntities = [durationParseResult]; - return result; - } - if (containsLaterOrIn) { - result = AgoLaterUtil.getDateResult(unitStr, num, referenceDate, true, mode); - durationParseResult.value.mod = TimeTypeConstants.afterMod; - result.subDateTimeEntities = [durationParseResult]; - return result; - } - return result; - } - - static getDateResult(unitStr: string, num: number, referenceDate: Date, isFuture: boolean, mode: AgoLaterMode): DateTimeResolutionResult { - let value = new Date(referenceDate); - let result = new DateTimeResolutionResult(); - let swift = isFuture ? 1 : -1; - switch (unitStr) { - case 'D': value.setDate(referenceDate.getDate() + (num * swift)); break; - case 'W': value.setDate(referenceDate.getDate() + (num * swift * 7)); break; - case 'MON': value.setMonth(referenceDate.getMonth() + (num * swift)); break; - case 'Y': value.setFullYear(referenceDate.getFullYear() + (num * swift)); break; - case 'H': value.setHours(referenceDate.getHours() + (num * swift)); break; - case 'M': value.setMinutes(referenceDate.getMinutes() + (num * swift)); break; - case 'S': value.setSeconds(referenceDate.getSeconds() + (num * swift)); break; - default: return result; - } - result.timex = mode === AgoLaterMode.Date ? DateTimeFormatUtil.luisDateFromDate(value) : DateTimeFormatUtil.luisDateTime(value); - result.futureValue = value; - result.pastValue = value; - result.success = true; - return result; - } -} - -export interface MatchedIndex { - matched: boolean, - index: number -} - -export class MatchingUtil { - private static readonly InvalidDayNumberPrefix = RegExpUtility.getSafeRegExp(BaseDateTime.InvalidDayNumberPrefix); - public static isInvalidDayNumberPrefix(prefix: string): boolean { - return RegExpUtility.isMatch(this.InvalidDayNumberPrefix, prefix); - } - - public static getAgoLaterIndex(source: string, regex: RegExp): MatchedIndex { - let result: MatchedIndex = { matched: false, index: -1 }; - let referencedMatches = RegExpUtility.getMatches(regex, source.trim().toLowerCase()); - if (referencedMatches && referencedMatches.length > 0 && referencedMatches[0].index === 0) { - result.index = source.toLowerCase().indexOf(referencedMatches[0].value) + referencedMatches[0].length; - result.matched = true; - } - return result; - } - - public static getInIndex(source: string, regex: RegExp): MatchedIndex { - let result: MatchedIndex = { matched: false, index: -1 }; - let referencedMatch = RegExpUtility.getMatches(regex, source.trim().toLowerCase().split(' ').pop()); - if (referencedMatch && referencedMatch.length > 0) { - result.index = source.length - source.toLowerCase().lastIndexOf(referencedMatch[0].value); - result.matched = true; - } - return result; - } - - public static containsAgoLaterIndex(source: string, regex: RegExp): boolean { - return this.getAgoLaterIndex(source, regex).matched; - } - - public static containsInIndex(source: string, regex: RegExp): boolean { - return this.getInIndex(source, regex).matched; - } -} - -export class DateTimeFormatUtil { - public static readonly HourTimexRegex = RegExpUtility.getSafeRegExp(String.raw`(? 2 : false; - return `${DateTimeFormatUtil.luisDateFromDate(time)}${DateTimeFormatUtil.formatShortTime(time, hasMin, hasSec)}`; - } - - public static formatDate(date: Date): string { - return [DateTimeFormatUtil.toString(date.getFullYear(), 4), - DateTimeFormatUtil.toString(date.getMonth() + 1, 2), - DateTimeFormatUtil.toString(date.getDate(), 2)].join("-"); - } - - public static formatTime(time: Date) { - return [DateTimeFormatUtil.toString(time.getHours(), 2), - DateTimeFormatUtil.toString(time.getMinutes(), 2), - DateTimeFormatUtil.toString(time.getSeconds(), 2)].join(":"); - } - - public static formatDateTime(datetime: Date): string { - return `${DateTimeFormatUtil.formatDate(datetime)} ${DateTimeFormatUtil.formatTime(datetime)}`; - } - - public static formatShortTime(time: Date, hasMin: Boolean = false, hasSec: Boolean = false): string { - let hour = time.getHours(); - let min = hasMin || time.getMinutes() > 0 ? time.getMinutes() : -1; - let sec = hasSec || time.getSeconds() > 0 ? time.getSeconds() : -1; - return DateTimeFormatUtil.shortTime(hour, min, sec); - } - - public static shortTime(hour: number, minute: number, second: number): string { - if (minute < 0 && second < 0) { - return `T${DateTimeFormatUtil.toString(hour, 2)}`; - } - else if (second < 0) { - return `T${DateTimeFormatUtil.toString(hour, 2)}:${DateTimeFormatUtil.toString(minute, 2)}`; - } - return `T${DateTimeFormatUtil.toString(hour, 2)}:${DateTimeFormatUtil.toString(minute, 2)}:${DateTimeFormatUtil.toString(second, 2)}`; - } - - public static luisTimeSpan(from: Date, to: Date): string { - let result = 'PT'; - let span = DateUtils.totalHoursFloor(from, to); - if (span > 0) { - result = `${result}${span}H`; - } - - span = DateUtils.totalMinutesFloor(from, to) - (span * 60); - if (span > 0 && span < 60) { - result = `${result}${span}M`; - } - - span = DateUtils.totalSeconds(from, to) - (span * 60); - if (span > 0 && span < 60) { - result = `${result}${span}S`; - } - - return result; - } - - public static allStringToPm(timeStr: string): string { - let matches = RegExpUtility.getMatches(DateTimeFormatUtil.HourTimexRegex, timeStr); - let split = Array(); - let lastPos = 0; - matches.forEach(match => { - if (lastPos !== match.index) { - split.push(timeStr.substring(lastPos, match.index)); - } - split.push(timeStr.substring(match.index, match.index + match.length)); - lastPos = match.index + match.length; - }); - - if (timeStr.substring(lastPos)) { - split.push(timeStr.substring(lastPos)); - } - - for (let i = 0; i < split.length; i += 1) { - if (RegExpUtility.getMatches(DateTimeFormatUtil.HourTimexRegex, split[i]).length > 0) { - split[i] = DateTimeFormatUtil.toPm(split[i]); - } - } - - return split.join(''); - } - - public static toPm(timeStr: string): string { - let hasT = false; - if (timeStr.startsWith("T")) { - hasT = true; - timeStr = timeStr.substring(1); - } - - let split = timeStr.split(':'); - let hour = parseInt(split[0], 10); - hour = (hour === 12) ? 0 : hour + 12; - split[0] = DateTimeFormatUtil.toString(hour, 2); - - return (hasT ? "T" : "") + split.join(":"); - } -} - -export class StringMap { - [key: string]: string; -} - -export class DateTimeResolutionResult { - success: boolean; - timex: string; - isLunar: boolean; - mod: string; - comment: string; - futureResolution: StringMap; - pastResolution: StringMap; - futureValue: any; - pastValue: any; - subDateTimeEntities: any[]; - - constructor() { - this.success = false; - } -} - -export class TimeOfDayResolutionResult { - timeX: string; - beginHour: number; - endHour: number; - endMin: number; - - constructor() { - this.timeX = null; - this.beginHour = this.endHour = this.endMin = 0; - } -} - -export enum DayOfWeek { - Sunday = 0, - Monday = 1, - Tuesday = 2, - Wednesday = 3, - Thursday = 4, - Friday = 5, - Saturday = 6 -} - -export class DateUtils { - private static readonly oneDay = 24 * 60 * 60 * 1000; - private static readonly oneHour = 60 * 60 * 1000; - private static readonly oneMinute = 60 * 1000; - private static readonly oneSecond = 1000; - - // Generate future/past date for cases without specific year like "Feb 29th" - static generateDates(noYear: boolean, referenceDate: Date, year: number, month: number, day: number): { future: Date, past: Date} { - let futureDate = this.safeCreateFromMinValue(year, month, day); - let pastDate = this.safeCreateFromMinValue(year, month, day); - let futureYear = year; - let pastYear = year; - if (noYear){ - if (this.isFeb29th(year, month, day)) { - if (this.isLeapYear(year)) { - if (futureDate < referenceDate) { - futureDate = this.safeCreateFromMinValue(futureYear + 4, month, day); - } - else { - pastDate = this.safeCreateFromMinValue(pastYear - 4, month, day); - } - } - else { - pastYear = pastYear >> 2 << 2; - if (!this.isLeapYear(pastYear)) { - pastYear -= 4; - } - - futureYear = pastYear + 4; - if (!this.isLeapYear(futureYear)) { - futureYear += 4; - } - - futureDate = this.safeCreateFromMinValue(futureYear, month, day); - pastDate = this.safeCreateFromMinValue(pastYear, month, day); - } - } - else { - if (futureDate < referenceDate && this.isValidDate(year, month, day)) { - futureDate = this.safeCreateFromMinValue(year + 1, month, day); - } - if (pastDate >= referenceDate && this.isValidDate(year, month, day)) { - pastDate = this.safeCreateFromMinValue(year - 1, month, day); - } - } - } - - return { future: futureDate, past: pastDate }; - } - - static parseChineseDynastyYear(yearStr: string, dynastyYearRegex: RegExp, dynastyYearMap: ReadonlyMap, dynastyStartYear: string, integerExtractor: IExtractor, numberParser: IParser): number { - let year = -1; - let regionTitleMatch = RegExpUtility.getMatches(dynastyYearRegex, yearStr).pop(); - if (regionTitleMatch && regionTitleMatch.index === 0 && regionTitleMatch.length === yearStr.length) { - // handle "康熙元年" refer to https://zh.wikipedia.org/wiki/%E5%B9%B4%E5%8F%B7 - let dynastyYearStr = regionTitleMatch.groups('dynasty').value; - let biasYearStr = regionTitleMatch.groups('biasYear').value; - let basicYear = dynastyYearMap.get(dynastyYearStr); - let biasYear = 1; - if (biasYearStr != dynastyStartYear) { - let er = integerExtractor.extract(biasYearStr).pop(); - biasYear = Number.parseInt(numberParser.parse(er).value); - } - year = basicYear + biasYear - 1; - } - - return year; - } - - static next(from: Date, dayOfWeek: DayOfWeek): Date { - let start = from.getDay(); - let target = dayOfWeek; - - if (start === 0) { - start = 7; - } - - if (target === 0) { - target = 7; - } - - let result = new Date(from); - result.setDate(from.getDate() + target - start + 7); - return result; - } - - static this(from: Date, dayOfWeek: DayOfWeek): Date { - let start = from.getDay(); - let target = dayOfWeek; - - if (start === 0) { - start = 7; - } - - if (target === 0) { - target = 7; - } - - let result = new Date(from); - result.setDate(from.getDate() + target - start); - return result; - } - - static last(from: Date, dayOfWeek: DayOfWeek): Date { - let start = from.getDay(); - let target = dayOfWeek; - - if (start === 0) { - start = 7; - } - - if (target === 0) { - target = 7; - } - - let result = new Date(from); - result.setDate(from.getDate() + target - start - 7); - return result; - } - - static diffDays(from: Date, to: Date): number { - return Math.round(Math.abs((from.getTime() - to.getTime()) / this.oneDay)); - } - - static totalHours(from: Date, to: Date): number { - // Fix to mimic .NET's Convert.ToInt32() - // C#: Math.Round(4.5) === 4 - // C#: Convert.ToInt32(4.5) === 4 - // JS: Math.round(4.5) === 5 !! - let fromEpoch = from.getTime() - (from.getTimezoneOffset() * 60 * 1000); - let toEpoch = to.getTime() - (to.getTimezoneOffset() * 60 * 1000); - return Math.round(Math.abs(fromEpoch - toEpoch - 0.00001) / this.oneHour); - } - - static totalHoursFloor(from: Date, to: Date): number { - let fromEpoch = from.getTime() - (from.getTimezoneOffset() * this.oneMinute); - let toEpoch = to.getTime() - (to.getTimezoneOffset() * this.oneMinute); - return Math.floor(Math.abs(fromEpoch - toEpoch) / this.oneHour); - } - - static totalMinutesFloor(from: Date, to: Date): number { - let fromEpoch = from.getTime() - (from.getTimezoneOffset() * this.oneMinute); - let toEpoch = to.getTime() - (to.getTimezoneOffset() * this.oneMinute); - return Math.floor(Math.abs(fromEpoch - toEpoch) / this.oneMinute); - } - - static totalSeconds(from: Date, to: Date): number { - let fromEpoch = from.getTime() - (from.getTimezoneOffset() * 60 * 1000); - let toEpoch = to.getTime() - (to.getTimezoneOffset() * 60 * 1000); - return Math.round(Math.abs(fromEpoch - toEpoch) / this.oneSecond); - } - - static addTime(seedDate: Date, timeToAdd: Date): Date { - let date = new Date(seedDate); - date.setHours(seedDate.getHours() + timeToAdd.getHours()); - date.setMinutes(seedDate.getMinutes() + timeToAdd.getMinutes()); - date.setSeconds(seedDate.getSeconds() + timeToAdd.getSeconds()); - return date; - } - - static addSeconds(seedDate: Date, secondsToAdd: number): Date { - let date = new Date(seedDate); - date.setSeconds(seedDate.getSeconds() + secondsToAdd); - return date; - } - - static addMinutes(seedDate: Date, minutesToAdd: number): Date { - let date = new Date(seedDate); - date.setMinutes(seedDate.getMinutes() + minutesToAdd); - return date; - } - - static addHours(seedDate: Date, hoursToAdd: number): Date { - let date = new Date(seedDate); - date.setHours(seedDate.getHours() + hoursToAdd); - return date; - } - - static addDays(seedDate: Date, daysToAdd: number): Date { - let date = new Date(seedDate); - date.setDate(seedDate.getDate() + daysToAdd); - return date; - } - - static addMonths(seedDate: Date, monthsToAdd: number): Date { - let date = new Date(seedDate); - date.setMonth(seedDate.getMonth() + monthsToAdd); - return date; - } - - static addYears(seedDate: Date, yearsToAdd: number): Date { - let date = new Date(seedDate); - date.setFullYear(seedDate.getFullYear() + yearsToAdd); - return date; - } - - static getWeekNumber(referenceDate: Date): { weekNo: number, year: number } { - // Create a copy of this date object - let target = new Date(referenceDate.valueOf()); - - // ISO week date weeks start on monday - // so correct the day number - let dayNr = (referenceDate.getDay() + 6) % 7; - - // ISO 8601 states that week 1 is the week - // with the first thursday of that year. - // Set the target date to the thursday in the target week - target.setDate(target.getDate() - dayNr + 3); - - // Store the millisecond value of the target date - let firstThursday = target.valueOf(); - let thursday = new Date(firstThursday); - - // Set the target to the first thursday of the year - // First set the target to january first - target.setMonth(0, 1); - // Not a thursday? Correct the date to the next thursday - if (target.getDay() !== 4) { - target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); - } - - // The weeknumber is the number of weeks between the - // first thursday of the year and the thursday in the target week - let weekNo = 1 + Math.ceil((firstThursday - target.valueOf()) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 - return { weekNo: weekNo, year: thursday.getFullYear() }; - } - - static minValue(): Date { - let date = new Date(1, 0, 1, 0, 0, 0, 0); - date.setFullYear(1); - return date; - } - - static safeCreateFromValue(seedDate: Date, year: number, month: number, day: number, hour = 0, minute = 0, second = 0) { - if (this.isValidDate(year, month, day) && this.isValidTime(hour, minute, second)) { - return new Date(year, month, day, hour, minute, second, 0); - } - return seedDate; - } - - static safeCreateFromMinValue(year: number, month: number, day: number, hour = 0, minute = 0, second = 0) { - return this.safeCreateFromValue(this.minValue(), year, month, day, hour, minute, second); - } - - // Resolve month overflow - static safeCreateDateResolveOverflow(year: number, month: number, day: number): Date { - if (month >= 12) { - year += (month + 1) / 12; - month %= 12; - } - return this.safeCreateFromMinValue(year, month, day); - } - - static safeCreateFromMinValueWithDateAndTime(date: Date, time?: Date): Date { - return this.safeCreateFromMinValue( - date.getFullYear(), date.getMonth(), date.getDate(), - time ? time.getHours() : 0, time ? time.getMinutes() : 0, time ? time.getSeconds() : 0 - ); - } - - static isLeapYear(year: number): boolean { - return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); - } - - static dayOfYear(date: Date): number { - let start = new Date(date.getFullYear(), 0, 1); - let diffDays = date.valueOf() - start.valueOf(); - return Math.floor(diffDays / DateUtils.oneDay); - } - - static isDafaultValue(date: Date): boolean { - return date.getTime() === this.minValue().getTime(); - } - - static isFeb29th(year: number, month: number, day: number): boolean { - return month === 1 && day === 29; - } - - static isFeb29thDate(date: Date): boolean { - return date.getMonth() === 1 && date.getDate() === 29; - } - - static isValidDate(year: number, month: number, day: number): boolean { - return year > 0 && year <= 9999 - && month >= 0 && month < 12 - && day > 0 && day <= this.validDays(year)[month]; - } - - static isValidDateType(date: Date): boolean { - return DateUtils.isValidDate(date.getFullYear(), date.getMonth(), date.getDate()); - } - - static isEmpty(date: Date) { - return date.getFullYear() == Constants.InvalidYear; - } - - static setDateWithContext(originDate: Date, year: number) { - if (!DateUtils.isDafaultValue(originDate)) { - return DateUtils.safeCreateFromMinValue(year, originDate.getMonth(), originDate.getDate()); - } - - return originDate; - } - - static getYear(config, startText: string, endText: string, text: string): number { - let contextYear = -1; - let isEndDatePureYear = false; - let isDateRelative = false; - - let yearMatchForEndDate = RegExpUtility.getMatches(config.yearRegex, endText); - - if (yearMatchForEndDate && yearMatchForEndDate.length == 1 && yearMatchForEndDate[0].length == endText.length) - { - isEndDatePureYear = true; - } - - let relativeMatchForStartDate = RegExpUtility.getMatches(config.relativeRegex, startText); - let relativeMatchForEndDate = RegExpUtility.getMatches(config.relativeRegex, endText); - isDateRelative = (relativeMatchForStartDate && relativeMatchForStartDate.length > 0) || (relativeMatchForEndDate && relativeMatchForEndDate.length > 0); - - if (!isEndDatePureYear && !isDateRelative) { - let matchYear = RegExpUtility.getMatches(config.yearRegex, text); - for (let match of matchYear) { - let year = AbstractYearExtractor.getYearFromText(match, config.numberParser); - if (year != -1) { - if (contextYear == -1) { - contextYear = year; - } - else { - if (contextYear != year) { - contextYear = -1; - break; - } - } - } - } - } - - return contextYear; - } - - static processDateEntityParsingResult(pr: DateTimeParseResult, year: number) { - if (year != -1){ - pr.timexStr = TimexUtil.setTimexWithContext(pr.timexStr, year); - pr.value = DateUtils.syncYearResolution(pr.value, year, year); - } - - return pr; - } - - // This method is to ensure the year of begin date is same with the end date in no year situation. - static syncYear(pr1: DateTimeParseResult, pr2: DateTimeParseResult): { pr1: DateTimeParseResult, pr2: DateTimeParseResult } { - let futureYear; - let pastYear; - if (DateUtils.isFeb29thDate(pr1.value.futureValue)) { - futureYear = pr1.value.futureValue.getFullYear(); - pastYear = pr1.value.pastValue.getFullYear(); - pr2.value = DateUtils.syncYearResolution(pr2.value, futureYear, pastYear); - } - else if (DateUtils.isFeb29thDate(pr2.value.futureValue)) { - futureYear = pr2.value.FftureValue.getFullYear(); - pastYear = pr2.value.pastValue.getFullYear(); - pr1.value = DateUtils.syncYearResolution(pr1.value, futureYear, pastYear); - } - - return {pr1, pr2}; - } - - static syncYearResolution(resolutionResult: DateTimeResolutionResult , futureYear: number, pastYear: number): DateTimeResolutionResult { - resolutionResult.futureValue = DateUtils.setDateWithContext(resolutionResult.futureValue, futureYear); - resolutionResult.pastValue = DateUtils.setDateWithContext(resolutionResult.pastValue, pastYear); - - return resolutionResult; - } - - private static validDays(year: number) { - return [31, this.isLeapYear(year) ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; - } - - private static isValidTime(hour: number, minute: number, second: number) { - return hour >= 0 && hour < 24 - && minute >= 0 && minute < 60 - && second >= 0 && minute < 60; - } -} - -export class HolidayFunctions { - - static calculateHolidayByEaster(year: number, days = 0): Date { - - let day = 0; - let month = 2; // In JavaScript month is 0 indexed - - let g = year % 19; - let c = year / 100; - let h = (c - ~~(c / 4) - ~~(((8 * c) + 13) / 25) + (19 * g) + 15) % 30; - let i = h - (~~(h / 28) * (1 - (~~(h / 28) * (29 / (h + 1)) * ~~((21 - g) / 11)))); - - day = i - ((year + ~~(year / 4) + i + 2 - c + ~~(c / 4)) % 7) + 28; - - if (day > 31) { - month++; - day -= 31; - } - - return DateUtils.addDays(DateUtils.safeCreateFromMinValue(year, month, day), days); - } - -} - -export class TimexUtil { - public static parseTimeOfDay(tod: string): TimeOfDayResolutionResult { - let result = new TimeOfDayResolutionResult(); - switch (tod) { - case Constants.EarlyMorning: - result.timeX = Constants.EarlyMorning; - result.beginHour = 4; - result.endHour = 8; - break; - case Constants.Morning: - result.timeX = Constants.Morning; - result.beginHour = 8; - result.endHour = 12; - break; - case Constants.MidDay: - result.timeX = Constants.MidDay; - result.beginHour = 11; - result.endHour = 13; - break; - case Constants.Afternoon: - result.timeX = Constants.Afternoon; - result.beginHour = 12; - result.endHour = 16; - break; - case Constants.Evening: - result.timeX = Constants.Evening; - result.beginHour = 16; - result.endHour = 20; - break; - case Constants.Daytime: - result.timeX = Constants.Daytime; - result.beginHour = 8; - result.endHour = 18; - break; - case Constants.BusinessHour: - result.timeX = Constants.BusinessHour; - result.beginHour = 8; - result.endHour = 18; - break; - case Constants.Night: - result.timeX = Constants.Night; - result.beginHour = 20; - result.endHour = 23; - result.endMin = 59; - break; - default: - break; - } - - return result; - } - - static setTimexWithContext(timex: string, year: number) { - return timex.replace(Constants.TimexFuzzyYear, DateTimeFormatUtil.toString(year, 4)); - } - - static getDatePeriodTimexUnitCount(begin: Date, end: Date, timeType: string): number { - let unitCount; - switch (timeType) { - case Constants.ByDay: - unitCount = DateUtils.diffDays(end, begin); - break; - case Constants.ByWeek: - unitCount = DateUtils.diffDays(end, begin) / 7; - break; - case Constants.ByMonth: - unitCount = (end.getFullYear() - begin.getFullYear()) * 12 + (end.getMonth() - begin.getMonth()); - break; - default: - unitCount = (end.getFullYear() - begin.getFullYear()) + (end.getMonth() - begin.getMonth()) / 12.0; - break; - } - - return unitCount; - } - - public static generateDatePeriodTimex(begin: Date, end: Date, timexType: string, timex1: string, timex2: string) { - let boundaryValid = !DateUtils.isDafaultValue(begin) && !DateUtils.isDafaultValue(end); - var unitCount = boundaryValid ? TimexUtil.getDatePeriodTimexUnitCount(begin, end, timexType) : "X"; - var datePeriodTimex = `P${unitCount}${Constants.DatePeriodTimexTypeToTimexSuffix.get(timexType)}`; - return `(${timex1},${timex2},${datePeriodTimex})`; - } - - public static mergeTimexAlternatives(timex1: string, timex2: string): string { - return timex1 === timex2 ? timex1 : `${timex1}${Constants.CompositeTimexDelimiter}${timex2}`; - } -} - -export class AbstractYearExtractor { - - public static getYearFromText(match: Match, numberParser: BaseNumberParser): number { - - let year = -1; - - let yearStr = match.groups('year').value; - let writtenYearStr = match.groups('fullyear').value; - if (!StringUtility.isNullOrEmpty(yearStr) && !(yearStr == writtenYearStr)) { - year = Number.parseInt(yearStr, 10); - if (year < 100 && year >= Constants.MinTwoDigitYearPastNum) - { - year += 1900; - } - else if (year >= 0 && year < Constants.MaxTwoDigitYearFutureNum) - { - year += 2000; - } - } - else { - let firstTwoYearNumStr = match.groups('firsttwoyearnum').value; - if (!StringUtility.isNullOrEmpty(firstTwoYearNumStr)) { - let er = new ExtractResult(); - er.text = firstTwoYearNumStr; - er.start = match.groups('firsttwoyearnum').index; - er.length = match.groups('firsttwoyearnum').length; - - let firstTwoYearNum = Number.parseInt(numberParser.parse(er).value, 10); - - let lastTwoYearNum = 0; - let lastTwoYearNumStr = match.groups('lasttwoyearnum').value; - if (!StringUtility.isNullOrEmpty(lastTwoYearNumStr)) { - er.text = lastTwoYearNumStr; - er.start = match.groups('lasttwoyearnum').index; - er.length = match.groups('lasttwoyearnum').length; - - lastTwoYearNum = Number.parseInt(numberParser.parse(er).value, 10); - } - - // Exclude pure number like "nineteen", "twenty four" - if (firstTwoYearNum < 100 && lastTwoYearNum === 0 || firstTwoYearNum < 100 && firstTwoYearNum % 10 === 0 && lastTwoYearNumStr.trim().split(' ').length === 1) { - year = -1; - return year; - } - - if (firstTwoYearNum >= 100) { - year = (firstTwoYearNum + lastTwoYearNum); - } - else { - year = (firstTwoYearNum * 100 + lastTwoYearNum); - } - } - else { - if (!StringUtility.isNullOrEmpty(writtenYearStr)) { - let er = new ExtractResult(); - er.text = writtenYearStr; - er.start = match.groups('fullyear').index; - er.length = match.groups('fullyear').length; - - let year = Number.parseInt(numberParser.parse(er).value, 10); - - if (year < 100 && year >= Constants.MinTwoDigitYearPastNum) - { - year += 1900; - } - else if (year >= 0 && year < Constants.MaxTwoDigitYearFutureNum) - { - year += 2000; - } - } - } - } - - return year; - } -} - -export class DefinitionLoader { - - public static LoadAmbiguityFilters(filters: ReadonlyMap) - { - let ambiguityFiltersDict: Map = new Map(); - - if (filters != null) - { - for (let [key, value] of filters) { - if (key) { - ambiguityFiltersDict.set(RegExpUtility.getSafeRegExp(key), RegExpUtility.getSafeRegExp(value)); - } - } - } - - return ambiguityFiltersDict; - } -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-date-time/src/recognizers-text-date-time.ts b/JavaScript/packages/recognizers-date-time/src/recognizers-text-date-time.ts deleted file mode 100644 index 689fd81093..0000000000 --- a/JavaScript/packages/recognizers-date-time/src/recognizers-text-date-time.ts +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -export { default as DateTimeRecognizer, DateTimeOptions, recognizeDateTime } from "./dateTime/dateTimeRecognizer"; -export { Culture, CultureInfo } from "@microsoft/recognizers-text-number"; -export { IDateExtractorConfiguration, IDateParserConfiguration, BaseDateExtractor, BaseDateParser } from "./dateTime/baseDate"; -export { ITimeExtractorConfiguration, ITimeParserConfiguration, BaseTimeExtractor, BaseTimeParser } from "./dateTime/baseTime"; -export { IDatePeriodExtractorConfiguration, IDatePeriodParserConfiguration, BaseDatePeriodExtractor, BaseDatePeriodParser } from "./dateTime/baseDatePeriod"; -export { ITimePeriodExtractorConfiguration, ITimePeriodParserConfiguration, BaseTimePeriodExtractor, BaseTimePeriodParser } from "./dateTime/baseTimePeriod"; -export { IDateTimeExtractor, IDateTimeExtractorConfiguration, IDateTimeParserConfiguration, BaseDateTimeExtractor, BaseDateTimeParser } from "./dateTime/baseDateTime"; -export { IDateTimePeriodExtractorConfiguration, IDateTimePeriodParserConfiguration, BaseDateTimePeriodExtractor, BaseDateTimePeriodParser } from "./dateTime/baseDateTimePeriod"; -export { IDurationExtractorConfiguration, IDurationParserConfiguration, BaseDurationExtractor, BaseDurationParser } from "./dateTime/baseDuration"; -export { ISetExtractorConfiguration, ISetParserConfiguration, BaseSetExtractor, BaseSetParser } from "./dateTime/baseSet"; -export { IHolidayExtractorConfiguration, IHolidayParserConfiguration, BaseHolidayExtractor, BaseHolidayParser, BaseHolidayParserConfiguration } from "./dateTime/baseHoliday"; -export { IMergedExtractorConfiguration, IMergedParserConfiguration, BaseMergedExtractor, BaseMergedParser } from "./dateTime/baseMerged"; -export { Constants, TimeTypeConstants } from "./dateTime/constants"; -export { IDateTimeModel, DateTimeModelResult, DateTimeModel } from "./dateTime/models"; -export { DateTimeParseResult, ICommonDateTimeParserConfiguration, IDateTimeParser, BaseDateParserConfiguration } from "./dateTime/parsers"; -export { Token, IDateTimeUtilityConfiguration, AgoLaterMode, AgoLaterUtil, MatchedIndex, MatchingUtil, DateTimeFormatUtil, DateTimeResolutionResult, DateUtils, DayOfWeek } from "./dateTime/utilities"; -export { EnglishCommonDateTimeParserConfiguration, EnglishDateTimeUtilityConfiguration } from "./dateTime/english/baseConfiguration"; -export { EnglishDateExtractorConfiguration, EnglishDateParserConfiguration } from "./dateTime/english/dateConfiguration"; -export { EnglishTimeExtractorConfiguration, EnglishTimeParserConfiguration } from "./dateTime/english/timeConfiguration"; -export { EnglishDatePeriodExtractorConfiguration, EnglishDatePeriodParserConfiguration } from "./dateTime/english/datePeriodConfiguration"; -export { EnglishTimePeriodExtractorConfiguration, EnglishTimePeriodParserConfiguration } from "./dateTime/english/timePeriodConfiguration"; -export { EnglishDateTimeExtractorConfiguration, EnglishDateTimeParserConfiguration } from "./dateTime/english/dateTimeConfiguration"; -export { EnglishDateTimePeriodExtractorConfiguration, EnglishDateTimePeriodParserConfiguration } from "./dateTime/english/dateTimePeriodConfiguration"; -export { EnglishSetExtractorConfiguration, EnglishSetParserConfiguration } from "./dateTime/english/setConfiguration"; -export { EnglishDurationExtractorConfiguration, EnglishDurationParserConfiguration } from "./dateTime/english/durationConfiguration"; -export { EnglishHolidayExtractorConfiguration, EnglishHolidayParserConfiguration } from "./dateTime/english/holidayConfiguration"; -export { EnglishMergedExtractorConfiguration, EnglishMergedParserConfiguration } from "./dateTime/english/mergedConfiguration"; -export { EnglishTimeParser } from "./dateTime/english/parsers"; -export { SpanishCommonDateTimeParserConfiguration, SpanishDateTimeUtilityConfiguration } from "./dateTime/spanish/baseConfiguration"; -export { SpanishDateExtractorConfiguration, SpanishDateParserConfiguration } from "./dateTime/spanish/dateConfiguration"; -export { SpanishTimeExtractorConfiguration, SpanishTimeParserConfiguration } from "./dateTime/spanish/timeConfiguration"; -export { SpanishDatePeriodExtractorConfiguration, SpanishDatePeriodParserConfiguration } from "./dateTime/spanish/datePeriodConfiguration"; -export { SpanishTimePeriodExtractorConfiguration, SpanishTimePeriodParserConfiguration } from "./dateTime/spanish/timePeriodConfiguration"; -export { SpanishDateTimeExtractorConfiguration, SpanishDateTimeParserConfiguration } from "./dateTime/spanish/dateTimeConfiguration"; -export { SpanishDateTimePeriodExtractorConfiguration, SpanishDateTimePeriodParserConfiguration } from "./dateTime/spanish/dateTimePeriodConfiguration"; -export { SpanishSetExtractorConfiguration, SpanishSetParserConfiguration } from "./dateTime/spanish/setConfiguration"; -export { SpanishDurationExtractorConfiguration, SpanishDurationParserConfiguration } from "./dateTime/spanish/durationConfiguration"; -export { SpanishHolidayExtractorConfiguration, SpanishHolidayParserConfiguration } from "./dateTime/spanish/holidayConfiguration"; -export { SpanishMergedExtractorConfiguration, SpanishMergedParserConfiguration } from "./dateTime/spanish/mergedConfiguration"; -export { SpanishDateTimePeriodParser } from "./dateTime/spanish/dateTimePeriodParser"; -export { FrenchCommonDateTimeParserConfiguration, FrenchDateTimeUtilityConfiguration } from "./dateTime/french/baseConfiguration"; -export { FrenchDateExtractorConfiguration, FrenchDateParserConfiguration } from "./dateTime/french/dateConfiguration"; -export { FrenchTimeExtractorConfiguration, FrenchTimeParserConfiguration } from "./dateTime/french/timeConfiguration"; -export { FrenchDatePeriodExtractorConfiguration, FrenchDatePeriodParserConfiguration } from "./dateTime/french/datePeriodConfiguration"; -export { FrenchTimePeriodExtractorConfiguration, FrenchTimePeriodParserConfiguration } from "./dateTime/french/timePeriodConfiguration"; -export { FrenchDateTimeExtractorConfiguration, FrenchDateTimeParserConfiguration } from "./dateTime/french/dateTimeConfiguration"; -export { FrenchDateTimePeriodExtractorConfiguration, FrenchDateTimePeriodParserConfiguration } from "./dateTime/french/dateTimePeriodConfiguration"; -export { FrenchSetExtractorConfiguration, FrenchSetParserConfiguration } from "./dateTime/french/setConfiguration"; -export { FrenchDurationExtractorConfiguration, FrenchDurationParserConfiguration } from "./dateTime/french/durationConfiguration"; -export { FrenchHolidayExtractorConfiguration, FrenchHolidayParserConfiguration } from "./dateTime/french/holidayConfiguration"; -export { FrenchMergedExtractorConfiguration, FrenchMergedParserConfiguration } from "./dateTime/french/mergedConfiguration"; -export { FrenchTimeParser } from './dateTime/french/timeParser'; -export { ChineseDurationExtractor, ChineseDurationParser } from "./dateTime/chinese/durationConfiguration"; -export { ChineseTimeExtractor, ChineseTimeParser } from "./dateTime/chinese/timeConfiguration"; -export { ChineseTimePeriodExtractor, ChineseTimePeriodParser } from "./dateTime/chinese/timePeriodConfiguration"; -export { ChineseDateExtractor, ChineseDateParser } from "./dateTime/chinese/dateConfiguration"; -export { ChineseDatePeriodExtractor, ChineseDatePeriodParser } from "./dateTime/chinese/datePeriodConfiguration"; -export { ChineseDateTimeExtractor, ChineseDateTimeParser } from "./dateTime/chinese/dateTimeConfiguration"; -export { ChineseDateTimePeriodExtractor, ChineseDateTimePeriodParser } from "./dateTime/chinese/dateTimePeriodConfiguration"; -export { ChineseSetExtractor, ChineseSetParser } from "./dateTime/chinese/setConfiguration"; -export { ChineseHolidayExtractorConfiguration, ChineseHolidayParser } from "./dateTime/chinese/holidayConfiguration"; -export { ChineseMergedExtractor, ChineseMergedParser, ChineseFullMergedParser } from "./dateTime/chinese/mergedConfiguration"; - -export { BaseDateTime } from "./resources/baseDateTime"; -export { EnglishDateTime } from "./resources/englishDateTime"; -export { SpanishDateTime } from "./resources/spanishDateTime"; -export { FrenchDateTime } from "./resources/frenchDateTime"; -export { ChineseDateTime } from "./resources/chineseDateTime"; \ No newline at end of file diff --git a/JavaScript/packages/recognizers-date-time/src/resources/baseDateTime.ts b/JavaScript/packages/recognizers-date-time/src/resources/baseDateTime.ts deleted file mode 100644 index bac10bffca..0000000000 --- a/JavaScript/packages/recognizers-date-time/src/resources/baseDateTime.ts +++ /dev/null @@ -1,36 +0,0 @@ -// ------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// ------------------------------------------------------------------------------ - -export namespace BaseDateTime { - export const HourRegex = `(?2[0-4]|[0-1]?\\d)(h)?`; - export const TwoDigitHourRegex = `(?[0-1]\\d|2[0-4])(h)?`; - export const MinuteRegex = `(?[0-5]\\d)(?!\\d)`; - export const TwoDigitMinuteRegex = `(?[0-5]\\d)(?!\\d)`; - export const DeltaMinuteRegex = `(?[0-5]?\\d)`; - export const SecondRegex = `(?[0-5]?\\d)`; - export const FourDigitYearRegex = `\\b(?((1\\d|20)\\d{2})|2100)(?!\\.0\\b)\\b`; - export const HyphenDateRegex = `((?[0-9]{4})-?(?1[0-2]|0[1-9])-?(?3[01]|0[1-9]|[12][0-9]))|((?1[0-2]|0[1-9])-?(?3[01]|0[1-9]|[12][0-9])-?(?[0-9]{4}))|((?3[01]|0[1-9]|[12][0-9])-?(?1[0-2]|0[1-9])-?(?[0-9]{4}))`; - export const IllegalYearRegex = `([-])(${FourDigitYearRegex})([-])`; - export const InvalidDayNumberPrefix = `(\\d[.,:]|[$£€]\\s*)$`; - export const CheckDecimalRegex = `(?![,.]\\d)`; - export const RangeConnectorSymbolRegex = `(--|-|—|——|~|–)`; - export const BaseAmDescRegex = `(am\\b|a\\s*\\.\\s*m\\s*\\.|a[\\.]?\\s*m\\b)`; - export const BasePmDescRegex = `(pm\\b|p\\s*\\.\\s*m\\s*\\.|p[\\.]?\\s*m\\b)`; - export const BaseAmPmDescRegex = `(ampm)`; - export const EqualRegex = `(?)=`; - export const BracketRegex = `^\\s*[\\)\\]]|[\\[\\(]\\s*$`; - export const MinYearNum = `1500`; - export const MaxYearNum = `2100`; - export const MaxTwoDigitYearFutureNum = `30`; - export const MinTwoDigitYearPastNum = `40`; - export const DayOfMonthDictionary: ReadonlyMap = new Map([["1", 1],["2", 2],["3", 3],["4", 4],["5", 5],["6", 6],["7", 7],["8", 8],["9", 9],["10", 10],["11", 11],["12", 12],["13", 13],["14", 14],["15", 15],["16", 16],["17", 17],["18", 18],["19", 19],["20", 20],["21", 21],["22", 22],["23", 23],["24", 24],["25", 25],["26", 26],["27", 27],["28", 28],["29", 29],["30", 30],["31", 31],["01", 1],["02", 2],["03", 3],["04", 4],["05", 5],["06", 6],["07", 7],["08", 8],["09", 9]]); - export const VariableHolidaysTimexDictionary: ReadonlyMap = new Map([["fathers", "-06-WXX-7-3"],["mothers", "-05-WXX-7-2"],["thanksgiving", "-11-WXX-4-4"],["martinlutherking", "-01-WXX-1-3"],["washingtonsbirthday", "-02-WXX-1-3"],["canberra", "-03-WXX-1-1"],["labour", "-09-WXX-1-1"],["columbus", "-10-WXX-1-2"],["memorial", "-05-WXX-1-4"]]); -} diff --git a/JavaScript/packages/recognizers-date-time/src/resources/chineseDateTime.ts b/JavaScript/packages/recognizers-date-time/src/resources/chineseDateTime.ts deleted file mode 100644 index 7e82697aa4..0000000000 --- a/JavaScript/packages/recognizers-date-time/src/resources/chineseDateTime.ts +++ /dev/null @@ -1,249 +0,0 @@ -// ------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// ------------------------------------------------------------------------------ - -import { BaseDateTime } from "./baseDateTime"; -export namespace ChineseDateTime { - export const LangMarker = `Chi`; - export const MonthRegex = `(?正月|一月|二月|三月|四月|五月|六月|七月|八月|九月|十月|十一月|十二月|01月|02月|03月|04月|05月|06月|07月|08月|09月|10月|11月|12月|1月|2月|3月|4月|5月|6月|7月|8月|9月|大年(?!龄|纪|级))`; - export const DayRegex = `(?01|02|03|04|05|06|07|08|09|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|1|2|3|4|5|6|7|8|9)`; - export const OneToNineIntegerRegex = `[一二三四五六七八九壹贰叁肆伍陆柒捌玖]`; - export const DateDayRegexInCJK = `(?(([12][0-9]|3[01]|[1-9]|[三叁][十拾][一壹]?|[二贰貳]?[十拾](${OneToNineIntegerRegex})?|${OneToNineIntegerRegex})[日号]|初一|三十))`; - export const DayRegexNumInCJK = `(?[12][0-9]|3[01]|[1-9]|[三叁][十拾][一壹]?|[二贰貳]?[十拾](${OneToNineIntegerRegex})?|${OneToNineIntegerRegex}|廿|卅)`; - export const MonthNumRegex = `(?01|02|03|04|05|06|07|08|09|10|11|12|1|2|3|4|5|6|7|8|9)`; - export const TwoNumYear = `50`; - export const YearNumRegex = `(?((1[5-9]|20)\\d{2})|2100)`; - export const SimpleYearRegex = `(?(\\d{2,4}))`; - export const ZeroToNineIntegerRegexCJK = `[一二三四五六七八九零壹贰叁肆伍陆柒捌玖〇两千俩倆仨]`; - export const DynastyStartYear = `元`; - export const RegionTitleRegex = `(贞观|开元|神龙|洪武|建文|永乐|景泰|天顺|成化|嘉靖|万历|崇祯|顺治|康熙|雍正|乾隆|嘉庆|道光|咸丰|同治|光绪|宣统|民国)`; - export const DynastyYearRegex = `(?${RegionTitleRegex})(?(${DynastyStartYear}|\\d{1,3}|[十拾]?(${ZeroToNineIntegerRegexCJK}[十百拾佰]?){0,3}))`; - export const DateYearInCJKRegex = `(?(${ZeroToNineIntegerRegexCJK}${ZeroToNineIntegerRegexCJK}${ZeroToNineIntegerRegexCJK}${ZeroToNineIntegerRegexCJK}|${ZeroToNineIntegerRegexCJK}${ZeroToNineIntegerRegexCJK}|${ZeroToNineIntegerRegexCJK}${ZeroToNineIntegerRegexCJK}${ZeroToNineIntegerRegexCJK}|${DynastyYearRegex}))`; - export const WeekDayRegex = `(?周日|周天|周一|周二|周三|周四|周五|周六|星期一|星期二|星期三|星期四|星期五|星期六|星期日|星期天|礼拜一|礼拜二|礼拜三|礼拜四|礼拜五|礼拜六|礼拜日|礼拜天|禮拜一|禮拜二|禮拜三|禮拜四|禮拜五|禮拜六|禮拜日|禮拜天|週日|週天|週一|週二|週三|週四|週五|週六)`; - export const WeekDayStartEnd = `^[.]`; - export const LunarRegex = `(农历|初一|正月|大年(?!龄|纪|级))`; - export const DateThisRegex = `(这个|这一个|这|这一|本)${WeekDayRegex}`; - export const DateLastRegex = `(上一个|上个|上一|上|最后一个|最后)(的)?${WeekDayRegex}`; - export const DateNextRegex = `(下一个|下个|下一|下)(的)?${WeekDayRegex}`; - export const WeekWithWeekDayRangeRegex = `^[.]`; - export const WoMLastRegex = `最后一`; - export const WoMPreviousRegex = `上个`; - export const WoMNextRegex = `下个`; - export const SpecialMonthRegex = `^[.]`; - export const SpecialYearRegex = `^[.]`; - export const MonthDayRange = `^[.]`; - export const SpecialDayRegex = `(最近|前天|后天|昨天|明天|今天|今日|明日|昨日|大后天|大前天|後天|大後天)`; - export const SpecialDayWithNumRegex = `^[.]`; - export const WeekDayOfMonthRegex = `(((${MonthRegex}|${MonthNumRegex})的\\s*)(?第一个|第二个|第三个|第四个|第五个|最后一个)\\s*${WeekDayRegex})`; - export const WeekDayAndDayRegex = `^[.]`; - export const ThisPrefixRegex = `这个|这一个|这|这一|本|今`; - export const LastPrefixRegex = `上个|上一个|上|上一|去`; - export const NextPrefixRegex = `下个|下一个|下|下一|明`; - export const RelativeRegex = `(?(${ThisPrefixRegex}|${LastPrefixRegex}|${NextPrefixRegex}))`; - export const SpecialDate = `(?(${ThisPrefixRegex}|${LastPrefixRegex}|${NextPrefixRegex})年)?(?(${ThisPrefixRegex}|${LastPrefixRegex}|${NextPrefixRegex})月)?${DateDayRegexInCJK}`; - export const DateUnitRegex = `(?年|个月|周|週|日|天)`; - export const BeforeRegex = `以前|之前|前`; - export const AfterRegex = `以后|以後|之后|之後|后|後|还剩`; - export const TimePeriodLeftRegex = `还剩`; - export const DateRegexList1 = `(${LunarRegex}(\\s*))?(((${SimpleYearRegex}|${DateYearInCJKRegex})年)(\\s*))?${MonthRegex}(\\s*)${DateDayRegexInCJK}((\\s*|,|,)${WeekDayRegex})?`; - export const DateRegexList2 = `(((${SimpleYearRegex}|${DateYearInCJKRegex})年)(\\s*))?(${LunarRegex}(\\s*))?${MonthRegex}(\\s*)${DateDayRegexInCJK}((\\s*|,|,)${WeekDayRegex})?`; - export const DateRegexList3 = `(((${SimpleYearRegex}|${DateYearInCJKRegex})年)(\\s*))?(${LunarRegex}(\\s*))?${MonthRegex}(\\s*)(${DayRegexNumInCJK}|${DayRegex})((\\s*|,|,)${WeekDayRegex})?`; - export const DateRegexList4 = `${MonthNumRegex}\\s*/\\s*${DayRegex}`; - export const DateRegexList5 = `${DayRegex}\\s*/\\s*${MonthNumRegex}`; - export const DateRegexList6 = `${MonthNumRegex}\\s*[/\\\\\\-]\\s*${DayRegex}\\s*[/\\\\\\-]\\s*${SimpleYearRegex}`; - export const DateRegexList7 = `${DayRegex}\\s*[/\\\\\\-\\.]\\s*${MonthNumRegex}\\s*[/\\\\\\-\\.]\\s*${SimpleYearRegex}`; - export const DateRegexList8 = `${SimpleYearRegex}\\s*[/\\\\\\-\\. ]\\s*${MonthNumRegex}\\s*[/\\\\\\-\\. ]\\s*${DayRegex}`; - export const DatePeriodTillRegex = `(?到|至|--|-|—|——|~|–)`; - export const DatePeriodRangeSuffixRegex = `^\\b$`; - export const DatePeriodRangePrefixRegex = `从`; - export const DatePeriodTillSuffixRequiredRegex = `(?与|和)`; - export const DatePeriodDayRegexInCJK = `(?初一|三十|一日|十一日|二十一日|三十一日|二日|三日|四日|五日|六日|七日|八日|九日|十二日|十三日|十四日|十五日|十六日|十七日|十八日|十九日|二十二日|二十三日|二十四日|二十五日|二十六日|二十七日|二十八日|二十九日|一日|十一日|十日|二十一日|二十日|三十一日|三十日|二日|三日|四日|五日|六日|七日|八日|九日|十二日|十三日|十四日|十五日|十六日|十七日|十八日|十九日|二十二日|二十三日|二十四日|二十五日|二十六日|二十七日|二十八日|二十九日|十日|二十日|三十日|10日|11日|12日|13日|14日|15日|16日|17日|18日|19日|1日|20日|21日|22日|23日|24日|25日|26日|27日|28日|29日|2日|30日|31日|3日|4日|5日|6日|7日|8日|9日|一号|十一号|二十一号|三十一号|二号|三号|四号|五号|六号|七号|八号|九号|十二号|十三号|十四号|十五号|十六号|十七号|十八号|十九号|二十二号|二十三号|二十四号|二十五号|二十六号|二十七号|二十八号|二十九号|一号|十一号|十号|二十一号|二十号|三十一号|三十号|二号|三号|四号|五号|六号|七号|八号|九号|十二号|十三号|十四号|十五号|十六号|十七号|十八号|十九号|二十二号|二十三号|二十四号|二十五号|二十六号|二十七号|二十八号|二十九号|十号|二十号|三十号|10号|11号|12号|13号|14号|15号|16号|17号|18号|19号|1号|20号|21号|22号|23号|24号|25号|26号|27号|28号|29号|2号|30号|31号|3号|4号|5号|6号|7号|8号|9号|一|十一|二十一|三十一|二|三|四|五|六|七|八|九|十二|十三|十四|十五|十六|十七|十八|十九|二十二|二十三|二十四|二十五|二十六|二十七|二十八|二十九|一|十一|十|二十一|二十|三十一|三十|二|三|四|五|六|七|八|九|十二|十三|十四|十五|十六|十七|十八|十九|二十二|二十三|二十四|二十五|二十六|二十七|二十八|二十九|十|二十|三十|廿|卅)`; - export const DatePeriodThisRegex = `这个|这一个|这|这一|本`; - export const DatePeriodLastRegex = `上个|上一个|上|上一`; - export const DatePeriodNextRegex = `下个|下一个|下|下一`; - export const RelativeMonthRegex = `(?(${DatePeriodThisRegex}|${DatePeriodLastRegex}|${DatePeriodNextRegex})\\s*月)`; - export const HalfYearRegex = `((?(上|前)半年)|(?(下|后)半年))`; - export const YearRegex = `((${YearNumRegex})(\\s*年)?|(${SimpleYearRegex})\\s*年)${HalfYearRegex}?`; - export const StrictYearRegex = `(${YearRegex}(?=[\\u4E00-\\u9FFF]|\\s|$|\\W))`; - export const YearRegexInNumber = `(?(\\d{4}))`; - export const DatePeriodYearInCJKRegex = `${DateYearInCJKRegex}年${HalfYearRegex}?`; - export const MonthSuffixRegex = `(?(${RelativeMonthRegex}|${MonthRegex}))`; - export const SimpleCasesRegex = `((从)\\s*)?((${YearRegex}|${DatePeriodYearInCJKRegex})\\s*)?${MonthSuffixRegex}(${DatePeriodDayRegexInCJK}|${DayRegex})\\s*${DatePeriodTillRegex}\\s*(${DatePeriodDayRegexInCJK}|${DayRegex})((\\s+|\\s*,\\s*)${YearRegex})?`; - export const YearAndMonth = `(${DatePeriodYearInCJKRegex}|${YearRegex}|(?明年|今年|去年))\\s*(${MonthRegex}|的?(?第一|第二|第三|第四|第五|第六|第七|第八|第九|第十|第十一|第十二|最后一)\\s*个月\\s*)`; - export const SimpleYearAndMonth = `(${YearNumRegex}[/\\\\\\-]${MonthNumRegex}\\b$)`; - export const PureNumYearAndMonth = `(${YearRegexInNumber}\\s*[-\\.\\/]\\s*${MonthNumRegex})|(${MonthNumRegex}\\s*\\/\\s*${YearRegexInNumber})`; - export const OneWordPeriodRegex = `(((?(明|今|去)年)\\s*)?${MonthRegex}|(${DatePeriodThisRegex}|${DatePeriodLastRegex}|${DatePeriodNextRegex})(?半)?\\s*(周末|周|月|年)|周末|(今|明|去|前|后)年(\\s*${HalfYearRegex})?)`; - export const LaterEarlyPeriodRegex = `^[.]`; - export const DatePointWithAgoAndLater = `^[.]`; - export const WeekOfMonthRegex = `(?${MonthSuffixRegex}的(?第一|第二|第三|第四|第五|最后一)\\s*周\\s*)`; - export const WeekOfYearRegex = `(?(${YearRegex}|${RelativeRegex}年)的(?第一|第二|第三|第四|第五|最后一)\\s*周\\s*)`; - export const WeekOfDateRegex = `^[.]`; - export const MonthOfDateRegex = `^[.]`; - export const RestOfDateRegex = `^[.]`; - export const UnitRegex = `(?年|(?(个)?月|周|週|日|天))`; - export const FollowedUnit = `^\\s*${UnitRegex}`; - export const NumberCombinedWithUnit = `(?\\d+(\\.\\d*)?)${UnitRegex}`; - export const DateRangePrepositions = `((从|在|自)\\s*)?`; - export const YearToYear = `(${DateRangePrepositions})(${DatePeriodYearInCJKRegex}|${YearRegex})\\s*(${DatePeriodTillRegex}|后|後|之后|之後)\\s*(${DatePeriodYearInCJKRegex}|${YearRegex})(\\s*((之间|之内|期间|中间|间)|前|之前))?`; - export const YearToYearSuffixRequired = `(${DateRangePrepositions})(${DatePeriodYearInCJKRegex}|${YearRegex})\\s*(${DatePeriodTillSuffixRequiredRegex})\\s*(${DatePeriodYearInCJKRegex}|${YearRegex})\\s*(之间|之内|期间|中间|间)`; - export const MonthToMonth = `(${DateRangePrepositions})(${MonthRegex})${DatePeriodTillRegex}(${MonthRegex})`; - export const MonthToMonthSuffixRequired = `(${DateRangePrepositions})(${MonthRegex})${DatePeriodTillSuffixRequiredRegex}(${MonthRegex})\\s*(之间|之内|期间|中间|间)`; - export const DayToDay = `^[.]`; - export const DayRegexForPeriod = `^[.]`; - export const FirstLastOfYearRegex = `((${DatePeriodYearInCJKRegex}|${YearRegex}|(?明年|今年|去年))的?)((?前)|(?(最后|最後)))`; - export const ComplexDatePeriodRegex = `^[.]`; - export const PastRegex = `(?(之前|前|上|近|过去))`; - export const FutureRegex = `(?(之后|之後|后|後|(?春|夏|秋|冬)(天|季)?`; - export const WhichWeekRegex = `^[.]`; - export const SeasonWithYear = `((${YearRegex}|${DatePeriodYearInCJKRegex}|(?明年|今年|去年))(的)?)?${SeasonRegex}`; - export const QuarterRegex = `((${YearRegex}|${DatePeriodYearInCJKRegex}|(?明年|今年|去年))(的)?)?(第(?1|2|3|4|一|二|三|四)季度)`; - export const CenturyNumRegex = `^[.]`; - export const CenturyRegex = `(?\\d|1\\d|2\\d)世纪`; - export const CenturyRegexInCJK = `(?一|二|三|四|五|六|七|八|九|十|十一|十二|十三|十四|十五|十六|十七|十八|十九|二十|二十一|二十二)世纪`; - export const RelativeCenturyRegex = `(?(${DatePeriodLastRegex}|${DatePeriodThisRegex}|${DatePeriodNextRegex}))世纪`; - export const DecadeRegexInCJK = `(?十|一十|二十|三十|四十|五十|六十|七十|八十|九十)`; - export const DecadeRegex = `(?(${CenturyRegex}|${CenturyRegexInCJK}|${RelativeCenturyRegex}))?(?(\\d0|${DecadeRegexInCJK}))年代`; - export const PrepositionRegex = `(?^的|在$)`; - export const NowRegex = `(?现在|马上|立刻|刚刚才|刚刚|刚才|这会儿|当下|此刻)`; - export const NightRegex = `(?早|晚)`; - export const TimeOfSpecialDayRegex = `(今晚|今早|今晨|明晚|明早|明晨|昨晚)(的|在)?`; - export const DateTimePeriodTillRegex = `(?到|直到|--|-|—|——)`; - export const DateTimePeriodPrepositionRegex = `(?^\\s*的|在\\s*$)`; - export const BeforeAfterRegex = `^\\b$`; - export const HourRegex = `\\b${BaseDateTime.HourRegex}`; - export const HourNumRegex = `(?[零〇一二两三四五六七八九]|二十[一二三四]?|十[一二三四五六七八九]?)`; - export const ZhijianRegex = `^\\s*(之间|之内|期间|中间|间)`; - export const DateTimePeriodThisRegex = `这个|这一个|这|这一`; - export const DateTimePeriodLastRegex = `上个|上一个|上|上一`; - export const DateTimePeriodNextRegex = `下个|下一个|下|下一`; - export const AmPmDescRegex = `(?(am|a\\.m\\.|a m|a\\. m\\.|a\\.m|a\\. m|a m|pm|p\\.m\\.|p m|p\\. m\\.|p\\.m|p\\. m|p m|上午|中午|下午|午后|晚上|夜里|夜晚|夜间|深夜|傍晚|晚|早间?))`; - export const TimeOfDayRegex = `(?凌晨|清晨|早上|早间|早|上午|中午|下午|午后|晚上|夜里|夜晚|半夜|夜间|深夜|傍晚|晚)`; - export const SpecificTimeOfDayRegex = `(((${DateTimePeriodThisRegex}|${DateTimePeriodNextRegex}|${DateTimePeriodLastRegex})\\s+${TimeOfDayRegex})|(今晚|今早|今晨|明晚|明早|明晨|昨晚))`; - export const DateTimePeriodUnitRegex = `(个)?(?(小时|钟头|分钟|秒钟|时|分|秒))`; - export const DateTimePeriodFollowedUnit = `^\\s*${DateTimePeriodUnitRegex}`; - export const DateTimePeriodNumberCombinedWithUnit = `\\b(?\\d+(\\.\\d*)?)${DateTimePeriodUnitRegex}`; - export const DurationAllRegex = `^[.]`; - export const DurationHalfRegex = `^[.]`; - export const DurationRelativeDurationUnitRegex = `^[.]`; - export const AgoLaterRegex = `^[.]`; - export const DurationDuringRegex = `^[.]`; - export const DurationSomeRegex = `^[.]`; - export const DurationMoreOrLessRegex = `^[.]`; - export const DurationYearRegex = `((\\d{3,4})|0\\d|两千)\\s*年`; - export const DurationHalfSuffixRegex = `半`; - export const DurationSuffixList: ReadonlyMap = new Map([["M", "分钟"],["S", "秒钟|秒"],["H", "个小时|小时|个钟头|钟头|时"],["D", "天"],["W", "星期|个星期|周|週"],["Mon", "个月"],["Y", "年"]]); - export const DurationAmbiguousUnits = [ "分钟","秒钟","秒","个小时","小时","天","星期","个星期","周","週","个月","年","时" ]; - export const DurationUnitRegex = `(?${DateUnitRegex}|分钟?|秒钟?|个?小时|时|个?钟头|天|个?星期|周|週|个?月|年)`; - export const AnUnitRegex = `^[.]`; - export const DurationConnectorRegex = `^\\s*(?[多又余零]?)\\s*$`; - export const ConnectorRegex = `^\\s*,\\s*$`; - export const LunarHolidayRegex = `((${YearRegex}|${DatePeriodYearInCJKRegex}|(?明年|今年|去年))(的)?)?(?除夕|春节|中秋节|中秋|元宵节|端午节|端午|重阳节)`; - export const HolidayRegexList1 = `((${YearRegex}|${DatePeriodYearInCJKRegex}|(?明年|今年|去年))(的)?)?(?新年|五一|劳动节|元旦节|元旦|愚人节|平安夜|圣诞节|植树节|国庆节|情人节|教师节|儿童节|妇女节|青年节|建军节|女生节|光棍节|双十一|清明节|清明)`; - export const HolidayRegexList2 = `((${YearRegex}|${DatePeriodYearInCJKRegex}|(?明年|今年|去年))(的)?)?(?母亲节|父亲节|感恩节|万圣节)`; - export const SetUnitRegex = `(?年|月|周|星期|日|天|小时|时|分钟|分|秒钟|秒)`; - export const SetEachUnitRegex = `(?(每个|每一|每)\\s*${SetUnitRegex})`; - export const SetEachPrefixRegex = `(?(每)\\s*$)`; - export const SetEachSuffixRegex = `^[.]`; - export const SetLastRegex = `(?last|this|next)`; - export const SetEachDayRegex = `(每|每一)(天|日)\\s*$`; - export const SetEachDateUnitRegex = `^[.]`; - export const TimeHourNumRegex = `(00|01|02|03|04|05|06|07|08|09|0|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|1|2|3|4|5|6|7|8|9)`; - export const TimeMinuteNumRegex = `(00|01|02|03|04|05|06|07|08|09|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|32|33|34|35|36|37|38|39|40|41|42|43|44|45|46|47|48|49|50|51|52|53|54|55|56|57|58|59|0|1|2|3|4|5|6|7|8|9)`; - export const TimeSecondNumRegex = `(00|01|02|03|04|05|06|07|08|09|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|32|33|34|35|36|37|38|39|40|41|42|43|44|45|46|47|48|49|50|51|52|53|54|55|56|57|58|59|0|1|2|3|4|5|6|7|8|9)`; - export const TimeHourCJKRegex = `([零〇一二两三四五六七八九]|二十[一二三四]?|十[一二三四五六七八九]?)`; - export const TimeMinuteCJKRegex = `([二三四五]?十[一二三四五六七八九]?|六十|[零〇一二三四五六七八九])`; - export const TimeSecondCJKRegex = `${TimeMinuteCJKRegex}`; - export const TimeClockDescRegex = `(点\\s*整|点\\s*钟|点|时)`; - export const TimeMinuteDescRegex = `(分钟|分|)`; - export const TimeSecondDescRegex = `(秒钟|秒)`; - export const TimeBanHourPrefixRegex = `(第)`; - export const TimeHourRegex = `(?${TimeHourCJKRegex}|${TimeHourNumRegex})${TimeClockDescRegex}`; - export const TimeMinuteRegex = `(?${TimeMinuteCJKRegex}|${TimeMinuteNumRegex})${TimeMinuteDescRegex}`; - export const TimeSecondRegex = `(?${TimeSecondCJKRegex}|${TimeSecondNumRegex})${TimeSecondDescRegex}`; - export const TimeHalfRegex = `(?过半|半)`; - export const TimeQuarterRegex = `(?[一两二三四1-4])\\s*(刻钟|刻)`; - export const TimeCJKTimeRegex = `${TimeHourRegex}(${TimeQuarterRegex}|${TimeHalfRegex}|((过|又)?${TimeMinuteRegex})(${TimeSecondRegex})?)?`; - export const TimeDigitTimeRegex = `(?${TimeHourNumRegex}):(?${TimeMinuteNumRegex})(:(?${TimeSecondNumRegex}))?`; - export const TimeDayDescRegex = `(?凌晨|清晨|早上|早间|早|上午|中午|下午|午后|晚上|夜里|夜晚|半夜|午夜|夜间|深夜|傍晚|晚)`; - export const TimeApproximateDescPreffixRegex = `(大[约概]|差不多|可能|也许|约|不超过|不多[于过]|最[多长少]|少于|[超短长多]过|几乎要|将近|差点|快要|接近|至少|起码|超出|不到)`; - export const TimeApproximateDescSuffixRegex = `(左右)`; - export const TimeRegexes1 = `${TimeApproximateDescPreffixRegex}?${TimeDayDescRegex}?${TimeCJKTimeRegex}${TimeApproximateDescSuffixRegex}?`; - export const TimeRegexes2 = `${TimeApproximateDescPreffixRegex}?${TimeDayDescRegex}?${TimeDigitTimeRegex}${TimeApproximateDescSuffixRegex}?(\\s*${AmPmDescRegex}?)`; - export const TimeRegexes3 = `差${TimeMinuteRegex}${TimeCJKTimeRegex}`; - export const TimePeriodTimePeriodConnectWords = `(起|至|到|–|-|—|~|~)`; - export const TimePeriodLeftCJKTimeRegex = `(从)?(?${TimeDayDescRegex}?(${TimeCJKTimeRegex}))`; - export const TimePeriodRightCJKTimeRegex = `${TimePeriodTimePeriodConnectWords}(?${TimeDayDescRegex}?${TimeCJKTimeRegex})(之间)?`; - export const TimePeriodLeftDigitTimeRegex = `(从)?(?${TimeDayDescRegex}?(${TimeDigitTimeRegex}))`; - export const TimePeriodRightDigitTimeRegex = `${TimePeriodTimePeriodConnectWords}(?${TimeDayDescRegex}?${TimeDigitTimeRegex})(之间)?`; - export const TimePeriodShortLeftCJKTimeRegex = `(从)?(?${TimeDayDescRegex}?(${TimeHourCJKRegex}))`; - export const TimePeriodShortLeftDigitTimeRegex = `(从)?(?${TimeDayDescRegex}?(${TimeHourNumRegex}))`; - export const TimePeriodRegexes1 = `(${TimePeriodLeftDigitTimeRegex}${TimePeriodRightDigitTimeRegex}|${TimePeriodLeftCJKTimeRegex}${TimePeriodRightCJKTimeRegex})`; - export const TimePeriodRegexes2 = `(${TimePeriodShortLeftDigitTimeRegex}${TimePeriodRightDigitTimeRegex}|${TimePeriodShortLeftCJKTimeRegex}${TimePeriodRightCJKTimeRegex})`; - export const FromToRegex = `(从|自).+([至到]).+`; - export const AmbiguousRangeModifierPrefix = `(从|自)`; - export const ReferenceDatePeriodRegex = `^[.]`; - export const UnspecificDatePeriodRegex = `^[.]`; - export const ParserConfigurationBefore = `((?和|或|及)?(之前|以前)|前)`; - export const ParserConfigurationAfter = `((?和|或|及)?(之后|之後|以后|以後)|后|後)`; - export const ParserConfigurationUntil = `(直到|直至|截至|截止(到)?)`; - export const ParserConfigurationSincePrefix = `(自从|自|自打|打|从)`; - export const ParserConfigurationSinceSuffix = `(以来|开始|起)`; - export const ParserConfigurationAroundPrefix = `^[.]`; - export const ParserConfigurationAroundSuffix = `^[.]`; - export const ParserConfigurationLastWeekDayRegex = `最后一个`; - export const ParserConfigurationNextMonthRegex = `下一个`; - export const ParserConfigurationLastMonthRegex = `上一个`; - export const ParserConfigurationDatePrefix = ` `; - export const ParserConfigurationUnitMap: ReadonlyMap = new Map([["年", "Y"],["月", "MON"],["个月", "MON"],["日", "D"],["周", "W"],["週", "W"],["天", "D"],["小时", "H"],["个小时", "H"],["时", "H"],["分钟", "M"],["分", "M"],["秒钟", "S"],["秒", "S"],["星期", "W"],["个星期", "W"]]); - export const ParserConfigurationUnitValueMap: ReadonlyMap = new Map([["years", 31536000],["year", 31536000],["months", 2592000],["month", 2592000],["weeks", 604800],["week", 604800],["days", 86400],["day", 86400],["hours", 3600],["hour", 3600],["hrs", 3600],["hr", 3600],["h", 3600],["minutes", 60],["minute", 60],["mins", 60],["min", 60],["seconds", 1],["second", 1],["secs", 1],["sec", 1]]); - export const MonthTerms = [ "月" ]; - export const WeekendTerms = [ "周末" ]; - export const WeekTerms = [ "周","週","星期" ]; - export const YearTerms = [ "年" ]; - export const ThisYearTerms = [ "今年" ]; - export const YearToDateTerms = [ "今年迄今" ]; - export const LastYearTerms = [ "去年" ]; - export const NextYearTerms = [ "明年" ]; - export const YearAfterNextTerms = [ "后年" ]; - export const YearBeforeLastTerms = [ "前年" ]; - export const ParserConfigurationSeasonMap: ReadonlyMap = new Map([["春", "SP"],["夏", "SU"],["秋", "FA"],["冬", "WI"]]); - export const ParserConfigurationSeasonValueMap: ReadonlyMap = new Map([["SP", 3],["SU", 6],["FA", 9],["WI", 12]]); - export const ParserConfigurationCardinalMap: ReadonlyMap = new Map([["1", 1],["2", 2],["3", 3],["4", 4],["5", 5],["一", 1],["二", 2],["三", 3],["四", 4],["五", 5],["第一个", 1],["第二个", 2],["第三个", 3],["第四个", 4],["第五个", 5],["第一", 1],["第二", 2],["第三", 3],["第四", 4],["第五", 5],["第六", 6],["第七", 7],["第八", 8],["第九", 9],["第十", 10],["第十一", 11],["第十二", 12]]); - export const ParserConfigurationDayOfMonth: ReadonlyMap = new Map([["1", 1],["2", 2],["3", 3],["4", 4],["5", 5],["6", 6],["7", 7],["8", 8],["9", 9],["10", 10],["11", 11],["12", 12],["13", 13],["14", 14],["15", 15],["16", 16],["17", 17],["18", 18],["19", 19],["20", 20],["21", 21],["22", 22],["23", 23],["24", 24],["25", 25],["26", 26],["27", 27],["28", 28],["29", 29],["30", 30],["31", 31],["01", 1],["02", 2],["03", 3],["04", 4],["05", 5],["06", 6],["07", 7],["08", 8],["09", 9],["1日", 1],["2日", 2],["3日", 3],["4日", 4],["5日", 5],["6日", 6],["7日", 7],["8日", 8],["9日", 9],["10日", 10],["11日", 11],["12日", 12],["13日", 13],["14日", 14],["15日", 15],["16日", 16],["17日", 17],["18日", 18],["19日", 19],["20日", 20],["21日", 21],["22日", 22],["23日", 23],["24日", 24],["25日", 25],["26日", 26],["27日", 27],["28日", 28],["29日", 29],["30日", 30],["31日", 31],["一日", 1],["十一日", 11],["二十日", 20],["十日", 10],["二十一日", 21],["三十一日", 31],["二日", 2],["三日", 3],["四日", 4],["五日", 5],["六日", 6],["七日", 7],["八日", 8],["九日", 9],["十二日", 12],["十三日", 13],["十四日", 14],["十五日", 15],["十六日", 16],["十七日", 17],["十八日", 18],["十九日", 19],["二十二日", 22],["二十三日", 23],["二十四日", 24],["二十五日", 25],["二十六日", 26],["二十七日", 27],["二十八日", 28],["二十九日", 29],["三十日", 30],["1号", 1],["2号", 2],["3号", 3],["4号", 4],["5号", 5],["6号", 6],["7号", 7],["8号", 8],["9号", 9],["10号", 10],["11号", 11],["12号", 12],["13号", 13],["14号", 14],["15号", 15],["16号", 16],["17号", 17],["18号", 18],["19号", 19],["20号", 20],["21号", 21],["22号", 22],["23号", 23],["24号", 24],["25号", 25],["26号", 26],["27号", 27],["28号", 28],["29号", 29],["30号", 30],["31号", 31],["一号", 1],["十一号", 11],["二十号", 20],["十号", 10],["二十一号", 21],["三十一号", 31],["二号", 2],["三号", 3],["四号", 4],["五号", 5],["六号", 6],["七号", 7],["八号", 8],["九号", 9],["十二号", 12],["十三号", 13],["十四号", 14],["十五号", 15],["十六号", 16],["十七号", 17],["十八号", 18],["十九号", 19],["二十二号", 22],["二十三号", 23],["二十四号", 24],["二十五号", 25],["二十六号", 26],["二十七号", 27],["二十八号", 28],["二十九号", 29],["三十号", 30],["初一", 32],["三十", 30],["一", 1],["十一", 11],["二十", 20],["十", 10],["二十一", 21],["三十一", 31],["二", 2],["三", 3],["四", 4],["五", 5],["六", 6],["七", 7],["八", 8],["九", 9],["十二", 12],["十三", 13],["十四", 14],["十五", 15],["十六", 16],["十七", 17],["十八", 18],["十九", 19],["二十二", 22],["二十三", 23],["二十四", 24],["二十五", 25],["二十六", 26],["二十七", 27],["二十八", 28],["二十九", 29]]); - export const ParserConfigurationDayOfWeek: ReadonlyMap = new Map([["星期一", 1],["星期二", 2],["星期三", 3],["星期四", 4],["星期五", 5],["星期六", 6],["星期天", 0],["星期日", 0],["礼拜一", 1],["礼拜二", 2],["礼拜三", 3],["礼拜四", 4],["礼拜五", 5],["礼拜六", 6],["礼拜天", 0],["礼拜日", 0],["周一", 1],["周二", 2],["周三", 3],["周四", 4],["周五", 5],["周六", 6],["周日", 0],["周天", 0],["禮拜一", 1],["禮拜二", 2],["禮拜三", 3],["禮拜四", 4],["禮拜五", 5],["禮拜六", 6],["禮拜天", 0],["禮拜日", 0],["週一", 1],["週二", 2],["週三", 3],["週四", 4],["週五", 5],["週六", 6],["週日", 0],["週天", 0]]); - export const ParserConfigurationMonthOfYear: ReadonlyMap = new Map([["1", 1],["2", 2],["3", 3],["4", 4],["5", 5],["6", 6],["7", 7],["8", 8],["9", 9],["10", 10],["11", 11],["12", 12],["01", 1],["02", 2],["03", 3],["04", 4],["05", 5],["06", 6],["07", 7],["08", 8],["09", 9],["一月", 1],["二月", 2],["三月", 3],["四月", 4],["五月", 5],["六月", 6],["七月", 7],["八月", 8],["九月", 9],["十月", 10],["十一月", 11],["十二月", 12],["1月", 1],["2月", 2],["3月", 3],["4月", 4],["5月", 5],["6月", 6],["7月", 7],["8月", 8],["9月", 9],["10月", 10],["11月", 11],["12月", 12],["01月", 1],["02月", 2],["03月", 3],["04月", 4],["05月", 5],["06月", 6],["07月", 7],["08月", 8],["09月", 9],["正月", 13],["大年", 13]]); - export const DateTimeSimpleAmRegex = `(?早|晨)`; - export const DateTimeSimplePmRegex = `(?晚)`; - export const DateTimePeriodMORegex = `(凌晨|清晨|早上|早间|早|上午)`; - export const DateTimePeriodMIRegex = `(中午)`; - export const DateTimePeriodAFRegex = `(下午|午后|傍晚)`; - export const DateTimePeriodEVRegex = `(晚上|夜里|夜晚|晚)`; - export const DateTimePeriodNIRegex = `(半夜|夜间|深夜)`; - export const AmbiguityTimeFiltersDict: ReadonlyMap = new Map([["^[.]", "^[.]"]]); - export const AmbiguityTimePeriodFiltersDict: ReadonlyMap = new Map([["^[.]", "^[.]"]]); - export const AmbiguityDateFiltersDict: ReadonlyMap = new Map([["^[.]", "^[.]"]]); - export const AmbiguityDateTimeFiltersDict: ReadonlyMap = new Map([["^[.]", "^[.]"]]); - export const AmbiguityFiltersDict: ReadonlyMap = new Map([["早", "(? = new Map([["Y", 31536000],["Mon", 2592000],["W", 604800],["D", 86400],["H", 3600],["M", 60],["S", 1]]); - export const HolidayNoFixedTimex: ReadonlyMap = new Map([["父亲节", "-06-WXX-6-3"],["母亲节", "-05-WXX-7-2"],["感恩节", "-11-WXX-4-4"]]); - export const MergedBeforeRegex = `(前|之前)$`; - export const MergedAfterRegex = `(后|後|之后|之後)$`; - export const TimeNumberDictionary: ReadonlyMap = new Map([["零", 0],["一", 1],["二", 2],["三", 3],["四", 4],["五", 5],["六", 6],["七", 7],["八", 8],["九", 9],["〇", 0],["两", 2],["十", 10]]); - export const TimeLowBoundDesc: ReadonlyMap = new Map([["中午", 11],["下午", 12],["午后", 12],["晚上", 18],["夜里", 18],["夜晚", 18],["夜间", 18],["深夜", 18],["傍晚", 18],["晚", 18],["pm", 12]]); - export const DefaultLanguageFallback = `YMD`; - export const MorningTermList = [ "早","上午","早间","早上","清晨" ]; - export const MidDayTermList = [ "中午","正午" ]; - export const AfternoonTermList = [ "下午","午后" ]; - export const EveningTermList = [ "晚","晚上","夜里","傍晚","夜晚" ]; - export const DaytimeTermList = [ "白天","日间" ]; - export const NightTermList = [ "深夜" ]; - export const DynastyYearMap: ReadonlyMap = new Map([["贞观", 627],["开元", 713],["神龙", 705],["洪武", 1368],["建文", 1399],["永乐", 1403],["景泰", 1450],["天顺", 1457],["成化", 1465],["嘉靖", 1522],["万历", 1573],["崇祯", 1628],["顺治", 1644],["康熙", 1662],["雍正", 1723],["乾隆", 1736],["嘉庆", 1796],["道光", 1821],["咸丰", 1851],["同治", 1862],["光绪", 1875],["宣统", 1909],["民国", 1912]]); -} diff --git a/JavaScript/packages/recognizers-date-time/src/resources/englishDateTime.ts b/JavaScript/packages/recognizers-date-time/src/resources/englishDateTime.ts deleted file mode 100644 index b8bd4c2bc5..0000000000 --- a/JavaScript/packages/recognizers-date-time/src/resources/englishDateTime.ts +++ /dev/null @@ -1,361 +0,0 @@ -// ------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// ------------------------------------------------------------------------------ - -import { BaseDateTime } from "./baseDateTime"; -export namespace EnglishDateTime { - export const LangMarker = `Eng`; - export const CheckBothBeforeAfter = false; - export const TillRegex = `(?\\b(to|(un)?till?|thru|through)\\b(\\s+the\\b)?|${BaseDateTime.RangeConnectorSymbolRegex})`; - export const RangeConnectorRegex = `(?\\b(and|through|to)\\b(\\s+the\\b)?|${BaseDateTime.RangeConnectorSymbolRegex})`; - export const LastNegPrefix = `(?following|next|(up)?coming|this|${LastNegPrefix}last|past|previous|current|the)\\b`; - export const StrictRelativeRegex = `\\b(?following|next|(up)?coming|this|${LastNegPrefix}last|past|previous|current)\\b`; - export const UpcomingPrefixRegex = `((this\\s+)?((up)?coming))`; - export const NextPrefixRegex = `\\b(following|next|${UpcomingPrefixRegex})\\b`; - export const AfterNextSuffixRegex = `\\b(after\\s+(the\\s+)?next)\\b`; - export const PastPrefixRegex = `((this\\s+)?past)\\b`; - export const PreviousPrefixRegex = `(${LastNegPrefix}last|previous|${PastPrefixRegex})\\b`; - export const ThisPrefixRegex = `(this|current)\\b`; - export const RangePrefixRegex = `(from|between)`; - export const CenturySuffixRegex = `(^century)\\b`; - export const ReferencePrefixRegex = `(that|same)\\b`; - export const FutureSuffixRegex = `\\b((in\\s+the\\s+)?future|hence)\\b`; - export const PastSuffixRegex = `\\b((in\\s+the\\s+)past)\\b`; - export const DayRegex = `(the\\s*)?(?(?:3[0-1]|[1-2]\\d|0?[1-9])(?:th|nd|rd|st)?)(?=\\b|t)`; - export const ImplicitDayRegex = `(the\\s*)?(?(?:3[0-1]|[0-2]?\\d)(?:th|nd|rd|st))\\b`; - export const MonthNumRegex = `(?1[0-2]|(0)?[1-9])\\b`; - export const WrittenOneToNineRegex = `(?:one|two|three|four|five|six|seven|eight|nine)`; - export const WrittenElevenToNineteenRegex = `(?:eleven|twelve|(?:thir|four|fif|six|seven|eigh|nine)teen)`; - export const WrittenTensRegex = `(?:ten|twenty|thirty|fou?rty|fifty|sixty|seventy|eighty|ninety)`; - export const WrittenNumRegex = `(?:${WrittenOneToNineRegex}|${WrittenElevenToNineteenRegex}|${WrittenTensRegex}(\\s+${WrittenOneToNineRegex})?)`; - export const WrittenOneToNineOrdinalRegex = `(?:first|second|third|fourth|fifth|sixth|seventh|eighth|nine?th)`; - export const WrittenTensOrdinalRegex = `(?:tenth|eleventh|twelfth|thirteenth|fourteenth|fifteenth|sixteenth|seventeenth|eighteenth|nineteenth|twentieth|thirtieth|fortieth|fiftieth|sixtieth|seventieth|eightieth|ninetieth)`; - export const WrittenOrdinalRegex = `(?:${WrittenOneToNineOrdinalRegex}|${WrittenTensOrdinalRegex}|${WrittenTensRegex}\\s+${WrittenOneToNineOrdinalRegex})`; - export const WrittenOrdinalDayRegex = `\\b(the\\s+)?(?(?${WrittenOneToNineOrdinalRegex}|(?:tenth|eleventh|twelfth|thirteenth|fourteenth|fifteenth|sixteenth|seventeenth|eighteenth|nineteenth|twentieth|thirtieth)|(?:ten|twenty)\\s+${WrittenOneToNineOrdinalRegex}|thirty\\s+first))\\b`; - export const WrittenCenturyFullYearRegex = `(?:(one|two)\\s+thousand((\\s+and)?\\s+${WrittenOneToNineRegex}\\s+hundred)?)`; - export const WrittenCenturyOrdinalYearRegex = `(?:twenty(\\s+(one|two))?|ten|eleven|twelve|thirteen|fifteen|eighteen|(?:four|six|seven|nine)(teen)?|one|two|three|five|eight)`; - export const CenturyRegex = `\\b(?${WrittenCenturyFullYearRegex}|${WrittenCenturyOrdinalYearRegex}(\\s+hundred)?)\\b`; - export const LastTwoYearNumRegex = `(?:(zero\\s+)?${WrittenOneToNineRegex}|${WrittenElevenToNineteenRegex}|${WrittenTensRegex}(\\s+${WrittenOneToNineRegex})?)`; - export const FullTextYearRegex = `\\b((?${CenturyRegex})(\\s+and)?\\s+(?${LastTwoYearNumRegex})\\b|\\b(?${WrittenCenturyFullYearRegex}|${WrittenCenturyOrdinalYearRegex}\\s+hundred))\\b`; - export const OclockRegex = `(?o\\s*((’|‘|')\\s*)?clock|sharp)`; - export const SpecialDescRegex = `((?)p\\b)`; - export const TasksModeSpecialDescRegex = `([0-9]+((?)p\\b))`; - export const AmDescRegex = `(?:${BaseDateTime.BaseAmDescRegex})`; - export const PmDescRegex = `(:?${BaseDateTime.BasePmDescRegex})`; - export const AmPmDescRegex = `(:?${BaseDateTime.BaseAmPmDescRegex})`; - export const DescRegex = `(:?(:?(${OclockRegex}\\s+)?(?(${AmPmDescRegex}|${AmDescRegex}|${PmDescRegex}|${SpecialDescRegex})))|${OclockRegex})`; - export const OfPrepositionRegex = `(\\bof\\b)`; - export const TwoDigitYearRegex = `\\b(?([0-9]\\d))(?!(\\s*((\\:\\d)|${AmDescRegex}|${PmDescRegex}|\\.\\d)))\\b`; - export const YearRegex = `(?:${BaseDateTime.FourDigitYearRegex}|${FullTextYearRegex})`; - export const WeekDayRegex = `\\b(?(?:sun|mon|tues?|thurs?|fri)(day)?|thu|wedn(esday)?|weds?|sat(urday)?)s?\\b`; - export const SingleWeekDayRegex = `\\b(?(?((day\\s+)?of\\s+)?${RelativeRegex}\\s+month)\\b`; - export const MonthRegexNoWordBoundary = `(?apr(il)?|aug(ust)?|dec(ember)?|feb(ruary)?|jan(uary)?|july?|june?|mar(ch)?|may|nov(ember)?|oct(ober)?|sept(ember)?|sep)(?!\\p{L})`; - export const MonthRegex = `\\b${MonthRegexNoWordBoundary}`; - export const WrittenMonthRegex = `(((the\\s+)?month of\\s+)?${MonthRegex})`; - export const MonthSuffixRegex = `(?(?:(in|of|on)\\s+)?(${RelativeMonthRegex}|${WrittenMonthRegex}))`; - export const DateUnitRegex = `(?(decade|year|(?month|week)|(?(business\\s+|week\\s*))?(?day)|fortnight|weekend)(?s)?|(?<=(^|\\s)\\d{1,4})[ymwd])\\b`; - export const DateTokenPrefix = `on `; - export const TimeTokenPrefix = `at `; - export const TokenBeforeDate = `on `; - export const TokenBeforeTime = `at `; - export const HalfTokenRegex = `^(half)`; - export const QuarterTokenRegex = `^((a\\s+)?quarter)`; - export const ThreeQuarterTokenRegex = `^(three\\s+quarters?)`; - export const ToTokenRegex = `\\b(to)$`; - export const FromRegex = `\\b(from(\\s+the)?)$`; - export const BetweenTokenRegex = `\\b(between(\\s+the)?)$`; - export const SimpleCasesRegex = `\\b(${RangePrefixRegex}\\s+)?(${DayRegex}|${WrittenOrdinalDayRegex})\\s*${TillRegex}\\s*((${DayRegex}|${WrittenOrdinalDayRegex})\\s+${MonthSuffixRegex}|${MonthSuffixRegex}\\s+(${DayRegex}|${WrittenOrdinalDayRegex}))((\\s+|\\s*,\\s*)${YearRegex})?\\b`; - export const MonthFrontSimpleCasesRegex = `\\b(${RangePrefixRegex}\\s+)?${MonthSuffixRegex}\\s+((from)\\s+)?(${DayRegex}|${WrittenOrdinalDayRegex})\\s*${TillRegex}\\s*(${DayRegex}|${WrittenOrdinalDayRegex})((\\s+|\\s*,\\s*)${YearRegex})?\\b`; - export const MonthFrontBetweenRegex = `\\b${MonthSuffixRegex}\\s+(between\\s+)(${DayRegex}|${WrittenOrdinalDayRegex})\\s*${RangeConnectorRegex}\\s*(${DayRegex}|${WrittenOrdinalDayRegex})((\\s+|\\s*,\\s*)${YearRegex})?\\b`; - export const BetweenRegex = `\\b(between\\s+)(${DayRegex}|${WrittenOrdinalDayRegex})\\s*${RangeConnectorRegex}\\s*(${DayRegex}|${WrittenOrdinalDayRegex})\\s+${MonthSuffixRegex}((\\s+|\\s*,\\s*)${YearRegex})?\\b`; - export const MonthWithYear = `\\b(((${WrittenMonthRegex}[\\.]?|((the\\s+)?(?first|1st|second|2nd|third|3rd|fourth|4th|fifth|5th|sixth|6th|seventh|7th|eighth|8th|ninth|9th|tenth|10th|eleventh|11th|twelfth|12th|last)\\s+month(?=\\s+(of|in))))((\\s*)[/\\\\\\-\\.,]?(\\s+(of|in))?(\\s*)(${YearRegex}|(?following|next|last|this)\\s+year)|\\s+(of|in)\\s+${TwoDigitYearRegex}))|((${YearRegex}|(?following|next|last|this)\\s+year)(\\s*),?(\\s*)${WrittenMonthRegex}))\\b`; - export const SpecialYearPrefixes = `(calendar|(?fiscal|school))`; - export const OneWordPeriodRegex = `\\b((((the\\s+)?month of\\s+)?(${StrictRelativeRegex}\\s+)?${MonthRegex})|(month|year) to date|(?((un)?till?|to)\\s+date)|(${RelativeRegex}\\s+)?(my\\s+)?((?working\\s+week|workweek)|week(end)?|month|fortnight|((${SpecialYearPrefixes}\\s+)?year))(?!((\\s+of)?\\s+\\d+(?!(${BaseDateTime.BaseAmDescRegex}|${BaseDateTime.BasePmDescRegex}))|\\s+to\\s+date))(\\s+${AfterNextSuffixRegex})?)\\b`; - export const MonthNumWithYear = `\\b((${BaseDateTime.FourDigitYearRegex}(\\s*)[/\\-\\.](\\s*)${MonthNumRegex})|(${MonthNumRegex}(\\s*)[/\\-](\\s*)${BaseDateTime.FourDigitYearRegex}))\\b`; - export const WeekOfMonthRegex = `\\b(?(the\\s+)?(?first|1st|second|2nd|third|3rd|fourth|4th|fifth|5th|last)\\s+week\\s+${MonthSuffixRegex}(\\s+${BaseDateTime.FourDigitYearRegex}|${RelativeRegex}\\s+year)?)\\b`; - export const WeekOfYearRegex = `\\b(?(the\\s+)?(?first|1st|second|2nd|third|3rd|fourth|4th|fifth|5th|last)\\s+week(\\s+of)?\\s+(${YearRegex}|${RelativeRegex}\\s+year))\\b`; - export const OfYearRegex = `\\b((of|in)\\s+(${YearRegex}|${StrictRelativeRegex}\\s+year))\\b`; - export const FirstLastRegex = `\\b(the\\s+)?((?first)|(?last))\\b`; - export const FollowedDateUnit = `^\\s*${DateUnitRegex}`; - export const NumberCombinedWithDateUnit = `\\b(?\\d+(\\.\\d*)?)${DateUnitRegex}`; - export const QuarterTermRegex = `\\b(((?first|1st|second|2nd|third|3rd|fourth|4th)[ -]+quarter)|(q(?[1-4])))\\b`; - export const RelativeQuarterTermRegex = `\\b(?${StrictRelativeRegex})\\s+((?[\\w,]+)\\s+)?quarters?\\b`; - export const QuarterRegex = `((the\\s+)?${QuarterTermRegex}(?:((\\s+of)?\\s+|\\s*[,-]\\s*)(${YearRegex}|${RelativeRegex}\\s+year))?)|${RelativeQuarterTermRegex}`; - export const QuarterRegexYearFront = `(?:${YearRegex}|${RelativeRegex}\\s+year)('s)?(?:\\s*-\\s*|\\s+(the\\s+)?)?${QuarterTermRegex}`; - export const HalfYearTermRegex = `(?first|1st|second|2nd)\\s+half`; - export const HalfYearFrontRegex = `(?((1[5-9]|20)\\d{2})|2100)(\\s*-\\s*|\\s+(the\\s+)?)?h(?[1-2])`; - export const HalfYearBackRegex = `(the\\s+)?(h(?[1-2])|(${HalfYearTermRegex}))(\\s+of|\\s*,\\s*)?\\s+(${YearRegex})`; - export const HalfYearRelativeRegex = `(the\\s+)?${HalfYearTermRegex}(\\s+of|\\s*,\\s*)?\\s+(${RelativeRegex}\\s+year)`; - export const AllHalfYearRegex = `(${HalfYearFrontRegex})|(${HalfYearBackRegex})|(${HalfYearRelativeRegex})`; - export const EarlyPrefixRegex = `\\b(?early|beginning of|start of|(?earlier(\\s+in)?))\\b`; - export const MidPrefixRegex = `\\b(?mid-?|middle of)\\b`; - export const LaterPrefixRegex = `\\b(?late|end of|(?later(\\s+in)?))\\b`; - export const PrefixPeriodRegex = `(${EarlyPrefixRegex}|${MidPrefixRegex}|${LaterPrefixRegex})`; - export const PrefixDayRegex = `\\b((?earl(y|ier))|(?mid(dle)?)|(?later?))(\\s+in)?(\\s+the\\s+day)?$`; - export const SeasonDescRegex = `(?spring|summer|fall|autumn|winter)`; - export const SeasonRegex = `\\b(?(${PrefixPeriodRegex}\\s+)?(${RelativeRegex}\\s+)?${SeasonDescRegex}((\\s+of|\\s*,\\s*)?\\s+(${YearRegex}|${RelativeRegex}\\s+year))?)\\b`; - export const WhichWeekRegex = `\\b(week)(\\s*)(?5[0-3]|[1-4]\\d|0?[1-9])(\\s+of\\s+(${YearRegex}|${RelativeRegex}\\s+year))?\\b`; - export const WeekOfRegex = `(the\\s+)?((week)(\\s+(of|(commencing|starting|beginning)(\\s+on)?))|w/c)(\\s+the)?`; - export const MonthOfRegex = `(month)(\\s*)(of)`; - export const DateYearRegex = `(?${BaseDateTime.FourDigitYearRegex}|(?(3[0-1]|[0-2]?\\d)(?:th|nd|rd|st))s?)\\b`; - export const PrefixWeekDayRegex = `(\\s*((,?\\s*on)|[-—–]))`; - export const ThisRegex = `\\b(this(\\s*week${PrefixWeekDayRegex}?)?\\s*${WeekDayRegex})|(${WeekDayRegex}((\\s+of)?\\s+this\\s*week))\\b`; - export const LastDateRegex = `\\b(${PreviousPrefixRegex}(\\s*week${PrefixWeekDayRegex}?)?\\s*${WeekDayRegex})|(${WeekDayRegex}(\\s+(of\\s+)?last\\s*week))\\b`; - export const NextDateRegex = `\\b(${NextPrefixRegex}(\\s*week${PrefixWeekDayRegex}?)?\\s*${WeekDayRegex})|((on\\s+)?${WeekDayRegex}((\\s+of)?\\s+(the\\s+following|(the\\s+)?next)\\s*week))\\b`; - export const SpecialDayRegex = `\\b((the\\s+)?day before yesterday|(the\\s+)?day after (tomorrow|tmrw?)|the\\s+day\\s+(before|after)(?!=\\s+day)|((the\\s+)?(${RelativeRegex}|my)\\s+day)|yesterday|tomorrow|tmrw?|today|otd|current date)\\b`; - export const SpecialDayWithNumRegex = `\\b((?${WrittenNumRegex})\\s+days?\\s+from\\s+(?yesterday|tomorrow|tmrw?|today|current date))\\b`; - export const RelativeDayRegex = `\\b(((the\\s+)?${RelativeRegex}\\s+day))\\b`; - export const SetWeekDayRegex = `\\b(?on\\s+)?(?morning|afternoon|evening|night|(sun|mon|tues|wednes|thurs|fri|satur)day)s\\b`; - export const WeekDayOfMonthRegex = `(?(the\\s+)?(?first|1st|second|2nd|third|3rd|fourth|4th|fifth|5th|last)\\s+(week\\s+${MonthSuffixRegex}[\\.]?\\s+(on\\s+)?${WeekDayRegex}|${WeekDayRegex}\\s+${MonthSuffixRegex}))`; - export const RelativeWeekDayRegex = `\\b(${WrittenNumRegex}\\s+${WeekDayRegex}\\s+(from\\s+now|later))\\b`; - export const SpecialDate = `(?=\\b(on|at)\\s+the\\s+)${DayRegex}\\b`; - export const DatePreposition = `\\b(on|in)`; - export const DateExtractorYearTermRegex = `(\\s+|\\s*[/\\\\.,-]\\s*|\\s+of\\s+)${DateYearRegex}`; - export const DayPrefix = `\\b(${WeekDayRegex}|${SpecialDayRegex})\\b`; - export const DateExtractor1 = `\\b(${DayPrefix}\\s*[,-]?\\s*)?((${MonthRegex}[\\.]?\\s*[/\\\\.,-]?\\s*${DayRegex})|(\\(${MonthRegex}\\s*[-./]\\s*${DayRegex}\\)))(?!\\s*\\-\\s*\\d{2}\\b)(\\s*\\(\\s*${DayPrefix}\\s*\\))?(${DateExtractorYearTermRegex}\\b)?`; - export const DateExtractor3 = `\\b(${DayPrefix}(\\s+|\\s*,\\s*))?(${DayRegex}?[\\.]?(\\s+|\\s*[-,/]\\s*|\\s+of\\s+|\\s*)(\\b)?${MonthRegexNoWordBoundary}[\\.]?((\\s+in)?${DateExtractorYearTermRegex})?|${BaseDateTime.FourDigitYearRegex}\\s*[-./]?\\s*(the\\s+)?(?(?:3[0-1]|[1-2]\\d|0?[1-9])(?:th|nd|rd|st)?)[\\.]?(\\s+|\\s*[-,/]\\s*|\\s+of\\s+)${MonthRegex}[\\.]?)\\b`; - export const DateExtractor4 = `\\b${MonthNumRegex}\\s*[/\\\\\\-]\\s*${DayRegex}[\\.]?\\s*[/\\\\\\-]\\s*${DateYearRegex}`; - export const DateExtractor5 = `\\b(${DayPrefix}(\\s*,)?\\s+)?${DayRegex}\\s*[/\\\\\\-\\.]\\s*(${MonthNumRegex}|${MonthRegex})\\s*[/\\\\\\-\\.]\\s*${DateYearRegex}(?!\\s*[/\\\\\\-\\.]\\s*\\d+)`; - export const DateExtractor6 = `(?<=${DatePreposition}\\s+)(${StrictRelativeRegex}\\s+)?(${DayPrefix}\\s+)?${MonthNumRegex}[\\-\\.]${DayRegex}(?![%])${BaseDateTime.CheckDecimalRegex}\\b`; - export const DateExtractor7L = `\\b(${DayPrefix}(\\s*,)?\\s+)?${MonthNumRegex}\\s*/\\s*${DayRegex}${DateExtractorYearTermRegex}(?![%])\\b`; - export const DateExtractor7S = `\\b(${DayPrefix}(\\s*,)?\\s+)?${MonthNumRegex}\\s*/\\s*${DayRegex}(?![%])${BaseDateTime.CheckDecimalRegex}\\b`; - export const DateExtractor8 = `(?<=${DatePreposition}\\s+)(${StrictRelativeRegex}\\s+)?(${DayPrefix}\\s+)?${DayRegex}[\\\\\\-]${MonthNumRegex}(?![%])${BaseDateTime.CheckDecimalRegex}\\b`; - export const DateExtractor9L = `\\b(${DayPrefix}(\\s*,)?\\s+)?${DayRegex}\\s*/\\s*${MonthNumRegex}${DateExtractorYearTermRegex}(?![%])\\b`; - export const DateExtractor9S = `\\b(${DayPrefix}(\\s*,)?\\s+)?${DayRegex}\\s*/\\s*${MonthNumRegex}${BaseDateTime.CheckDecimalRegex}(?![%])\\b`; - export const DateExtractorNoSep = `\\b((?((1\\d|20)\\d{2})|2100)(\\s+(?1[0-2]|(0)?[1-9])\\s+(?(?:3[0-1]|[1-2]\\d|0?[1-9]))|(?1[0-2]|(0)?[1-9])(?(?:3[0-1]|[1-2]\\d|0?[1-9])))\\b)`; - export const DateExtractorA = `\\b(${DayPrefix}(\\s*,)?\\s+)?((${BaseDateTime.FourDigitYearRegex}\\s*[/\\\\\\-\\.]\\s*(${MonthNumRegex}|${MonthRegex})\\s*[/\\\\\\-\\.]\\s*${DayRegex})|(${MonthRegex}\\s*[/\\\\\\-\\.]\\s*${BaseDateTime.FourDigitYearRegex}\\s*[/\\\\\\-\\.]\\s*(the\\s+)?(?(?:3[0-1]|[1-2]\\d|0?[1-9])(?:th|nd|rd|st)?))|(${DayRegex}\\s*[/\\\\\\-\\.]\\s*${BaseDateTime.FourDigitYearRegex}\\s*[/\\\\\\-\\.]\\s*${MonthRegex})|${DateExtractorNoSep})`; - export const OfMonth = `^(\\s*(day\\s+)?of)?\\s*${MonthRegex}`; - export const MonthEnd = `${MonthRegex}\\s*(the)?\\s*$`; - export const WeekDayEnd = `(this\\s+)?${WeekDayRegex}\\s*,?\\s*$`; - export const WeekDayStart = `^\\s+(on\\s+)?${WeekDayRegex}\\b`; - export const RangeUnitRegex = `\\b(?years?|months?|weeks?|fortnights?)\\b`; - export const HourNumRegex = `\\b(?zero|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)\\b`; - export const MinuteNumRegex = `(((?twenty|thirty|fou?rty|fifty)(\\s*-?\\s*))?(?one|two|three|four|five|six|seven|eight|nine)|(?ten|eleven|twelve|thirteen|fifteen|eighteen|(four|six|seven|nine)(teen)|twenty|thirty|forty|fifty))`; - export const DeltaMinuteNumRegex = `(((?twenty|thirty|fou?rty|fifty)(\\s*-?\\s*))?(?one|two|three|four|five|six|seven|eight|nine)|(?ten|eleven|twelve|thirteen|fifteen|eighteen|(four|six|seven|nine)(teen)|twenty|thirty|forty|fifty))`; - export const PmRegex = `(?(((?:at|in|around|circa|on|for)\\s+(the\\s+)?)?(((early|late)\\s+)?(afternoon|evening)|midnight|lunchtime))|((at|in|around|on|for)\\s+(the\\s+)?night))`; - export const PmRegexFull = `(?((?:at|in|around|circa|on|for)\\s+(the\\s+)?)?(((early|late)\\s+)?(afternoon|evening)|(mid)?night|lunchtime))`; - export const AmRegex = `(?((?:at|in|around|circa|on|for)\\s+(the\\s+)?)?((early|late)\\s+)?(morning))`; - export const LunchRegex = `\\blunchtime\\b`; - export const NightRegex = `\\b(mid)?night\\b`; - export const CommonDatePrefixRegex = `^[\\.]`; - export const LessThanOneHour = `(?(a\\s+)?quarter|three quarter(s)?|half( an hour)?|${BaseDateTime.DeltaMinuteRegex}(\\s+(minutes?|mins?)|(?=\\s+past))|${DeltaMinuteNumRegex}(\\s+(minutes?|mins?)|(?=\\s+past)))`; - export const WrittenTimeRegex = `(?${HourNumRegex}\\s+${MinuteNumRegex}(\\s+(minutes?|mins?))?)`; - export const TimePrefix = `(?${LessThanOneHour}\\s+(past|to))`; - export const TimeSuffix = `(?${AmRegex}|${PmRegex}|${OclockRegex})`; - export const TimeSuffixFull = `(?${AmRegex}|${PmRegexFull}|${OclockRegex})`; - export const BasicTime = `\\b(?${WrittenTimeRegex}|${HourNumRegex}|${BaseDateTime.HourRegex}:${BaseDateTime.MinuteRegex}(:${BaseDateTime.SecondRegex})?|${BaseDateTime.HourRegex}(?![%\\d]))`; - export const MidnightRegex = `(?mid\\s*(-\\s*)?night)`; - export const MidmorningRegex = `(?mid\\s*(-\\s*)?morning)`; - export const MidafternoonRegex = `(?mid\\s*(-\\s*)?afternoon)`; - export const MiddayRegex = `(?mid\\s*(-\\s*)?day|((12\\s)?noon))`; - export const MidTimeRegex = `(?(${MidnightRegex}|${MidmorningRegex}|${MidafternoonRegex}|${MiddayRegex}))`; - export const AtRegex = `\\b(?:(?:(?<=\\b(at|(at)?\\s*around|circa)\\s+)(?:${WrittenTimeRegex}|${HourNumRegex}|${BaseDateTime.HourRegex}(?!\\.\\d)(\\s*((?a)|(?p)))?|${MidTimeRegex}))|${MidTimeRegex})\\b`; - export const IshRegex = `\\b(${BaseDateTime.HourRegex}(-|——)?ish|noon(ish)?)\\b`; - export const TimeUnitRegex = `([^a-z]{1,}|\\b)(?(h(ou)?r|min(ute)?|sec(ond)?)(?s)?|h)\\b`; - export const RestrictedTimeUnitRegex = `(?hour|minute)\\b`; - export const FivesRegex = `(?(?:fifteen|(?:twen|thir|fou?r|fif)ty(\\s*five)?|ten|five))\\b`; - export const HourRegex = `\\b${BaseDateTime.HourRegex}`; - export const PeriodHourNumRegex = `\\b(?twenty(\\s+(one|two|three|four))?|eleven|twelve|thirteen|fifteen|eighteen|(four|six|seven|nine)(teen)?|zero|one|two|three|five|eight|ten)\\b`; - export const ConnectNumRegex = `\\b${BaseDateTime.HourRegex}(?[0-5][0-9])\\s*${DescRegex}`; - export const TimeRegexWithDotConnector = `(${BaseDateTime.HourRegex}(\\s*\\.\\s*)${BaseDateTime.MinuteRegex})`; - export const TimeRegex1 = `\\b(${TimePrefix}\\s+)?(${WrittenTimeRegex}|${HourNumRegex}|${BaseDateTime.HourRegex})(\\s*|[.])${DescRegex}`; - export const TimeRegex2 = `(\\b${TimePrefix}\\s+)?(t)?${BaseDateTime.HourRegex}(\\s*)?:(\\s*)?${BaseDateTime.MinuteRegex}((\\s*)?:(\\s*)?${BaseDateTime.SecondRegex})?(?a)?((\\s*${DescRegex})|\\b)`; - export const TimeRegex3 = `(\\b${TimePrefix}\\s+)?${BaseDateTime.HourRegex}\\.${BaseDateTime.MinuteRegex}(\\s*${DescRegex})`; - export const TimeRegex4 = `\\b${TimePrefix}\\s+${BasicTime}(\\s*${DescRegex})?\\s+${TimeSuffix}\\b`; - export const TimeRegex5 = `\\b${TimePrefix}\\s+${BasicTime}((\\s*${DescRegex})|\\b)`; - export const TimeRegex6 = `(${BasicTime})(\\s*${DescRegex})?\\s+${TimeSuffix}\\b`; - export const TimeRegex7 = `\\b${TimeSuffixFull}\\s+(at\\s+)?${BasicTime}((\\s*${DescRegex})|\\b)`; - export const TimeRegex8 = `.^`; - export const TimeRegex9 = `\\b${PeriodHourNumRegex}(\\s+|-)${FivesRegex}((\\s*${DescRegex})|\\b)`; - export const TimeRegex10 = `\\b(${TimePrefix}\\s+)?${BaseDateTime.HourRegex}(\\s*h\\s*)${BaseDateTime.MinuteRegex}(\\s*${DescRegex})?`; - export const TimeRegex11 = `\\b((?:(${TimeTokenPrefix})?${TimeRegexWithDotConnector}(\\s*${DescRegex}))|(?:(?:${TimeTokenPrefix}${TimeRegexWithDotConnector})(?!\\s*per\\s*cent|%)))`; - export const FirstTimeRegexInTimeRange = `\\b${TimeRegexWithDotConnector}(\\s*${DescRegex})?`; - export const PureNumFromTo = `(${RangePrefixRegex}\\s+)?(${HourRegex}|${PeriodHourNumRegex})(\\s*(?${DescRegex}))?\\s*${TillRegex}\\s*(${HourRegex}|${PeriodHourNumRegex})(?\\s*(${PmRegex}|${AmRegex}|${DescRegex}))?`; - export const PureNumBetweenAnd = `(between\\s+)((${BaseDateTime.TwoDigitHourRegex}${BaseDateTime.TwoDigitMinuteRegex})|${HourRegex}|${PeriodHourNumRegex})(\\s*(?${DescRegex}))?\\s*${RangeConnectorRegex}\\s*((${BaseDateTime.TwoDigitHourRegex}${BaseDateTime.TwoDigitMinuteRegex})|${HourRegex}|${PeriodHourNumRegex})(?\\s*(${PmRegex}|${AmRegex}|${DescRegex}))?`; - export const SpecificTimeFromTo = `(${RangePrefixRegex}\\s+)?(?((${TimeRegex2}|${FirstTimeRegexInTimeRange})|(${HourRegex}|${PeriodHourNumRegex})(\\s*(?${DescRegex}))?))\\s*${TillRegex}\\s*(?((${TimeRegex2}|${TimeRegexWithDotConnector}(?\\s*${DescRegex}))|(${HourRegex}|${PeriodHourNumRegex})(\\s*(?${DescRegex}))?))`; - export const SpecificTimeBetweenAnd = `(between\\s+)(?((${TimeRegex2}|${FirstTimeRegexInTimeRange})|(${HourRegex}|${PeriodHourNumRegex})(\\s*(?${DescRegex}))?))\\s*${RangeConnectorRegex}\\s*(?((${TimeRegex2}|${TimeRegexWithDotConnector}(?\\s*${DescRegex}))|(${HourRegex}|${PeriodHourNumRegex})(\\s*(?${DescRegex}))?))`; - export const SuffixAfterRegex = `\\b(((at)\\s)?(or|and)\\s+(above|after|later|greater)(?!\\s+than))\\b`; - export const PrepositionRegex = `(?^(,\\s*)?(at|on|of)(\\s+the)?$)`; - export const LaterEarlyRegex = `((?earl(y|ier)(\\s+|-))|(?late(r?\\s+|-)))`; - export const MealTimeRegex = `\\b(at\\s+)?(?breakfast|brunch|lunch(\\s*time)?|dinner(\\s*time)?|supper)\\b`; - export const UnspecificTimePeriodRegex = `(${MealTimeRegex})`; - export const TimeOfDayRegex = `\\b(?((((in\\s+the\\s+)${LaterEarlyRegex}?(morning|afternoon|night(-?time)?|evening)s)|((in\\s+the\\s+)?${LaterEarlyRegex}?(in(\\s+the)?\\s+)?(morning|afternoon|night(-?time)?|evening)))|${MealTimeRegex}|(((in\\s+(the)?\\s+)?)(daytime|business\\s+hours?))))\\b`; - export const SpecificTimeOfDayRegex = `\\b((${StrictRelativeRegex}\\s+${TimeOfDayRegex})\\b|\\b(?toni(ght|te)))s?\\b`; - export const TimeFollowedUnit = `^\\s*${TimeUnitRegex}`; - export const TimeNumberCombinedWithUnit = `\\b(?\\d+(\\.\\d*)?)${TimeUnitRegex}`; - export const BusinessHourSplitStrings = [ "business","hour" ]; - export const NowRegex = `\\b(?(right\\s+)?now|as\\s+soon\\s+as\\s+possible|asap|recently|previously|at\\s+(present|this\\s+time|th(e|is)\\s+minute|the\\s+(moment|present\\s+time)))\\b`; - export const NowParseRegex = `\\b(${NowRegex}|^(date)$)\\b`; - export const SuffixRegex = `^\\s*(in the\\s+)?(morning|afternoon|evening|night)\\b`; - export const NonTimeContextTokens = `(building)`; - export const DateTimeTimeOfDayRegex = `\\b(?morning|(?afternoon|night|evening))\\b`; - export const DateTimeSpecificTimeOfDayRegex = `\\b((${RelativeRegex}\\s+${DateTimeTimeOfDayRegex})\\b|\\btoni(ght|te))\\b`; - export const TimeOfTodayAfterRegex = `^\\s*(,\\s*)?(in\\s+)?${DateTimeSpecificTimeOfDayRegex}`; - export const TimeOfTodayBeforeRegex = `${DateTimeSpecificTimeOfDayRegex}(\\s*,)?(\\s+(at|around|circa|in|on))?\\s*$`; - export const SimpleTimeOfTodayAfterRegex = `(?(?tonight))))\\b`; - export const PeriodSpecificTimeOfDayRegex = `\\b(${LaterEarlyRegex}?this\\s+${DateTimeTimeOfDayRegex}|(${StrictRelativeRegex}\\s+${PeriodTimeOfDayRegex})\\b|\\b(?toni(ght|te)))\\b`; - export const PeriodTimeOfDayWithDateRegex = `\\b((${PeriodTimeOfDayRegex}(\\s+(on|of))?))\\b`; - export const TasksmodeMealTimeofDayRegex = `\\b((in\\s+(the)?\\s+)?((?earl(y|ier)(\\s+|-))|(?late(r?\\s+|-)))?((this\\s+)?\\b(?lunch(\\s*time)?|dinner(\\s*time)?|brunch|breakfast)\\b))\\b`; - export const LessThanRegex = `\\b(less\\s+than)\\b`; - export const MoreThanRegex = `\\b(more\\s+than)\\b`; - export const DurationUnitRegex = `(?${DateUnitRegex}|h(ou)?rs?|h|min(ute)?s?|sec(ond)?s?|nights?)\\b`; - export const SuffixAndRegex = `(?\\s*(and)\\s+(an?\\s+)?(?half|quarter))`; - export const PeriodicRegex = `\\b(?((?semi|bi|tri)(\\s*|-))?(daily|monthly|weekly|quarterly|yearly|annual(ly)?))\\b`; - export const EachUnitRegex = `\\b(?(every|(each|any|once an|one a|once a)\\s?)(?\\s+(other|alternate|second))?\\s*(${DurationUnitRegex}|(?quarters?|weekends?)|${WeekDayRegex})|(?weekends))`; - export const EachPrefixRegex = `\\b(?(each|every|once an?)\\s*$)`; - export const SetEachRegex = `\\b(?(each|every)(?\\s+(other|alternate))?\\s*)(?!the|that)\\b`; - export const SetLastRegex = `(?following|next|upcoming|this|${LastNegPrefix}last|past|previous|current)`; - export const EachDayRegex = `^\\s*(each|every)\\s*day\\b`; - export const DurationFollowedUnit = `(^\\s*${DurationUnitRegex}\\s+${SuffixAndRegex})|(^\\s*${SuffixAndRegex}?(\\s+|-)?${DurationUnitRegex})`; - export const NumberCombinedWithDurationUnit = `\\b(?\\d+(\\.\\d*)?)(-)?${DurationUnitRegex}`; - export const AnUnitRegex = `(\\b((?(half)\\s+)?an?|another)|(?(1/2|½|half)))\\s+${DurationUnitRegex}`; - export const DuringRegex = `\\b(for|during)\\s+the\\s+(?year|month|week|day|fortnight)\\b`; - export const AllRegex = `\\b(?(all|full|whole)(\\s+|-)(?year|month|week|day|fortnight))\\b`; - export const HalfRegex = `((an?\\s*)|\\b)(?half\\s+(?year|month|week|fortnight|day|hour))\\b`; - export const ConjunctionRegex = `\\b((and(\\s+for)?)|with)\\b`; - export const HolidayList1 = `(?mardi gras|(washington|mao)'s birthday|juneteenth|(jubilee|freedom)(\\s+day)|chinese new year|(new\\s+(years'|year\\s*'s|years?)\\s+eve)|(new\\s+(years'|year\\s*'s|years?)(\\s+day)?)|may\\s*day|yuan dan|christmas eve|(christmas|xmas)(\\s+day)?|black friday|yuandan|easter(\\s+(sunday|saturday|monday))?|clean monday|ash wednesday|palm sunday|maundy thursday|good friday|white\\s+(sunday|monday)|trinity sunday|pentecost|corpus christi|cyber monday)`; - export const HolidayList2 = `(?(thanks\\s*giving|all saint's|white lover|s(?:ain)?t?(\\.)?\\s+(?:patrick|george)(?:')?(?:s)?|us independence|all hallow|all souls|guy fawkes|cinco de mayo|halloween|qingming|dragon boat|april fools|tomb\\s*sweeping)(\\s+day)?)`; - export const HolidayList3 = `(?(?:independence|presidents(?:')?|mlk|martin luther king( jr)?|canberra|ascension|columbus|tree( planting)?|arbor|labou?r|((international|int'?l)\\s+)?workers'?|mother'?s?|father'?s?|female|women('s)?|single|teacher'?s|youth|children|girls|lovers?|earth|inauguration|groundhog|valentine'?s|baptiste|bastille|veterans(?:')?|memorial|mid[ \\-]autumn|moon|spring|lantern)\\s+day)`; - export const HolidayList4 = `(?ramad(h)?an|ram(a)?zan|ramathan|eid al(-|\\s+)adha|eid al(-|\\s+)azha|eidul(-|\\s+)azha|feast of the sacrifice|(islamic|arabic|hijri) new year|eid al(-|\\s+)fitr|festival of breaking the fast)`; - export const HolidayRegex = `\\b((${StrictRelativeRegex}\\s+(${HolidayList1}|${HolidayList2}|${HolidayList3}|${HolidayList4}))|(?((the\\s+)?weekend\\s+of\\s+)(${HolidayList1}|${HolidayList2}|${HolidayList3}|${HolidayList4})(\\s+((of\\s+)?(${YearRegex}|${RelativeRegex}\\s+year)))?)|((${HolidayList1}|${HolidayList2}|${HolidayList3}|${HolidayList4})((?(\\s+weekend)(\\s+((of\\s+)?(${YearRegex}|${RelativeRegex}\\s+year)))?)|(\\s+(of\\s+)?(${YearRegex}|${RelativeRegex}\\s+year)(?\\s+weekend)?))?))\\b`; - export const TasksModeHolidayListSupression = `(?(?:independence|teacher'?s|youth|children|girls)\\s+day)|(?ramad(h)?an|ram(a)?zan|ramathan|eid al(-|\\s+)adha|eid al(-|\\s+)azha|eidul(-|\\s+)azha|feast of the sacrifice|(islamic|arabic|hijri) new year|eid al(-|\\s+)fitr|festival of breaking the fast)\\b`; - export const AMTimeRegex = `(?morning)`; - export const PMTimeRegex = `\\b(?afternoon|evening|night)\\b`; - export const NightTimeRegex = `(night)`; - export const NowTimeRegex = `(now|at\\s+(present|this\\s+time|th(e|is)\\s+minute|the\\s+(moment|(current|present)\\s+time)))`; - export const RecentlyTimeRegex = `(recently|previously)`; - export const AsapTimeRegex = `(as soon as possible|asap)`; - export const InclusiveModPrepositions = `(?((on|in|at)\\s+or\\s+)|(\\s+or\\s+(on|in|at)))`; - export const AroundRegex = `(?:\\b(?:around|circa)\\s*?\\b)(\\s+the)?`; - export const BeforeRegex = `((\\b${InclusiveModPrepositions}?(?:before|in\\s+advance\\s+of|prior\\s+to|(no\\s+later|earlier|sooner)\\s+than|ending\\s+(with|on)|by|(un)?till?|(?as\\s+late\\s+as))${InclusiveModPrepositions}?\\b\\s*?)|(?)((?<\\s*=)|<))(\\s+the)?`; - export const AfterRegex = `((\\b${InclusiveModPrepositions}?((after(\\s+on)?(?!\\sfrom)|(?>\\s*=)|>))(\\s+the)?`; - export const SinceRegex = `(?:(?:\\b(?:since|after\\s+or\\s+equal\\s+to|(starting|beginning)(\\s)?(?:from|on|with)?|as\\s+early\\s+as|(any\\s+time\\s+)from)\\b\\s*?)|(?=))(\\s+the)?`; - export const SinceRegexExp = `(${SinceRegex}|\\bfrom(\\s+the)?\\b)`; - export const AgoRegex = `\\b(ago|earlier|before\\s+(?yesterday|today))\\b`; - export const LaterRegex = `\\b(?:later(?!((\\s+in)?\\s*${OneWordPeriodRegex})|(\\s+${TimeOfDayRegex})|\\s+than\\b)|from now|(from|after)\\s+(?tomorrow|tmrw?|today))\\b`; - export const BeforeAfterRegex = `\\b((?before)|(?from|after))\\b`; - export const ModPrefixRegex = `\\b(${RelativeRegex}|${AroundRegex}|${BeforeRegex}|${AfterRegex}|${SinceRegex})\\b`; - export const ModSuffixRegex = `\\b(${AgoRegex}|${LaterRegex}|${BeforeAfterRegex}|${FutureSuffixRegex}|${PastSuffixRegex})\\b`; - export const InConnectorRegex = `\\b(in)\\b`; - export const SinceYearSuffixRegex = `(^\\s*${SinceRegex}(\\s*(the\\s+)?year\\s*)?${YearSuffix})`; - export const WithinNextPrefixRegex = `\\b(within(\\s+the)?(\\s+(?${NextPrefixRegex}))?)\\b`; - export const TodayNowRegex = `\\b(today|now|current (date|time))\\b`; - export const MorningStartEndRegex = `(^(morning|${AmDescRegex}))|((morning|${AmDescRegex})$)`; - export const AfternoonStartEndRegex = `(^(afternoon|${PmDescRegex}))|((afternoon|${PmDescRegex})$)`; - export const EveningStartEndRegex = `(^(evening))|((evening)$)`; - export const NightStartEndRegex = `(^(over|to)?ni(ght|te))|((over|to)?ni(ght|te)$)`; - export const InexactNumberRegex = `\\b((a\\s+)?few|some|several|(?(a\\s+)?couple(\\s+of)?))\\b`; - export const InexactNumberUnitRegex = `(${InexactNumberRegex})\\s+(${DurationUnitRegex})`; - export const RelativeTimeUnitRegex = `(?:(?:(?:${NextPrefixRegex}|${PreviousPrefixRegex}|${ThisPrefixRegex})\\s+(${TimeUnitRegex}))|((the|my))\\s+(${RestrictedTimeUnitRegex}))`; - export const RelativeDurationUnitRegex = `(?:(?:(?<=(${NextPrefixRegex}|${PreviousPrefixRegex}|${ThisPrefixRegex})\\s+)(${DurationUnitRegex}))|((the|my))\\s+(${RestrictedTimeUnitRegex}))`; - export const ReferenceDatePeriodRegex = `\\b${ReferencePrefixRegex}\\s+(?week(end)?|fortnight|month|year|decade)\\b`; - export const ConnectorRegex = `^(-|,|for|t|around|circa|@)$`; - export const FromToRegex = `(\\b(from).+(to|and|or)\\b.+)`; - export const SingleAmbiguousMonthRegex = `^(the\\s+)?(may|march)$`; - export const SingleAmbiguousTermsRegex = `^(the\\s+)?(day|week|month|year)$`; - export const UnspecificDatePeriodRegex = `^(week|fortnight|month|year)$`; - export const PrepositionSuffixRegex = `\\b(on|in|at|around|circa|from|to)$`; - export const FlexibleDayRegex = `(?([A-Za-z]+\\s)?[A-Za-z\\d]+)`; - export const ForTheRegex = `\\b((((?<=\\bfor\\s+)the\\s+${FlexibleDayRegex})|((?<=\\bon\\s+)(the\\s+)?${FlexibleDayRegex}(?<=(st|nd|rd|th))))(?\\s*(,|\\.(?!\\d)|!|\\?|$)))`; - export const WeekDayAndDayOfMonthRegex = `\\b${WeekDayRegex}\\s+(the\\s+${FlexibleDayRegex})\\b`; - export const WeekDayAndDayRegex = `\\b${WeekDayRegex}\\s+(?!(the))${DayRegex}(?!([-:]|(\\s+(${AmDescRegex}|${PmDescRegex}|${OclockRegex}))))\\b`; - export const RestOfDateRegex = `\\b(rest|remaining)\\s+(of\\s+)?((the|my|this|current)\\s+)?(?week|fortnight|month|year|decade)\\b`; - export const RestOfDateTimeRegex = `\\b(rest|remaining)\\s+(of\\s+)?((the|my|this|current)\\s+)?(?day)\\b`; - export const AmbiguousRangeModifierPrefix = `(from)`; - export const NumberEndingPattern = `^(?:\\s+(?meeting|appointment|conference|((skype|teams|zoom|facetime)\\s+)?call)\\s+to\\s+(?${PeriodHourNumRegex}|${HourRegex})([\\.]?$|(\\.,|,|!|\\?)))`; - export const OneOnOneRegex = `\\b(1\\s*:\\s*1(?!\\d))|(one (on )?one|one\\s*-\\s*one|one\\s*:\\s*one)\\b`; - export const LaterEarlyPeriodRegex = `\\b((${PrefixPeriodRegex})\\s*\\b\\s*(?${OneWordPeriodRegex}|(?${BaseDateTime.FourDigitYearRegex}))|(${UnspecificEndOfRangeRegex}))\\b`; - export const WeekWithWeekDayRangeRegex = `\\b((?(${NextPrefixRegex}|${PreviousPrefixRegex}|this)\\s+week)((\\s+between\\s+${WeekDayRegex}\\s+and\\s+${WeekDayRegex})|(\\s+from\\s+${WeekDayRegex}\\s+to\\s+${WeekDayRegex})))\\b`; - export const GeneralEndingRegex = `^\\s*((\\.,)|\\.|,|!|\\?)?\\s*$`; - export const MiddlePauseRegex = `\\s*(,)\\s*`; - export const DurationConnectorRegex = `^\\s*(?\\s+|and|,)\\s*$`; - export const PrefixArticleRegex = `\\bthe\\s+`; - export const OrRegex = `\\s*((\\b|,\\s*)(or|and)\\b|,)\\s*`; - export const SpecialYearTermsRegex = `\\b(((${SpecialYearPrefixes}\\s+)?year)|(cy|(?fy|sy)))`; - export const YearPlusNumberRegex = `\\b(${SpecialYearTermsRegex}\\s*((?(\\d{2,4}))|${FullTextYearRegex}))\\b`; - export const NumberAsTimeRegex = `\\b(${WrittenTimeRegex}|${PeriodHourNumRegex}|${BaseDateTime.HourRegex})\\b`; - export const TimeBeforeAfterRegex = `\\b(((?<=\\b(before|no later than|by|after)\\s+)(${WrittenTimeRegex}|${HourNumRegex}|${BaseDateTime.HourRegex}|${MidTimeRegex}))|${MidTimeRegex})\\b`; - export const DateNumberConnectorRegex = `^\\s*(?\\s+at)\\s*$`; - export const DecadeRegex = `(?(?:nough|twen|thir|fou?r|fif|six|seven|eigh|nine)ties|two\\s+thousands)`; - export const DecadeWithCenturyRegex = `(the\\s+)?(((?\\d|1\\d|2\\d)?(')?(?\\d0)(')?(\\s)?s\\b)|((${CenturyRegex}(\\s+|-)(and\\s+)?)?${DecadeRegex})|(${CenturyRegex}(\\s+|-)(and\\s+)?(?tens|hundreds)))`; - export const RelativeDecadeRegex = `\\b((the\\s+)?${RelativeRegex}\\s+((?[\\w,]+)\\s+)?decades?)\\b`; - export const YearPeriodRegex = `((((from|during|in)\\s+)?${YearRegex}\\s*(${TillRegex})\\s*${YearRegex})|(((between)\\s+)${YearRegex}\\s*(${RangeConnectorRegex})\\s*${YearRegex}))`; - export const StrictTillRegex = `(?\\b(to|(un)?till?|thru|through)\\b|${BaseDateTime.RangeConnectorSymbolRegex}(?!\\s*(h[1-2]|q[1-4])(?!(\\s+of|\\s*,\\s*))))`; - export const StrictRangeConnectorRegex = `(?\\b(and|through|to)\\b|${BaseDateTime.RangeConnectorSymbolRegex}(?!\\s*(h[1-2]|q[1-4])(?!(\\s+of|\\s*,\\s*))))`; - export const StartMiddleEndRegex = `\\b((?((the\\s+)?(start|beginning)\\s+of\\s+)?)(?((the\\s+)?middle\\s+of\\s+)?)(?((the\\s+)?end\\s+of\\s+)?))`; - export const ComplexDatePeriodRegex = `(?:((from|during|in)\\s+)?${StartMiddleEndRegex}(?.+)\\s*(${StrictTillRegex})\\s*${StartMiddleEndRegex}(?.+)|((between)\\s+)${StartMiddleEndRegex}(?.+)\\s*(${StrictRangeConnectorRegex})\\s*${StartMiddleEndRegex}(?.+))`; - export const FailFastRegex = `${BaseDateTime.DeltaMinuteRegex}|\\b(?:${BaseDateTime.BaseAmDescRegex}|${BaseDateTime.BasePmDescRegex})|${BaseDateTime.BaseAmPmDescRegex}|\\b(?:zero|${WrittenOneToNineRegex}|${WrittenElevenToNineteenRegex}|${WrittenTensRegex}|${WrittenMonthRegex}|${SeasonDescRegex}|${DecadeRegex}|centur(y|ies)|weekends?|quarters?|hal(f|ves)|yesterday|to(morrow|day|night)|tmr|noonish|\\d(-|——)?ish|((the\\s+\\w*)|\\d)(th|rd|nd|st)|(mid\\s*(-\\s*)?)?(night|morning|afternoon|day)s?|evenings?|noon|lunch(time)?|dinner(time)?|(day|night)time|overnight|dawn|dusk|sunset|hours?|hrs?|h|minutes?|mins?|seconds?|secs?|eo[dmy]|mardi[ -]?gras|birthday|eve|christmas|xmas|thanksgiving|halloween|yuandan|easter|yuan dan|april fools|cinco de mayo|all (hallow|souls)|guy fawkes|(st )?patrick|hundreds?|noughties|aughts|thousands?)\\b|${WeekDayRegex}|${SetWeekDayRegex}|${NowRegex}|${PeriodicRegex}|\\b(${DateUnitRegex}|${ImplicitDayRegex})`; - export const TasksModeSupressionRegexes = `(${AmPmDescRegex}|${TasksModeSpecialDescRegex}|${TasksModeHolidayListSupression}|${DecadeRegex}|${DecadeWithCenturyRegex}|${QuarterRegex}|${QuarterRegexYearFront}|${AllHalfYearRegex}|${SeasonRegex})`; - export const TasksModeNextPrefix = `(?next\\s+)`; - export const TasksModeDurationToDatePatterns = `\\b(${TasksModeNextPrefix}((?week)|(?month)|(?year)))\\b`; - export const UnitMap: ReadonlyMap = new Map([["decades", "10Y"],["decade", "10Y"],["years", "Y"],["year", "Y"],["y", "Y"],["months", "MON"],["month", "MON"],["m", "M"],["quarters", "3MON"],["quarter", "3MON"],["semesters", "6MON"],["semestres", "6MON"],["semester", "6MON"],["semestre", "6MON"],["weeks", "W"],["week", "W"],["w", "W"],["weekends", "WE"],["weekend", "WE"],["fortnights", "2W"],["fortnight", "2W"],["weekdays", "D"],["weekday", "D"],["days", "D"],["day", "D"],["d", "D"],["nights", "D"],["night", "D"],["hours", "H"],["hour", "H"],["hrs", "H"],["hr", "H"],["h", "H"],["minutes", "M"],["minute", "M"],["mins", "M"],["min", "M"],["seconds", "S"],["second", "S"],["secs", "S"],["sec", "S"]]); - export const UnitValueMap: ReadonlyMap = new Map([["decades", 315360000],["decade", 315360000],["years", 31536000],["year", 31536000],["y", 31536000],["months", 2592000],["month", 2592000],["m", 2592000],["fortnights", 1209600],["fortnight", 1209600],["weekends", 172800],["weekend", 172800],["weeks", 604800],["week", 604800],["w", 604800],["days", 86400],["day", 86400],["d", 86400],["nights", 86400],["night", 86400],["hours", 3600],["hour", 3600],["hrs", 3600],["hr", 3600],["h", 3600],["minutes", 60],["minute", 60],["mins", 60],["min", 60],["seconds", 1],["second", 1],["secs", 1],["sec", 1]]); - export const SpecialYearPrefixesMap: ReadonlyMap = new Map([["fiscal", "FY"],["school", "SY"],["fy", "FY"],["sy", "SY"]]); - export const SeasonMap: ReadonlyMap = new Map([["spring", "SP"],["summer", "SU"],["fall", "FA"],["autumn", "FA"],["winter", "WI"]]); - export const SeasonValueMap: ReadonlyMap = new Map([["SP", 3],["SU", 6],["FA", 9],["WI", 12]]); - export const CardinalMap: ReadonlyMap = new Map([["first", 1],["1st", 1],["second", 2],["2nd", 2],["third", 3],["3rd", 3],["fourth", 4],["4th", 4],["fifth", 5],["5th", 5],["sixth", 6],["6th", 6],["seventh", 7],["7th", 7],["eighth", 8],["8th", 8],["ninth", 9],["9th", 9],["tenth", 10],["10th", 10],["eleventh", 11],["11th", 11],["twelfth", 12],["12th", 12]]); - export const DayOfWeek: ReadonlyMap = new Map([["monday", 1],["tuesday", 2],["wednesday", 3],["thursday", 4],["friday", 5],["saturday", 6],["sunday", 0],["mon", 1],["tue", 2],["tues", 2],["wed", 3],["wedn", 3],["weds", 3],["thu", 4],["thur", 4],["thurs", 4],["fri", 5],["sat", 6],["sun", 0]]); - export const MonthOfYear: ReadonlyMap = new Map([["1", 1],["2", 2],["3", 3],["4", 4],["5", 5],["6", 6],["7", 7],["8", 8],["9", 9],["10", 10],["11", 11],["12", 12],["january", 1],["february", 2],["march", 3],["april", 4],["may", 5],["june", 6],["july", 7],["august", 8],["september", 9],["october", 10],["november", 11],["december", 12],["jan", 1],["feb", 2],["mar", 3],["apr", 4],["jun", 6],["jul", 7],["aug", 8],["sep", 9],["sept", 9],["oct", 10],["nov", 11],["dec", 12],["01", 1],["02", 2],["03", 3],["04", 4],["05", 5],["06", 6],["07", 7],["08", 8],["09", 9]]); - export const Numbers: ReadonlyMap = new Map([["zero", 0],["one", 1],["a", 1],["an", 1],["two", 2],["three", 3],["four", 4],["five", 5],["six", 6],["seven", 7],["eight", 8],["nine", 9],["ten", 10],["eleven", 11],["twelve", 12],["thirteen", 13],["fourteen", 14],["fifteen", 15],["sixteen", 16],["seventeen", 17],["eighteen", 18],["nineteen", 19],["twenty", 20],["twenty one", 21],["twenty two", 22],["twenty three", 23],["twenty four", 24],["twenty five", 25],["twenty six", 26],["twenty seven", 27],["twenty eight", 28],["twenty nine", 29],["thirty", 30],["thirty one", 31],["thirty two", 32],["thirty three", 33],["thirty four", 34],["thirty five", 35],["thirty six", 36],["thirty seven", 37],["thirty eight", 38],["thirty nine", 39],["forty", 40],["forty one", 41],["forty two", 42],["forty three", 43],["forty four", 44],["forty five", 45],["forty six", 46],["forty seven", 47],["forty eight", 48],["forty nine", 49],["fifty", 50],["fifty one", 51],["fifty two", 52],["fifty three", 53],["fifty four", 54],["fifty five", 55],["fifty six", 56],["fifty seven", 57],["fifty eight", 58],["fifty nine", 59],["sixty", 60],["sixty one", 61],["sixty two", 62],["sixty three", 63],["sixty four", 64],["sixty five", 65],["sixty six", 66],["sixty seven", 67],["sixty eight", 68],["sixty nine", 69],["seventy", 70],["seventy one", 71],["seventy two", 72],["seventy three", 73],["seventy four", 74],["seventy five", 75],["seventy six", 76],["seventy seven", 77],["seventy eight", 78],["seventy nine", 79],["eighty", 80],["eighty one", 81],["eighty two", 82],["eighty three", 83],["eighty four", 84],["eighty five", 85],["eighty six", 86],["eighty seven", 87],["eighty eight", 88],["eighty nine", 89],["ninety", 90],["ninety one", 91],["ninety two", 92],["ninety three", 93],["ninety four", 94],["ninety five", 95],["ninety six", 96],["ninety seven", 97],["ninety eight", 98],["ninety nine", 99],["one hundred", 100]]); - export const DayOfMonth: ReadonlyMap = new Map([["1st", 1],["1th", 1],["2nd", 2],["2th", 2],["3rd", 3],["3th", 3],["4th", 4],["5th", 5],["6th", 6],["7th", 7],["8th", 8],["9th", 9],["10th", 10],["11th", 11],["11st", 11],["12th", 12],["12nd", 12],["13th", 13],["13rd", 13],["14th", 14],["15th", 15],["16th", 16],["17th", 17],["18th", 18],["19th", 19],["20th", 20],["21st", 21],["21th", 21],["22nd", 22],["22th", 22],["23rd", 23],["23th", 23],["24th", 24],["25th", 25],["26th", 26],["27th", 27],["28th", 28],["29th", 29],["30th", 30],["31st", 31],["01st", 1],["01th", 1],["02nd", 2],["02th", 2],["03rd", 3],["03th", 3],["04th", 4],["05th", 5],["06th", 6],["07th", 7],["08th", 8],["09th", 9]]); - export const DoubleNumbers: ReadonlyMap = new Map([["half", 0.5],["quarter", 0.25]]); - export const HolidayNames: ReadonlyMap = new Map([["easterday", ["easterday","easter","eastersunday"]],["ashwednesday", ["ashwednesday"]],["palmsunday", ["palmsunday"]],["maundythursday", ["maundythursday"]],["goodfriday", ["goodfriday"]],["eastersaturday", ["eastersaturday"]],["eastermonday", ["eastermonday"]],["ascensionday", ["ascensionday"]],["whitesunday", ["whitesunday","pentecost","pentecostday"]],["whitemonday", ["whitemonday"]],["trinitysunday", ["trinitysunday"]],["corpuschristi", ["corpuschristi"]],["earthday", ["earthday"]],["fathers", ["fatherday","fathersday"]],["mothers", ["motherday","mothersday"]],["thanksgiving", ["thanksgivingday","thanksgiving"]],["blackfriday", ["blackfriday"]],["cybermonday", ["cybermonday"]],["martinlutherking", ["mlkday","martinlutherkingday","martinlutherkingjrday"]],["washingtonsbirthday", ["washingtonsbirthday","washingtonbirthday","presidentsday"]],["canberra", ["canberraday"]],["labour", ["labourday","laborday"]],["columbus", ["columbusday"]],["memorial", ["memorialday"]],["yuandan", ["yuandan"]],["maosbirthday", ["maosbirthday"]],["teachersday", ["teachersday","teacherday"]],["singleday", ["singleday"]],["allsaintsday", ["allsaintsday"]],["youthday", ["youthday"]],["childrenday", ["childrenday","childday"]],["femaleday", ["femaleday"]],["treeplantingday", ["treeplantingday"]],["arborday", ["arborday"]],["girlsday", ["girlsday"]],["whiteloverday", ["whiteloverday"]],["loverday", ["loverday","loversday"]],["christmas", ["christmasday","christmas"]],["xmas", ["xmasday","xmas"]],["newyear", ["newyear"]],["newyearday", ["newyearday"]],["newyearsday", ["newyearsday"]],["inaugurationday", ["inaugurationday"]],["groundhougday", ["groundhougday"]],["valentinesday", ["valentinesday"]],["stpatrickday", ["stpatrickday","stpatricksday","stpatrick"]],["aprilfools", ["aprilfools"]],["stgeorgeday", ["stgeorgeday"]],["mayday", ["mayday","intlworkersday","internationalworkersday","workersday"]],["cincodemayoday", ["cincodemayoday"]],["baptisteday", ["baptisteday"]],["usindependenceday", ["usindependenceday"]],["independenceday", ["independenceday"]],["bastilleday", ["bastilleday"]],["halloweenday", ["halloweenday","halloween"]],["allhallowday", ["allhallowday"]],["allsoulsday", ["allsoulsday"]],["guyfawkesday", ["guyfawkesday"]],["veteransday", ["veteransday"]],["christmaseve", ["christmaseve"]],["newyeareve", ["newyearseve","newyeareve"]],["juneteenth", ["juneteenth","freedomday","jubileeday"]],["ramadan", ["ramadan","ramazan","ramzan","ramadhan","ramathan"]],["sacrifice", ["eidaladha","eidalazha","eidulazha","feastofthesacrifice"]],["islamicnewyear", ["islamicnewyear","hijrinewyear","arabicnewyear"]],["eidalfitr", ["eidalfitr","festivalofbreakingthefast"]]]); - export const WrittenDecades: ReadonlyMap = new Map([["hundreds", 0],["tens", 10],["twenties", 20],["thirties", 30],["forties", 40],["fifties", 50],["sixties", 60],["seventies", 70],["eighties", 80],["nineties", 90]]); - export const SpecialDecadeCases: ReadonlyMap = new Map([["noughties", 2000],["aughts", 2000],["two thousands", 2000]]); - export const DefaultLanguageFallback = `MDY`; - export const SuperfluousWordList = [ "preferably","how about","maybe","perhaps","say","like" ]; - export const DurationDateRestrictions = [ "today","now","current date" ]; - export const AmbiguityFiltersDict: ReadonlyMap = new Map([["^\\d{4}$", "(\\d\\.\\d{4}|\\d{4}\\.\\d)"],["^(morning|afternoon|evening|night|day)\\b", "\\b(good\\s+(morning|afternoon|evening|night|day))|(nighty\\s+night)\\b"],["\\bnow\\b", "\\b(^now,)|\\b((is|are)\\s+now\\s+for|for\\s+now)\\b"],["\\bmay$", "\\b((((!|\\.|\\?|,|;|)\\s+|^)may i)|(i|you|he|she|we|they)\\s+may|(may\\s+((((also|not|(also not)|well)\\s+)?(be|ask|contain|constitute|e-?mail|take|have|result|involve|get|work|reply|differ))|(or may not)))|(? = new Map([["^(\\p{L}+|\\d{1,2})(\\s+(morning|afternoon|evening|night))?$", "\\b(one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve|\\d{1,2})\\s+(morning|afternoon|evening|night)\\b"]]); - export const AmbiguityDurationFiltersDict: ReadonlyMap = new Map([["night$", "\\bnight(\\s*|-)(club|light|market|shift|work(er)?)s?\\b"]]); - export const MorningTermList = [ "morning" ]; - export const AfternoonTermList = [ "afternoon" ]; - export const EveningTermList = [ "evening" ]; - export const MealtimeBreakfastTermList = [ "breakfast" ]; - export const MealtimeBrunchTermList = [ "brunch" ]; - export const MealtimeLunchTermList = [ "lunch","lunchtime" ]; - export const MealtimeDinnerTermList = [ "dinner","dinnertime","supper" ]; - export const DaytimeTermList = [ "daytime" ]; - export const NightTermList = [ "night" ]; - export const NighttimeTermList = [ "nighttime","night-time" ]; - export const SameDayTerms = [ "today","current date","otd" ]; - export const PlusOneDayTerms = [ "tomorrow","tmr","tmrw","day after" ]; - export const MinusOneDayTerms = [ "yesterday","day before" ]; - export const PlusTwoDayTerms = [ "day after tomorrow","day after tmr","day after tmrw" ]; - export const MinusTwoDayTerms = [ "day before yesterday" ]; - export const FutureTerms = [ "this","next" ]; - export const LastCardinalTerms = [ "last" ]; - export const MonthTerms = [ "month" ]; - export const MonthToDateTerms = [ "month to date" ]; - export const WeekendTerms = [ "weekend" ]; - export const WeekTerms = [ "week" ]; - export const FortnightTerms = [ "fortnight","fourtenight" ]; - export const YearTerms = [ "year" ]; - export const GenericYearTerms = [ "y" ]; - export const YearToDateTerms = [ "year to date" ]; - export const DoubleMultiplierRegex = `^(bi)(-|\\s)?`; - export const HalfMultiplierRegex = `^(semi)(-|\\s)?`; - export const DayTypeRegex = `((week)?da(il)?ys?)$`; - export const WeekTypeRegex = `(week(s|ly)?)$`; - export const WeekendTypeRegex = `(weekends?)$`; - export const MonthTypeRegex = `(month(s|ly)?)$`; - export const QuarterTypeRegex = `(quarter(s|ly)?)$`; - export const YearTypeRegex = `((years?|annual)(ly)?)$`; -} diff --git a/JavaScript/packages/recognizers-date-time/src/resources/frenchDateTime.ts b/JavaScript/packages/recognizers-date-time/src/resources/frenchDateTime.ts deleted file mode 100644 index bf686d7aa4..0000000000 --- a/JavaScript/packages/recognizers-date-time/src/resources/frenchDateTime.ts +++ /dev/null @@ -1,297 +0,0 @@ -// ------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// ------------------------------------------------------------------------------ - -import { BaseDateTime } from "./baseDateTime"; -export namespace FrenchDateTime { - export const LangMarker = `Fre`; - export const CheckBothBeforeAfter = false; - export const TillRegex = `(?\\b(au|et|(jusqu')?a|avant)\\b|(jusqu')?à|--|-|—|——)`; - export const RangeConnectorRegex = `(?\\b(de\\s+la|au|(jusqu')?a|et(\\s*la)?)\\b|(jusqu')?à|--|-|—|——)`; - export const RelativeRegex = `(?prochaine?|de|du|ce(tte)?|l[ae]|derni[eè]re|hier|pr[eé]c[eé]dente|au\\s+cours+(de|du\\s*))`; - export const StrictRelativeRegex = `(?prochaine?|derni[eè]re|hier|pr[eé]c[eé]dente|au\\s+cours+(de|du\\s*))`; - export const NextSuffixRegex = `(?prochain(es?)?|suivante)\\b`; - export const PastSuffixRegex = `(?derni[eè]r(es?)?|pr[eé]c[eé]dente)\\b`; - export const ThisPrefixRegex = `(?ce(tte)?|au\\s+cours+(du|de))\\b`; - export const RangePrefixRegex = `(du|depuis|des?|entre)`; - export const DayRegex = `(?(?:3[0-1]|[1-2]\\d|0?[1-9])(e(r)?)?)(?=\\b|t)`; - export const WrittenDayRegex = `(?((vingt|trente)(\\s*-\\s*|\\s+)et(\\s*-\\s*|\\s+))?un|(vingt(\\s*-\\s*|\\s+))?(deux|trois|quatre|cinq|six|sept|huit|neuf)|dix|onze|douze|treize|quatorze|quinze|seize|dix-(sept|huit|neuf)|vingt|trente)`; - export const MonthNumRegex = `(?1[0-2]|(0)?[1-9])\\b`; - export const SpecialDescRegex = `(p\\b)`; - export const AmDescRegex = `(h\\b|${BaseDateTime.BaseAmDescRegex})`; - export const PmDescRegex = `(h\\b|${BaseDateTime.BasePmDescRegex})`; - export const AmPmDescRegex = `(h\\b|${BaseDateTime.BaseAmPmDescRegex})`; - export const DescRegex = `(?${AmPmDescRegex}|${AmDescRegex}|${PmDescRegex}|${SpecialDescRegex})`; - export const TwoDigitYearRegex = `\\b(?([0-9]\\d))(?!(\\s*((\\:\\d)|${AmDescRegex}|${PmDescRegex}|\\.\\d)))\\b`; - export const WrittenOneToNineRegex = `(?:une?|deux|trois|quatre|cinq|six|sept|huit|neuf)`; - export const WrittenElevenToNineteenRegex = `(?:(seize|quinze|quatorze|treize|douze|onze)|dix\\W(neuf|huit|sept))`; - export const WrittenTensRegex = `(?:quatre\\Wvingt(s|\\Wdix)?|soixante(\\Wdix)?|dix|vingt|trente|quarante|cinquante|septante|octante|huitante|nonante)`; - export const WrittenCenturyFullYearRegex = `(?:(deux\\s+)?mille((\\s+${WrittenOneToNineRegex})?\\s+cents?)?)`; - export const WrittenCenturyOrdinalYearRegex = `(${WrittenOneToNineRegex}|${WrittenElevenToNineteenRegex}|dix)`; - export const CenturyRegex = `\\b(?${WrittenCenturyFullYearRegex}|${WrittenCenturyOrdinalYearRegex}(\\s+cents?)?)\\b`; - export const LastTwoYearNumRegex = `((${WrittenTensRegex}(\\s+|-))?(${WrittenOneToNineRegex}|${WrittenElevenToNineteenRegex})|${WrittenTensRegex})`; - export const FullTextYearRegex = `\\b(?(?${CenturyRegex})\\s+(?${LastTwoYearNumRegex})\\b|\\b(?${WrittenCenturyFullYearRegex}|${WrittenCenturyOrdinalYearRegex}\\s+cents))\\b`; - export const YearRegex = `(${BaseDateTime.FourDigitYearRegex}|${FullTextYearRegex})`; - export const WeekDayRegex = `(?dimanche|lundi|mardi|mercredi|jeudi|vendredi|samedi|lun(\\.)?|mar(\\.)?|mer(\\.)?|jeu(\\.)?|ven(\\.)?|sam(\\.)?|dim(\\.)?)`; - export const RelativeMonthRegex = `(?(${ThisPrefixRegex}\\s+mois)|(mois\\s+${PastSuffixRegex})|(mois\\s+${NextSuffixRegex}))\\b`; - export const WrittenMonthRegex = `(?avril|avr(\\.)?|ao[uû]t|d[eé]cembre|d[eé]c(\\.)?|f[eé]vrier|f[eé]vr?(\\.)?|janvier|janv?(\\.)?|juillet|jui?[ln](\\.)?|mars?(\\.)?|mai|novembre|nov(\\.)?|octobre|oct(\\.)?|septembre|sept?(\\.)?(?!\\s+heures))`; - export const MonthSuffixRegex = `(?(en\\s*|le\\s*|de\\s*|dans\\s*)?(${RelativeMonthRegex}|${WrittenMonthRegex}))`; - export const DateUnitRegex = `(?an|mois|((l')?ann[eé]e|semaine|journ[eé]e|jour)(?s)?)\\b`; - export const SimpleCasesRegex = `\\b((d[ue])|entre\\s+)?(${DayRegex})\\s*${TillRegex}\\s*(${DayRegex})\\s+${MonthSuffixRegex}((\\s+|\\s*,\\s*)${YearRegex})?\\b`; - export const MonthFrontSimpleCasesRegex = `\\b((d[ue]|entre)\\s+)?${MonthSuffixRegex}\\s+((d[ue]|entre)\\s+)?(${DayRegex})\\s*${TillRegex}\\s*(${DayRegex})((\\s+|\\s*,\\s*)${YearRegex})?\\b`; - export const MonthFrontBetweenRegex = `\\b${MonthSuffixRegex}\\s+(entre|d[ue]\\s+)(${DayRegex})\\s*${RangeConnectorRegex}\\s*(${DayRegex})((\\s+|\\s*,\\s*)${YearRegex})?\\b`; - export const BetweenRegex = `\\b(entre\\s+)(${DayRegex})\\s*${RangeConnectorRegex}\\s*(${DayRegex})\\s+${MonthSuffixRegex}((\\s+|\\s*,\\s*)${YearRegex})?\\b`; - export const YearWordRegex = `\\b(?l'ann[ée]e)\\b`; - export const MonthWithYear = `\\b(${WrittenMonthRegex}(\\s*),?(\\s+de)?(\\s*)(${YearRegex}|${TwoDigitYearRegex}|(?cette)\\s*${YearWordRegex})|${YearWordRegex}\\s*(${PastSuffixRegex}|${NextSuffixRegex}))`; - export const OneWordPeriodRegex = `\\b((${RelativeRegex}\\s+)?${WrittenMonthRegex}|(la\\s+)?(weekend|(fin de )?semaine|week-end|mois|ans?|l'année)\\s+${StrictRelativeRegex}|${RelativeRegex}\\s+(weekend|(fin de )?semaine|week-end|mois|ans?|l'année)|weekend|week-end|mois|l'année|an)\\b`; - export const MonthNumWithYear = `(${YearRegex}(\\s*)[/\\-\\.](\\s*)${MonthNumRegex})|(${MonthNumRegex}(\\s*)[/\\-](\\s*)${YearRegex})`; - export const WeekOfMonthRegex = `(?(le\\s+)?(?premier|1er|duexi[èe]me|2|troisi[èe]me|3|quatri[èe]me|4|cinqi[èe]me|5)\\s+semaine(\\s+de)?\\s+${MonthSuffixRegex})`; - export const WeekOfYearRegex = `(?(le\\s+)?(?premier|1er|duexi[èe]me|2|troisi[èe]me|3|quatri[èe]me|4|cinqi[èe]me|5)\\s+semaine(\\s+de)?\\s+(${YearRegex}|${RelativeRegex}\\s+ann[ée]e))`; - export const OfYearRegex = `\\b((of|in)\\s+(${YearRegex}|${StrictRelativeRegex}\\s+year))\\b`; - export const FirstLastRegex = `\\b(the\\s+)?((?first)|(?last))\\b`; - export const FollowedDateUnit = `^\\s*${DateUnitRegex}`; - export const NumberCombinedWithDateUnit = `\\b(?\\d+(\\.\\d*)?)${DateUnitRegex}`; - export const QuarterRegex = `(le\\s+)?(?premier|1er|duexi[èe]me|2|troisi[èe]me|3|quatri[èe]me|4)\\s+quart(\\s+de|\\s*,\\s*)?\\s+(${YearRegex}|${RelativeRegex}\\s+l'ann[eé]e)`; - export const QuarterRegexYearFront = `(${YearRegex}|l'année\\s+(${PastSuffixRegex}|${NextSuffixRegex})|${RelativeRegex}\\s+ann[eé]e)\\s+(le\\s+)?(?premier|1er|duexi[èe]me|2|troisi[èe]me|3|quatri[èe]me|4)\\s+quarts`; - export const AllHalfYearRegex = `^\\b$`; - export const PrefixDayRegex = `\\b((?t[ôo]t\\sdans)|(?au\\smilieu\\sde)|(?tard\\sdans))(\\s+la\\s+journ[ée]e)?$`; - export const CenturySuffixRegex = `^\\b$`; - export const SeasonRegex = `\\b((printemps|été|automne|hiver)+\\s*(${NextSuffixRegex}|${PastSuffixRegex}))|(?(${RelativeRegex}\\s+)?(?printemps|[ée]t[ée]|automne|hiver)((\\s+de|\\s*,\\s*)?\\s+(${YearRegex}|${RelativeRegex}\\s+l'ann[eé]e))?)\\b`; - export const WhichWeekRegex = `\\b(semaine)(\\s*)(?5[0-3]|[1-4]\\d|0?[1-9])\\b`; - export const WeekOfRegex = `(semaine)(\\s*)(de)`; - export const MonthOfRegex = `(mois)(\\s*)(de)`; - export const MonthRegex = `(?avril|avr(\\.)?|ao[uû]t|d[eé]cembre|d[eé]c(\\.)?|f[eé]vrier|f[eé]vr?(\\.)?|janvier|janv?(\\.)?|juillet|jui?[ln](\\.)?|mars?(\\.)?|mai|novembre|nov(\\.)?|octobre|oct(\\.)?|septembre|sept?(\\.)?(?!\\s+heures))`; - export const OnRegex = `(?<=\\b(en|sur\\s*l[ea]|sur)\\s+)(${DayRegex}s?)\\b`; - export const RelaxedOnRegex = `(?<=\\b(en|le|dans|sur\\s*l[ea]|du|sur)\\s+)((?10e|11e|12e|13e|14e|15e|16e|17e|18e|19e|1er|20e|21e|22e|23e|24e|25e|26e|27e|28e|29e|2e|30e|31e|3e|4e|5e|6e|7e|8e|9e)s?)\\b`; - export const ThisRegex = `\\b((cette(\\s*semaine)?\\s+)${WeekDayRegex})|(${WeekDayRegex}(\\s+cette\\s*semaine))\\b`; - export const LastDateRegex = `\\b((${WeekDayRegex}(\\s*(de)?\\s*la\\s*semaine\\s+${PastSuffixRegex}))|(${WeekDayRegex}(\\s+${PastSuffixRegex})))\\b`; - export const NextDateRegex = `\\b((${WeekDayRegex}(\\s+${NextSuffixRegex}))|(${WeekDayRegex}(\\s*(de)?\\s*la\\s*semaine\\s+${NextSuffixRegex})))\\b`; - export const SpecialDayRegex = `\\b(avant[\\s|-]hier|apr[eè]s(-demain|\\s*demain)|(le\\s)?jour suivant|(le\\s+)?dernier jour|hier|lendemain|demain|(de\\s)?la journ[ée]e|aujourd'hui)\\b`; - export const SpecialDayWithNumRegex = `^\\b$`; - export const StrictWeekDay = `\\b(?dim(anche)?|lun(di)?|mar(di)?|mer(credi)?|jeu(di)?|ven(dredi)?|sam(edi)?)s?\\b`; - export const SetWeekDayRegex = `\\b(?le\\s+)?(?matin([ée]e)?|apr[eè]s-midi|soir([ée]e)?|dimanche|lundi|mardi|mercredi|jeudi|vendredi|samedi)s\\b`; - export const WeekDayOfMonthRegex = `(?(le\\s+)?(?premier|1er|duexi[èe]me|2|troisi[èe]me|3|quatri[èe]me|4|cinqi[èe]me|5)\\s+${WeekDayRegex}\\s+${MonthSuffixRegex})`; - export const RelativeWeekDayRegex = `^\\b$`; - export const AmbiguousRangeModifierPrefix = `^\\b$`; - export const NumberEndingPattern = `^\\b$`; - export const SpecialDate = `(?<=\\b(au|le)\\s+)${DayRegex}(?!:)\\b`; - export const DateYearRegex = `(?${YearRegex}|${TwoDigitYearRegex})`; - export const DateExtractor1 = `\\b(${WeekDayRegex}(\\s+|\\s*,\\s*))?${MonthRegex}\\s*[/\\\\\\.\\-]?\\s*${DayRegex}(\\s*([/\\\\\\.\\-]|\\bde\\b)?\\s*${BaseDateTime.FourDigitYearRegex})?\\b`; - export const DateExtractor2 = `\\b(${WeekDayRegex}(\\s+|\\s*,\\s*))?${DayRegex}(\\s+|\\s*,\\s*|\\s+)${MonthRegex}\\s*([\\.\\-]|\\bde\\b)?\\s*${DateYearRegex}\\b`; - export const DateExtractor3 = `\\b(${WeekDayRegex}(\\s+|\\s*,\\s*))?((?(l')?ann[eé]e(s)?|mois|semaines?)\\b`; - export const HourNumRegex = `\\b(?zero|une?(?=\\s+heure)|deux|trois|quatre|cinq|six|sept|huit|neuf|onze|douze|treize|quatorze|quinze|dix-six|seize|dix(-|\\s+)sept|dix(-|\\s+)huit|dix(-|\\s+)neuf|vingt|vingt(-|\\s+)et(-|\\s+)un|vingt(-|\\s+)deux|vingt(-|\\s+)trois|dix)\\b`; - export const MinuteNumRegex = `(?((vingt|trente|quarante|cinquante)(\\s*(et|-)?\\s*))?(un|deux|trois|quatre|cinq|six|sept|huit|neuf)|onze|douze|treize|quatorze|quinze|seize|dix-sept|dix-huit|dix-neuf|vingt|trente|quarante|cinquante|dix)`; - export const DeltaMinuteNumRegex = `(?((vingt|trente|quarante|cinquante)(\\s*(et|-)?\\s*))?(un|deux|trois|quatre|cinq|six|sept|huit|neuf)|onze|douze|treize|quatorze|quinze|seize|dix-sept|dix-huit|dix-neuf|vingt|trente|quarante|cinquante|dix)`; - export const OclockRegex = `(?heures?|h)`; - export const PmRegex = `(?(dans l'\\s*)?apr[eè]s(\\s*|-)midi|(du|ce|de|le)\\s*(soir([ée]e)?)|(dans l[ea]\\s+)?(nuit|soir[eé]e))`; - export const AmRegex = `(?(du|de|ce|(du|de|dans)\\s*l[ea]|le)?\\s*matin[ée]e|(du|de|ce|dans l[ea]|le)?\\s*matin)`; - export const LessThanOneHour = `(?(une\\s+)?quart|trois quart(s)?|demie( heure)?|(${BaseDateTime.DeltaMinuteRegex}|${DeltaMinuteNumRegex})(\\s+(minutes?|mins?))|(?<=heures?\\s+((et|moins)\\s+)?)(${BaseDateTime.DeltaMinuteRegex}|${DeltaMinuteNumRegex}))`; - export const WrittenTimeRegex = `(?${HourNumRegex}\\s+(heures\\s+)?(et\\s+)?${MinuteNumRegex}(?!\\s+heures)(\\s+(minutes?|mins?))?)`; - export const TimePrefix = `(?(heures?\\s+((et|moins)\\s+)?${LessThanOneHour}|(et|moins)\\s+${LessThanOneHour}|${LessThanOneHour}\\s+[àa]))`; - export const TimeSuffix = `(?${AmRegex}|${PmRegex}|${OclockRegex})`; - export const BasicTime = `(?${WrittenTimeRegex}|${HourNumRegex}|${BaseDateTime.HourRegex}(:|\\s*h\\s*)${BaseDateTime.MinuteRegex}(:${BaseDateTime.SecondRegex})?|${BaseDateTime.HourRegex})`; - export const MidnightRegex = `(?minuit)`; - export const CommonDatePrefixRegex = `^[\\.]`; - export const MorningRegex = `(?matin([ée]e)?)`; - export const AfternoonRegex = `(?(d'|l')?apr[eè]s(-|\\s*)midi)`; - export const MidmorningRegex = `(?milieu\\s*d[ue]\\s*${MorningRegex})`; - export const MiddayRegex = `(?milieu(\\s*|-)d[eu]\\s*(jour|midi)|apr[eè]s(-|\\s*)midi|(?<=\\bà\\s+)midi)`; - export const MidafternoonRegex = `(?milieu\\s*d'+${AfternoonRegex})`; - export const MidTimeRegex = `(?(${MidnightRegex}|${MidmorningRegex}|${MidafternoonRegex}|${MiddayRegex}))`; - export const AtRegex = `\\b(((?<=\\b[àa]\\s+)(${WrittenTimeRegex}|${HourNumRegex}(\\s+heures)?|${BaseDateTime.HourRegex}|${MidTimeRegex}))|${MidTimeRegex})\\b`; - export const IshRegex = `\\b(peu\\s*pr[èe]s\\s*${BaseDateTime.HourRegex}|peu\\s*pr[èe]s\\s*${WrittenTimeRegex}|peu\\s*pr[èe]s\\s*[àa]\\s*${BaseDateTime.HourRegex}|peu pr[èe]s midi)\\b`; - export const TimeUnitRegex = `(?h|(heure|hr|minute|min|seconde|sec)(?s)?)\\b`; - export const RestrictedTimeUnitRegex = `(?huere|minute)\\b`; - export const ConnectNumRegex = `${BaseDateTime.HourRegex}(?[0-5][0-9])\\s*${DescRegex}`; - export const FivesRegex = `(?(quinze|vingt(\\s*|-*(cinq))?|trente(\\s*|-*(cinq))?|quarante(\\s*|-*(cinq))??|cinquante(\\s*|-*(cinq))?|dix|cinq))\\b`; - export const PeriodHourNumRegex = `(?vingt-et-un|vingt-deux|vingt-trois|vingt-quatre|zero|une|deux|trois|quatre|cinq|six|sept|huit|neuf|dix|onze|douze|treize|quatorze|quinze|seize|dix-sept|dix-huit|dix-neuf|vingt)`; - export const TimeRegex1 = `\\b(${WrittenTimeRegex}|${HourNumRegex}|${BaseDateTime.HourRegex})\\s*${DescRegex}(\\s+${TimePrefix})?\\b`; - export const TimeRegex2 = `(\\b${TimePrefix}\\s+)?(t)?${BaseDateTime.HourRegex}(\\s*)?:(\\s*)?${BaseDateTime.MinuteRegex}((\\s*)?:(\\s*)?${BaseDateTime.SecondRegex})?((\\s*${DescRegex})|\\b)`; - export const TimeRegex3 = `\\b${BaseDateTime.HourRegex}\\.${BaseDateTime.MinuteRegex}(\\s*${DescRegex})(\\s+${TimePrefix})?`; - export const TimeRegex4 = `\\b${BasicTime}(\\s*${DescRegex})?(\\s+${TimePrefix})?\\s+${TimeSuffix}\\b`; - export const TimeRegex5 = `\\b${BasicTime}((\\s*${DescRegex})(\\s+${TimePrefix})?|\\s+${TimePrefix})`; - export const TimeRegex6 = `${BasicTime}(\\s*${DescRegex})?\\s+${TimeSuffix}\\b`; - export const TimeRegex7 = `\\b${TimeSuffix}\\s+[àa]\\s+${BasicTime}((\\s*${DescRegex})|\\b)`; - export const TimeRegex8 = `\\b${TimeSuffix}\\s+${BasicTime}((\\s*${DescRegex})|\\b)`; - export const TimeRegex9 = `\\b${PeriodHourNumRegex}\\s+${FivesRegex}((\\s*${DescRegex})|\\b)`; - export const TimeRegex10 = `\\b${BaseDateTime.HourRegex}(\\s*h\\s*)${BaseDateTime.MinuteRegex}(\\s*${DescRegex})?(\\s+${TimePrefix})?`; - export const HourRegex = `\\b${BaseDateTime.HourRegex}`; - export const PeriodDescRegex = `(?pm|am|p\\.m\\.|a\\.m\\.|p)`; - export const PeriodPmRegex = `(?dans l'apr[eè]s-midi|ce soir|d[eu] soir|dans l[ea] soir[eé]e|dans la nuit|d[eu] soir[ée]e)s?`; - export const PeriodAmRegex = `(?d[eu] matin|matin([ée]e)s?`; - export const PureNumFromTo = `((du|depuis|des?)\\s+)?(?${PeriodDescRegex}))?\\s*${TillRegex}\\s*(${HourRegex}|${PeriodHourNumRegex})\\s*(?${PmRegex}|${AmRegex}|${PeriodDescRegex})?`; - export const PureNumBetweenAnd = `(entre\\s+)(${HourRegex}|${PeriodHourNumRegex})(\\s*(?${PeriodDescRegex}))?\\s*${RangeConnectorRegex}\\s*(${HourRegex}|${PeriodHourNumRegex})\\s*(?${PmRegex}|${AmRegex}|${PeriodDescRegex})?`; - export const SpecificTimeFromTo = `^\\b$`; - export const SpecificTimeBetweenAnd = `^\\b$`; - export const PrepositionRegex = `(?^([aà](\\s+?la)?|en|sur(\\s*l[ea])?|de)$)`; - export const TimeOfDayRegex = `\\b(?((((dans\\s+(l[ea])?\\s+)?((?d[eé]but(\\s+|-)|t[oô]t(\\s+|-)(l[ea]\\s*)?)|(?fin\\s*|fin de(\\s+(la)?)|tard\\s*))?(matin([ée]e)?|((d|l)?'?)apr[eè]s[-|\\s*]midi|nuit|soir([eé]e)?)))|(((\\s+(l[ea])?\\s+)?)jour(n[eé]e)?))s?)\\b`; - export const SpecificTimeOfDayRegex = `\\b((${RelativeRegex}\\s+${TimeOfDayRegex})|(${TimeOfDayRegex}\\s*(${NextSuffixRegex}))\\b|\\b(du )?soir)s?\\b`; - export const TimeFollowedUnit = `^\\s*${TimeUnitRegex}`; - export const TimeNumberCombinedWithUnit = `\\b(?\\d+(\\.\\d*)?)${TimeUnitRegex}`; - export const NowRegex = `\\b(?(ce\\s+)?moment|maintenant|(d[eè]s|aussit[oô]t) que possible|dqp|r[eé]cemment|auparavant|le plus tôt( que)? possible)\\b`; - export const SuffixRegex = `^\\s*((dans\\s+l[ea]\\s+)|(en\\s+)|(d(u|\\'))?(matin([eé]e)?|apr[eè]s-midi|soir[eé]e|nuit))\\b`; - export const DateTimeTimeOfDayRegex = `\\b(?matin([eé]e)?|apr[eè]s-midi|nuit|soir)\\b`; - export const DateTimeSpecificTimeOfDayRegex = `\\b((${RelativeRegex}\\s+${DateTimeTimeOfDayRegex})\\b|\\b(ce(tte)?\\s+)(soir|nuit))\\b`; - export const TimeOfTodayAfterRegex = `^\\s*(,\\s*)?(en|dans|du\\s+)?${DateTimeSpecificTimeOfDayRegex}`; - export const TimeOfTodayBeforeRegex = `${DateTimeSpecificTimeOfDayRegex}(\\s*,)?(\\s+([àa]|vers|pour))?\\s*$`; - export const SimpleTimeOfTodayAfterRegex = `(${HourNumRegex}|${BaseDateTime.HourRegex})\\s*(,\\s*)?(en|[àa]\\s+)?${DateTimeSpecificTimeOfDayRegex}`; - export const SimpleTimeOfTodayBeforeRegex = `${DateTimeSpecificTimeOfDayRegex}(\\s*,)?(\\s+([àa]|vers|pour))?\\s*(${HourNumRegex}|${BaseDateTime.HourRegex})`; - export const SpecificEndOfRegex = `(la\\s+)?fin(\\s+de\\s*|\\s*de*l[ea])?\\s*$`; - export const UnspecificEndOfRegex = `^\\b$`; - export const UnspecificEndOfRangeRegex = `^\\b$`; - export const PeriodTimeOfDayRegex = `\\b((dans\\s+(le)?\\s+)?((?d[eé]but(\\s+|-|d[ue]|de la)|t[oô]t)|(?tard\\s*|fin(\\s+|-|d[eu])?))?(?matin|((d|l)?'?)apr[eè]s-midi|nuit|soir([eé]e)?))\\b`; - export const PeriodSpecificTimeOfDayRegex = `\\b((${RelativeRegex}\\s+${PeriodTimeOfDayRegex})\\b|\\b(ce(tte)?\\s+)(soir|nuit))\\b`; - export const PeriodTimeOfDayWithDateRegex = `\\b((${TimeOfDayRegex}))\\b`; - export const LessThanRegex = `^\\b$`; - export const MoreThanRegex = `^\\b$`; - export const DurationUnitRegex = `(?ann[eé]es?|ans?|mois|semaines?|jours?|heures?|hrs?|h|minutes?|mins?|secondes?|secs?|journ[eé]e)\\b`; - export const SuffixAndRegex = `(?\\s*(et)\\s+(une?\\s+)?(?demi|quart))`; - export const PeriodicRegex = `\\b(?quotidien(ne)?|journellement|mensuel(le)?|jours?|hebdomadaire|bihebdomadaire|annuel(lement)?)\\b`; - export const EachUnitRegex = `(?(chaque|toutes les|tous les)(?\\s+autres)?\\s*${DurationUnitRegex})`; - export const EachPrefixRegex = `\\b(?(chaque|tous les|(toutes les))\\s*$)`; - export const SetEachRegex = `\\b(?(chaque|tous les|(toutes les))\\s*)`; - export const SetLastRegex = `(?prochain|dernier|derni[eè]re|pass[ée]s|pr[eé]c[eé]dent|courant|en\\s*cours)`; - export const EachDayRegex = `^\\s*(chaque|tous les)\\s*(jour|jours)\\b`; - export const DurationFollowedUnit = `^\\s*${SuffixAndRegex}?(\\s+|-)?${DurationUnitRegex}`; - export const NumberCombinedWithDurationUnit = `\\b(?\\d+(\\.\\d*)?)(-)?${DurationUnitRegex}`; - export const AnUnitRegex = `\\b(((?demi\\s+)?(-)\\s+${DurationUnitRegex}))`; - export const DuringRegex = `^\\b$`; - export const AllRegex = `\\b(?toute\\s(l['ea])\\s?(?ann[eé]e|mois|semaines?|jours?|journ[eé]e))\\b`; - export const HalfRegex = `((une?\\s*)|\\b)(?demi?(\\s*|-)+(?ann[eé]e|ans?|mois|semaine|jour|heure))\\b`; - export const ConjunctionRegex = `\\b((et(\\s+de|pour)?)|avec)\\b`; - export const HolidayRegex1 = `\\b(?vendredi saint|mercredi des cendres|p[aâ]ques|l'action de gr[âa]ce|mardi gras|la saint-sylvestre|la saint sylvestre|la saint-valentin|la saint valentin|nouvel an chinois|nouvel an|r[eé]veillon de nouvel an|jour de l'an|premier-mai|ler-mai|1-mai|poisson d'avril|r[eé]veillon de no[eë]l|veille de no[eë]l|noël|noel|thanksgiving|halloween|yuandan)(\\s+((d[ue]\\s+|d'))?(${YearRegex}|(${ThisPrefixRegex}\\s+)ann[eé]e|ann[eé]e\\s+(${PastSuffixRegex}|${NextSuffixRegex})))?\\b`; - export const HolidayRegex2 = `\\b(?martin luther king|martin luther king jr|toussaint|st patrick|st george|cinco de mayo|l'ind[eé]pendance(\\s+am[eé]ricaine)?|guy fawkes)(\\s+(de\\s+)?(${YearRegex}|${ThisPrefixRegex}\\s+ann[eé]e|ann[eé]e\\s+(${PastSuffixRegex}|${NextSuffixRegex})))?\\b`; - export const HolidayRegex3 = `(?(jour\\s*(d[eu]|des)\\s*(canberra|p[aâ]ques|colomb|bastille|la prise de la bastille|thanks\\s*giving|bapt[êe]me|nationale|d'armistice|inaugueration|marmotte|assomption|femme|comm[ée]moratif)))(\\s+(de\\s+)?(${YearRegex}|${ThisPrefixRegex}\\s+ann[eé]e|ann[eé]e\\s+(${PastSuffixRegex}|${NextSuffixRegex})))?`; - export const HolidayRegex4 = `(?(f[eê]te\\s*(d[eu]|des)\\s*)(travail|m[eè]res?|p[eè]res?))(\\s+(de\\s+)?(${YearRegex}|${ThisPrefixRegex}\\s+ann[eé]e|ann[eé]e\\s+(${PastSuffixRegex}|${NextSuffixRegex})))?\\b`; - export const DateTokenPrefix = `le `; - export const TimeTokenPrefix = `à `; - export const TokenBeforeDate = `le `; - export const TokenBeforeTime = `à `; - export const HalfTokenRegex = `\\b(demie)$`; - export const QuarterTokenRegex = `\\b((un\\s+)?quart)$`; - export const ThreeQuarterTokenRegex = `\\b(trois\\s+quarts)$`; - export const ToTokenRegex = `\\b(moins|[aà]$)\\b`; - export const AMTimeRegex = `(?matin([ée]e)?)`; - export const PMTimeRegex = `\\b(?(d'|l')?apr[eè]s-midi|nuit|((\\s*ce|du)\\s+)?soir)\\b`; - export const AsapTimeRegex = `((d[eè]s|le plus t[oô]t|aussit[oô]t)( que)? possible|dqp)`; - export const BeforeRegex = `\\b(avant)\\b`; - export const BeforeRegex2 = `\\b(entre\\s*(le|la(s)?)?)\\b`; - export const AfterRegex = `\\b(apres)\\b`; - export const SinceRegex = `\\b(depuis)\\b`; - export const AroundRegex = `\\b(vers|à\\s+peu\\s+près|environ)\\b`; - export const AgoPrefixRegex = `\\b(y a)\\b`; - export const LaterRegex = `\\b(plus\\s+tard|à\\s+partir\\s+(de\\s+(maintenant|demain)|d'aujourd'hui)|après\\s+(aujourd'hui|demain))\\b`; - export const AgoRegex = `\\b((depuis|il\\s+y\\s*a)(\\s+${AroundRegex})?|auparavant|avant\\s+(?hier|aujourd'hui))\\b`; - export const BeforeAfterRegex = `^\\b$`; - export const InConnectorRegex = `\\b(dans|en|sur)\\b`; - export const SinceYearSuffixRegex = `^\\b$`; - export const WithinNextPrefixRegex = `\\b(dans\\s+les)\\b`; - export const TodayNowRegex = `\\b(aujourd'hui|maintenant)\\b`; - export const MorningStartEndRegex = `(^(matin))|((matin)$)`; - export const AfternoonStartEndRegex = `(^((d'|l')?apr[eè]s-midi))|(((d'|l')?apr[eè]s-midi)$)`; - export const EveningStartEndRegex = `(^(soir[ée]e|soir))|((soir[ée]e|soir)$)`; - export const NightStartEndRegex = `(^(nuit))|((nuit)$)`; - export const InexactNumberRegex = `\\b(quel qu[ée]s|quelqu[ée]s?|plusieurs?|divers)\\b`; - export const InexactNumberUnitRegex = `(${InexactNumberRegex})\\s+(${DurationUnitRegex})`; - export const RelativeTimeUnitRegex = `((((${ThisPrefixRegex})?)\\s+(${TimeUnitRegex}(\\s*${NextSuffixRegex}|${PastSuffixRegex})?))|((le))\\s+(${RestrictedTimeUnitRegex}))`; - export const RelativeDurationUnitRegex = `\\b(((?<=(${NextSuffixRegex}|${PastSuffixRegex})\\s+)(${DurationUnitRegex}))|((${DurationUnitRegex})(\\s+(${NextSuffixRegex}|${PastSuffixRegex}))?)|((le|my))\\s+(${RestrictedTimeUnitRegex}))\\b`; - export const ReferenceDatePeriodRegex = `^\\b$`; - export const UpcomingPrefixRegex = `.^`; - export const NextPrefixRegex = `.^`; - export const PastPrefixRegex = `.^`; - export const PreviousPrefixRegex = `.^`; - export const RelativeDayRegex = `\\b(((la\\s+)?${RelativeRegex}\\s+journ[ée]e))\\b`; - export const ConnectorRegex = `^(,|pour|t|vers|le)$`; - export const ConnectorAndRegex = `\\b(et\\s*(le|las?)?)\\b`; - export const FromRegex = `((de|du)?)$`; - export const FromRegex2 = `((depuis|de)(\\s*las?)?)$`; - export const FromToRegex = `\\b(du|depuis|des?).+(au|à|a)\\b.+`; - export const SingleAmbiguousMonthRegex = `^(le\\s+)?(may|march)$`; - export const UnspecificDatePeriodRegex = `^(semaine|mois|an(n[eé]e)?)$`; - export const PrepositionSuffixRegex = `\\b(du|de|[àa]|vers|dans)$`; - export const FlexibleDayRegex = `(?([A-Za-z]+\\s)?[A-Za-z\\d]+)`; - export const ForTheRegex = `\\b(((pour le ${FlexibleDayRegex})|(dans (le\\s+)?${FlexibleDayRegex}(?<=(st|nd|rd|th))))(?\\s*(,|\\.|!|\\?|$)))`; - export const WeekDayAndDayOfMonthRegex = `\\b(${WeekDayRegex}\\s+(le\\s+${FlexibleDayRegex})|le\\s+(?${DayRegex}|${WrittenDayRegex})\\s+${WeekDayRegex})\\b`; - export const WeekDayAndDayRegex = `\\b${WeekDayRegex}\\s+(?!(the))${DayRegex}(?!([-:]|(\\s+(${AmDescRegex}|${PmDescRegex}|${OclockRegex}))))\\b`; - export const RestOfDateRegex = `\\b(reste|fin)\\s+(d[eu]\\s+)?((le|ce(tte)?)\\s+)?(?semaine|mois|l'ann[ée]e)\\b`; - export const RestOfDateTimeRegex = `\\b(reste|fin)\\s+(d[eu]\\s+)?((le|ce(tte)?)\\s+)?(?jour)\\b`; - export const LaterEarlyPeriodRegex = `^\\b$`; - export const WeekWithWeekDayRangeRegex = `^\\b$`; - export const GeneralEndingRegex = `^\\b$`; - export const MiddlePauseRegex = `^\\b$`; - export const DurationConnectorRegex = `^\\b$`; - export const PrefixArticleRegex = `^[\\.]`; - export const OrRegex = `^\\b$`; - export const YearPlusNumberRegex = `^\\b$`; - export const NumberAsTimeRegex = `^\\b$`; - export const TimeBeforeAfterRegex = `^\\b$`; - export const DateNumberConnectorRegex = `^\\s*(?\\s+[aà])\\s*$`; - export const DecadeRegex = `^\\b$`; - export const DecadeWithCenturyRegex = `^\\b$`; - export const RelativeDecadeRegex = `^\\b$`; - export const YearSuffix = `(,?(\\s*à)?\\s*(${DateYearRegex}|${FullTextYearRegex}))`; - export const SuffixAfterRegex = `^\\b$`; - export const YearPeriodRegex = `((((du|depuis|des?)\\s+)?${YearRegex}\\s*(${TillRegex})\\s*${YearRegex})|(((entre)\\s+)${YearRegex}\\s*(${RangeConnectorRegex})\\s*${YearRegex}))`; - export const FutureSuffixRegex = `\\b(dans\\s+le\\s+futur)\\b`; - export const ModPrefixRegex = `\\b(${RelativeRegex}|${AroundRegex}|${BeforeRegex}|${AfterRegex}|${SinceRegex})\\b`; - export const ModSuffixRegex = `\\b(${AgoRegex}|${LaterRegex}|${BeforeAfterRegex}|${FutureSuffixRegex}|${PastSuffixRegex})\\b`; - export const ComplexDatePeriodRegex = `^\\b$`; - export const AmbiguousPointRangeRegex = `^(mar\\.?)$`; - export const UnitMap: ReadonlyMap = new Map([["annees", "Y"],["annee", "Y"],["an", "Y"],["ans", "Y"],["mois", "MON"],["semaines", "W"],["semaine", "W"],["journees", "D"],["journee", "D"],["jour", "D"],["jours", "D"],["heures", "H"],["heure", "H"],["hrs", "H"],["hr", "H"],["h", "H"],["minutes", "M"],["minute", "M"],["mins", "M"],["min", "M"],["secondes", "S"],["seconde", "S"],["secs", "S"],["sec", "S"]]); - export const UnitValueMap: ReadonlyMap = new Map([["annees", 31536000],["annee", 31536000],["l'annees", 31536000],["l'annee", 31536000],["an", 31536000],["ans", 31536000],["mois", 2592000],["semaines", 604800],["semaine", 604800],["journees", 86400],["journee", 86400],["jour", 86400],["jours", 86400],["heures", 3600],["heure", 3600],["hrs", 3600],["hr", 3600],["h", 3600],["minutes", 60],["minute", 60],["mins", 60],["min", 60],["secondes", 1],["seconde", 1],["secs", 1],["sec", 1]]); - export const SpecialYearPrefixesMap: ReadonlyMap = new Map([["", ""]]); - export const SeasonMap: ReadonlyMap = new Map([["printemps", "SP"],["été", "SU"],["automne", "FA"],["hiver", "WI"]]); - export const SeasonValueMap: ReadonlyMap = new Map([["SP", 3],["SU", 6],["FA", 9],["WI", 12]]); - export const CardinalMap: ReadonlyMap = new Map([["premier", 1],["1er", 1],["deuxième", 2],["2e", 2],["troisième", 3],["troisieme", 3],["3e", 3],["quatrième", 4],["4e", 4],["cinqième", 5],["5e", 5]]); - export const DayOfWeek: ReadonlyMap = new Map([["lundi", 1],["mardi", 2],["mercredi", 3],["jeudi", 4],["vendredi", 5],["samedi", 6],["dimanche", 0],["lun", 1],["mar", 2],["mer", 3],["jeu", 4],["ven", 5],["sam", 6],["dim", 0],["lun.", 1],["mar.", 2],["mer.", 3],["jeu.", 4],["ven.", 5],["sam.", 6],["dim.", 0]]); - export const MonthOfYear: ReadonlyMap = new Map([["1", 1],["2", 2],["3", 3],["4", 4],["5", 5],["6", 6],["7", 7],["8", 8],["9", 9],["10", 10],["11", 11],["12", 12],["janvier", 1],["fevrier", 2],["février", 2],["mars", 3],["mar", 3],["mar.", 3],["avril", 4],["avr", 4],["avr.", 4],["mai", 5],["juin", 6],["jun", 6],["jun.", 6],["juillet", 7],["aout", 8],["août", 8],["septembre", 9],["octobre", 10],["novembre", 11],["decembre", 12],["décembre", 12],["janv", 1],["janv.", 1],["jan", 1],["jan.", 1],["fevr", 2],["fevr.", 2],["févr.", 2],["févr", 2],["fev", 2],["fev.", 2],["juil", 7],["jul", 7],["jul.", 7],["sep", 9],["sep.", 9],["sept.", 9],["sept", 9],["oct", 10],["oct.", 10],["nov", 11],["nov.", 11],["dec", 12],["dec.", 12],["déc.", 12],["déc", 12],["01", 1],["02", 2],["03", 3],["04", 4],["05", 5],["06", 6],["07", 7],["08", 8],["09", 9]]); - export const Numbers: ReadonlyMap = new Map([["zero", 0],["un", 1],["une", 1],["a", 1],["deux", 2],["trois", 3],["quatre", 4],["cinq", 5],["six", 6],["sept", 7],["huit", 8],["neuf", 9],["dix", 10],["onze", 11],["douze", 12],["treize", 13],["quatorze", 14],["quinze", 15],["seize", 16],["dix-sept", 17],["dix-huit", 18],["dix-neuf", 19],["vingt-et-un", 21],["vingt et un", 21],["vingt", 20],["vingt deux", 22],["vingt-deux", 22],["vingt trois", 23],["vingt-trois", 23],["vingt quatre", 24],["vingt-quatre", 24],["vingt cinq", 25],["vingt-cinq", 25],["vingt six", 26],["vingt-six", 26],["vingt sept", 27],["vingt-sept", 27],["vingt huit", 28],["vingt-huit", 28],["vingt neuf", 29],["vingt-neuf", 29],["trente", 30],["trente et un", 31],["trente-et-un", 31],["trente deux", 32],["trente-deux", 32],["trente trois", 33],["trente-trois", 33],["trente quatre", 34],["trente-quatre", 34],["trente cinq", 35],["trente-cinq", 35],["trente six", 36],["trente-six", 36],["trente sept", 37],["trente-sept", 37],["trente huit", 38],["trente-huit", 38],["trente neuf", 39],["trente-neuf", 39],["quarante", 40],["quarante et un", 41],["quarante-et-un", 41],["quarante deux", 42],["quarante-duex", 42],["quarante trois", 43],["quarante-trois", 43],["quarante quatre", 44],["quarante-quatre", 44],["quarante cinq", 45],["quarante-cinq", 45],["quarante six", 46],["quarante-six", 46],["quarante sept", 47],["quarante-sept", 47],["quarante huit", 48],["quarante-huit", 48],["quarante neuf", 49],["quarante-neuf", 49],["cinquante", 50],["cinquante et un", 51],["cinquante-et-un", 51],["cinquante deux", 52],["cinquante-deux", 52],["cinquante trois", 53],["cinquante-trois", 53],["cinquante quatre", 54],["cinquante-quatre", 54],["cinquante cinq", 55],["cinquante-cinq", 55],["cinquante six", 56],["cinquante-six", 56],["cinquante sept", 57],["cinquante-sept", 57],["cinquante huit", 58],["cinquante-huit", 58],["cinquante neuf", 59],["cinquante-neuf", 59],["soixante", 60],["soixante et un", 61],["soixante-et-un", 61],["soixante deux", 62],["soixante-deux", 62],["soixante trois", 63],["soixante-trois", 63],["soixante quatre", 64],["soixante-quatre", 64],["soixante cinq", 65],["soixante-cinq", 65],["soixante six", 66],["soixante-six", 66],["soixante sept", 67],["soixante-sept", 67],["soixante huit", 68],["soixante-huit", 68],["soixante neuf", 69],["soixante-neuf", 69],["soixante dix", 70],["soixante-dix", 70],["soixante et onze", 71],["soixante-et-onze", 71],["soixante douze", 72],["soixante-douze", 72],["soixante treize", 73],["soixante-treize", 73],["soixante quatorze", 74],["soixante-quatorze", 74],["soixante quinze", 75],["soixante-quinze", 75],["soixante seize", 76],["soixante-seize", 76],["soixante dix sept", 77],["soixante-dix-sept", 77],["soixante dix huit", 78],["soixante-dix-huit", 78],["soixante dix neuf", 79],["soixante-dix-neuf", 79],["quatre vingt", 80],["quatre-vingt", 80],["quatre vingt un", 81],["quatre-vingt-un", 81],["quatre vingt deux", 82],["quatre-vingt-duex", 82],["quatre vingt trois", 83],["quatre-vingt-trois", 83],["quatre vingt quatre", 84],["quatre-vingt-quatre", 84],["quatre vingt cinq", 85],["quatre-vingt-cinq", 85],["quatre vingt six", 86],["quatre-vingt-six", 86],["quatre vingt sept", 87],["quatre-vingt-sept", 87],["quatre vingt huit", 88],["quatre-vingt-huit", 88],["quatre vingt neuf", 89],["quatre-vingt-neuf", 89],["quatre vingt dix", 90],["quatre-vingt-dix", 90],["quatre vingt onze", 91],["quatre-vingt-onze", 91],["quatre vingt douze", 92],["quatre-vingt-douze", 92],["quatre vingt treize", 93],["quatre-vingt-treize", 93],["quatre vingt quatorze", 94],["quatre-vingt-quatorze", 94],["quatre vingt quinze", 95],["quatre-vingt-quinze", 95],["quatre vingt seize", 96],["quatre-vingt-seize", 96],["quatre vingt dix sept", 97],["quatre-vingt-dix-sept", 97],["quatre vingt dix huit", 98],["quatre-vingt-dix-huit", 98],["quatre vingt dix neuf", 99],["quatre-vingt-dix-neuf", 99],["cent", 100]]); - export const DayOfMonth: ReadonlyMap = new Map([["1er", 1],["2e", 2],["3e", 3],["4e", 4],["5e", 5],["6e", 6],["7e", 7],["8e", 8],["9e", 9],["10e", 10],["11e", 11],["12e", 12],["13e", 13],["14e", 14],["15e", 15],["16e", 16],["17e", 17],["18e", 18],["19e", 19],["20e", 20],["21e", 21],["22e", 22],["23e", 23],["24e", 24],["25e", 25],["26e", 26],["27e", 27],["28e", 28],["29e", 29],["30e", 30],["31e", 31]]); - export const DoubleNumbers: ReadonlyMap = new Map([["demi", 0.5],["quart", 0.25]]); - export const HolidayNames: ReadonlyMap = new Map([["fathers", ["peres","pères","fêtedespères","fetedesperes"]],["mothers", ["fêtedesmères","fetedesmeres"]],["thanksgiving", ["lactiondegrace","lactiondegrâce","jourdethanksgiving","thanksgiving"]],["martinlutherking", ["journeemartinlutherking","martinlutherkingjr"]],["washingtonsbirthday", ["washingtonsbirthday","washingtonbirthday"]],["canberra", ["canberraday"]],["labour", ["fetedetravail","travail","fetedutravail"]],["columbus", ["columbusday"]],["memorial", ["jourcommémoratif","jourcommemoratif"]],["yuandan", ["yuandan","nouvelanchinois"]],["maosbirthday", ["maosbirthday"]],["teachersday", ["teachersday","teacherday"]],["singleday", ["singleday"]],["allsaintsday", ["allsaintsday"]],["youthday", ["youthday"]],["childrenday", ["childrenday","childday"]],["femaleday", ["femaleday"]],["treeplantingday", ["treeplantingday"]],["arborday", ["arborday"]],["girlsday", ["girlsday"]],["whiteloverday", ["whiteloverday"]],["loverday", ["loverday"]],["christmas", ["noel","noël"]],["xmas", ["xmas"]],["newyear", ["nouvellesannees","nouvelan"]],["newyearday", ["jourdunouvelan"]],["newyearsday", ["jourdel'an","jourpremierdelannee","jourpremierdelannée"]],["inaugurationday", ["jourd'inaugueration","inaugueration"]],["groundhougday", ["marmotte"]],["valentinesday", ["lasaint-valentin","lasaintvalentin"]],["stpatrickday", ["stpatrickday"]],["aprilfools", ["poissond'avril"]],["stgeorgeday", ["stgeorgeday"]],["mayday", ["premier-mai","ler-mai","1-mai"]],["cincodemayoday", ["cincodemayo"]],["baptisteday", ["bapteme","baptême"]],["usindependenceday", ["l'independanceamericaine","lindépendanceaméricaine"]],["independenceday", ["l'indépendance","lindependance"]],["bastilleday", ["laprisedelabastille","bastille"]],["halloweenday", ["halloween"]],["allhallowday", ["allhallowday"]],["allsoulsday", ["allsoulsday"]],["guyfawkesday", ["guyfawkesday"]],["veteransday", ["veteransday"]],["christmaseve", ["reveillondenoel","réveillondenoël","veilledenoel","veilledenoël"]],["newyeareve", ["réveillondenouvelan","reveillondenouvelan","lasaint-sylvestre","lasaintsylvestre"]]]); - export const NightRegex = `\\b(minuit|nuit)\\b`; - export const WrittenDecades: ReadonlyMap = new Map([["", 0]]); - export const SpecialDecadeCases: ReadonlyMap = new Map([["", 0]]); - export const DefaultLanguageFallback = `DMY`; - export const DurationDateRestrictions = [ ]; - export const AmbiguityFiltersDict: ReadonlyMap = new Map([["^\\d{4}$", "(\\d\\.\\d{4}|\\d{4}\\.\\d)"],["^([eé]t[eé])$", "(? = new Map([["heures?$", "\\b(pour|durée\\s+de|pendant)\\s+(\\S+\\s+){1,2}heures?\\b"]]); - export const MorningTermList = [ "matinee","matin","matinée" ]; - export const AfternoonTermList = [ "apres-midi","apres midi","après midi","après-midi" ]; - export const EveningTermList = [ "soir","soiree","soirée" ]; - export const DaytimeTermList = [ "jour","journee","journée" ]; - export const NightTermList = [ "nuit" ]; - export const SameDayTerms = [ "aujourd'hui","auj" ]; - export const PlusOneDayTerms = [ "demain","a2m1","lendemain","jour suivant" ]; - export const MinusOneDayTerms = [ "hier","dernier" ]; - export const PlusTwoDayTerms = [ "après demain","après-demain","apres-demain" ]; - export const MinusTwoDayTerms = [ "avant-hier","avant hier" ]; - export const FutureStartTerms = [ "cette" ]; - export const FutureEndTerms = [ "prochaine","prochain" ]; - export const LastCardinalTerms = [ "dernières","dernière","dernieres","derniere","dernier" ]; - export const MonthTerms = [ "mois" ]; - export const MonthToDateTerms = [ "mois à ce jour" ]; - export const WeekendTerms = [ "fin de semaine","le weekend" ]; - export const WeekTerms = [ "semaine" ]; - export const YearTerms = [ "années","ans","an","l'annees","l'annee" ]; - export const YearToDateTerms = [ "année à ce jour","an à ce jour" ]; -} diff --git a/JavaScript/packages/recognizers-date-time/src/resources/portugueseDateTime.ts b/JavaScript/packages/recognizers-date-time/src/resources/portugueseDateTime.ts deleted file mode 100644 index a1dca67b4a..0000000000 --- a/JavaScript/packages/recognizers-date-time/src/resources/portugueseDateTime.ts +++ /dev/null @@ -1,284 +0,0 @@ -// ------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// ------------------------------------------------------------------------------ - -import { BaseDateTime } from "./baseDateTime"; -export namespace PortugueseDateTime { - export const LangMarker = `Por`; - export const CheckBothBeforeAfter = false; - export const TillRegex = `(?\\b(at[eé]h?|[aà]s|ao?)\\b|--|-|—|——)(\\s+\\b(o|[aà](s)?)\\b)?`; - export const RangeConnectorRegex = `(?(e\\s*(([àa]s?)|o)?)|${BaseDateTime.RangeConnectorSymbolRegex})`; - export const DayRegex = `(?(?:3[0-1]|[1-2]\\d|0?[1-9]))(?=\\b|t)`; - export const WrittenDayRegex = `(?(vinte\\s+e\\s+)?(um|dois|tr[eê]s|quatro|cinco|seis|sete|oito|nove)|dez|onze|doze|treze|(c|qu)atorze|quinze|dez[ae](s(seis|sete)|nove)|dezoito|vinte|trinta(\\s+e\\s+um)?)`; - export const MonthNumRegex = `(?1[0-2]|(0)?[1-9])\\b`; - export const AmDescRegex = `(${BaseDateTime.BaseAmDescRegex})`; - export const PmDescRegex = `(${BaseDateTime.BasePmDescRegex})`; - export const AmPmDescRegex = `(${BaseDateTime.BaseAmPmDescRegex})`; - export const OclockRegex = `(?em\\s+ponto)`; - export const DescRegex = `((horas\\s+)?(?${AmDescRegex}|${PmDescRegex})|${OclockRegex})`; - export const OfPrepositionRegex = `(\\bd(o|a|e)s?\\b)`; - export const AfterNextSuffixRegex = `\\b(que\\s+vem|passad[oa])\\b`; - export const RangePrefixRegex = `((de(sde)?|das?|entre)\\s+(a(s)?\\s+)?)`; - export const TwoDigitYearRegex = `\\b(?([0-9]\\d))(?!(\\s*((\\:\\d)|${AmDescRegex}|${PmDescRegex}|\\.\\d)))\\b`; - export const RelativeRegex = `(?((n?est[ae]s?|pr[oó]xim[oa]s?|([uú]ltim[ao]s?))(\\s+fina(l|is)\\s+d[eao])?)|(fina(l|is)\\s+d[eao]))\\b`; - export const StrictRelativeRegex = `(?((n?est[ae]|pr[oó]xim[oa]|([uú]ltim(o|as|os)))(\\s+fina(l|is)\\s+d[eao])?)|(fina(l|is)\\s+d[eao]))\\b`; - export const WrittenOneToNineRegex = `(uma?|dois|duas|tr[eê]s|quatro|cinco|seis|sete|oito|nove)`; - export const WrittenOneHundredToNineHundredRegex = `(duzent[oa]s|trezent[oa]s|[cq]uatrocent[ao]s|quinhent[ao]s|seiscent[ao]s|setecent[ao]s|oitocent[ao]s|novecent[ao]s|cem|(?((dois\\s+)?mil)((\\s+e)?\\s+${WrittenOneHundredToNineHundredRegex})?((\\s+e)?\\s+${WrittenOneToNinetyNineRegex})?)`; - export const YearRegex = `(${BaseDateTime.FourDigitYearRegex}|${FullTextYearRegex})`; - export const RelativeMonthRegex = `(?([nd]?es[st]e|pr[óo]ximo|passsado|[uú]ltimo)\\s+m[eê]s)\\b`; - export const MonthRegex = `(?abr(il)?|ago(sto)?|dez(embro)?|fev(ereiro)?|jan(eiro)?|ju[ln](ho)?|mar([çc]o)?|maio?|nov(embro)?|out(ubro)?|sep?t(embro)?)`; - export const MonthSuffixRegex = `(?((em|no)\\s+|d[eo]\\s+)?(${RelativeMonthRegex}|${MonthRegex}))`; - export const DateUnitRegex = `(?(?m[êe]s)(?es)?|(ano|(?semana|dia))(?s)?)\\b`; - export const PastRegex = `(?\\b(passad[ao](s)?|[uú]ltim[oa](s)?|anterior(es)?|h[aá]|pr[ée]vi[oa](s)?)\\b)`; - export const FutureRegex = `(?\\b(seguinte(s)?|pr[oó]xim[oa](s)?|daqui\\s+a)\\b)`; - export const SimpleCasesRegex = `\\b((desde\\s+[oa]|desde|d[oa])\\s+)?(dia\\s+)?(${DayRegex})\\s*${TillRegex}\\s*(o dia\\s+)?(${DayRegex})\\s+${MonthSuffixRegex}((\\s+|\\s*,\\s*)${YearRegex})?\\b`; - export const MonthFrontSimpleCasesRegex = `\\b${MonthSuffixRegex}\\s+((desde\\s+[oa]|desde|d[oa])\\s+)?(dia\\s+)?(${DayRegex})\\s*${TillRegex}\\s*(${DayRegex})((\\s+|\\s*,\\s*)${YearRegex})?\\b`; - export const MonthFrontBetweenRegex = `\\b${MonthSuffixRegex}\\s+((entre|entre\\s+[oa]s?)\\s+)(dias?\\s+)?(${DayRegex})\\s*${RangeConnectorRegex}\\s*(${DayRegex})((\\s+|\\s*,\\s*)${YearRegex})?\\b`; - export const DayBetweenRegex = `\\b((entre|entre\\s+[oa]s?)\\s+)(dia\\s+)?(${DayRegex})\\s*${RangeConnectorRegex}\\s*(${DayRegex})\\s+${MonthSuffixRegex}((\\s+|\\s*,\\s*)${YearRegex})?\\b`; - export const SpecialYearPrefixes = `((do\\s+)?calend[aá]rio|civil|(?fiscal|escolar|letivo))`; - export const OneWordPeriodRegex = `\\b(((pr[oó]xim[oa]?|[nd]?es[st]e|aquel[ea]|[uú]ltim[oa]?|em)\\s+)?(?abr(il)?|ago(sto)?|dez(embro)?|fev(ereiro)?|jan(eiro)?|ju[ln](ho)?|mar([çc]o)?|maio?|nov(embro)?|out(ubro)?|sep?t(embro)?)|(${RelativeRegex}\\s+)?(ano\\s+${SpecialYearPrefixes}|${SpecialYearPrefixes}\\s+ano)|(?<=\\b(de|do|da|o|a)\\s+)?(pr[oó]xim[oa](s)?|[uú]ltim[oa]s?|est(e|a))\\s+(fim de semana|fins de semana|semana|m[êe]s|ano)|fim de semana|fins de semana|(m[êe]s|anos)? [àa] data)\\b`; - export const MonthWithYearRegex = `\\b((((pr[oó]xim[oa](s)?|[nd]?es[st]e|aquele|[uú]ltim[oa]?|em)\\s+)?${MonthRegex}|((n?o\\s+)?(?primeiro|1o|segundo|2o|terceiro|3o|[cq]uarto|4o|quinto|5o|sexto|6o|s[eé]timo|7o|oitavo|8o|nono|9o|d[eé]cimo(\\s+(primeiro|segundo))?|10o|11o|12o|[uú]ltimo)\\s+m[eê]s(?=\\s+(d[aeo]|[ao]))))\\s+((d[aeo]|[ao])\\s+)?(${YearRegex}|${TwoDigitYearRegex}|(?pr[oó]ximo(s)?|[uú]ltimo?|[nd]?es[st]e)\\s+ano))\\b`; - export const MonthNumWithYearRegex = `(${YearRegex}(\\s*?)[/\\-\\.](\\s*?)${MonthNumRegex})|(${MonthNumRegex}(\\s*?)[/\\-](\\s*?)${YearRegex})`; - export const WeekOfMonthRegex = `(?(a|na\\s+)?(?primeira?|1a|segunda|2a|terceira|3a|[qc]uarta|4a|quinta|5a|[uú]ltima)\\s+semana\\s+${MonthSuffixRegex})`; - export const WeekOfYearRegex = `(?(a|na\\s+)?(?primeira?|1a|segunda|2a|terceira|3a|[qc]uarta|4a|quinta|5a|[uú]ltima?)\\s+semana(\\s+d[oe]?)?\\s+(${YearRegex}|(?pr[oó]ximo|[uú]ltimo|[nd]?es[st]e)\\s+ano))`; - export const OfYearRegex = `\\b((d[aeo]?|[ao])\\s*(${YearRegex}|${StrictRelativeRegex}\\s+ano))\\b`; - export const FirstLastRegex = `\\b(n?[ao]s?\\s+)?((?primeir[ao]s?)|(?[uú]ltim[ao]s?))\\b`; - export const FollowedDateUnit = `^\\s*${DateUnitRegex}`; - export const NumberCombinedWithDateUnit = `\\b(?\\d+(\\.\\d*)?)${DateUnitRegex}`; - export const QuarterRegex = `(n?o\\s+)?(?primeiro|1[oº]|segundo|2[oº]|terceiro|3[oº]|[qc]uarto|4[oº])\\s+trimestre(\\s+d[oe]|\\s*,\\s*)?\\s+(${YearRegex}|(?pr[oó]ximo(s)?|[uú]ltimo?|[nd]?es[st]e)\\s+ano)`; - export const QuarterRegexYearFront = `(${YearRegex}|(?pr[oó]ximo(s)?|[uú]ltimo?|[nd]?es[st]e)\\s+ano)\\s+(n?o\\s+)?(?(primeiro)|1[oº]|segundo|2[oº]|terceiro|3[oº]|[qc]uarto|4[oº])\\s+trimestre`; - export const AllHalfYearRegex = `^[.]`; - export const PrefixDayRegex = `^[.]`; - export const SeasonRegex = `\\b(?(([uú]ltim[oa]|[nd]?es[st][ea]|n?[oa]|(pr[oó]xim[oa]s?|seguinte))\\s+)?(?primavera|ver[ãa]o|outono|inverno)((\\s+)?(seguinte|((de\\s+|,)?\\s*${YearRegex})|((do\\s+)?(?pr[oó]ximo|[uú]ltimo|[nd]?es[st]e)\\s+ano)))?)\\b`; - export const WhichWeekRegex = `\\b(semana)(\\s*)(?5[0-3]|[1-4]\\d|0?[1-9])(\\s+(de|do)\\s+(${YearRegex}|(?pr[oó]ximo|[uú]ltimo|[nd]?es[st]e)\\s+ano|ano\\s+(?passado)))?\\b`; - export const WeekOfRegex = `(semana)(\\s*)((do|da|de))`; - export const MonthOfRegex = `(mes)(\\s*)((do|da|de))`; - export const RangeUnitRegex = `\\b(?anos?|meses|m[êe]s|semanas?)\\b`; - export const BeforeAfterRegex = `^[.]`; - export const UpcomingPrefixRegex = `.^`; - export const NextPrefixRegex = `(pr[oó]xim[oa]s?|seguinte|${UpcomingPrefixRegex})\\b`; - export const InConnectorRegex = `\\b(em)\\b`; - export const SinceYearSuffixRegex = `^[.]`; - export const WithinNextPrefixRegex = `\\b(dentro\\s+d(e|as)(\\s+(?${NextPrefixRegex}))?)\\b`; - export const TodayNowRegex = `\\b(hoje|agora)\\b`; - export const CenturySuffixRegex = `^[.]`; - export const FromRegex = `(de(sde)?(\\s*a(s)?)?)$`; - export const BetweenRegex = `(entre\\s*([oa](s)?)?)`; - export const WeekDayRegex = `\\b(?(domingos?|(segunda|ter[çc]a|quarta|quinta|sexta)s?([-\\s+]feiras?)?|s[aá]bados?|(2|3|4|5|6)[aª])\\b|(dom|seg|ter[cç]|qua|qui|sex|sab)\\b(\\.?(?=\\s|,|;|$)))`; - export const OnRegex = `(?<=\\b(em|no)\\s+)(${DayRegex}s?)\\b`; - export const RelaxedOnRegex = `((?<=\\b(em|[nd][oa])\\s+)(dia\\s+)?(${DayRegex}s?)|dia\\s+${DayRegex}s?)\\b(?!\\s*[/\\\\\\-\\.,:\\s]\\s*(\\d|(de\\s+)?${MonthRegex}))`; - export const ThisRegex = `\\b(([nd]?es[st][ea]\\s*)${WeekDayRegex})|(${WeekDayRegex}\\s*([nd]?es[st]a\\s+semana))\\b`; - export const LastDateRegex = `\\b(([uú]ltim[ao])\\s*${WeekDayRegex})|(${WeekDayRegex}(\\s+(([nd]?es[st]a|[nd]a)\\s+([uú]ltima\\s+)?semana)))\\b`; - export const NextDateRegex = `\\b(((pr[oó]xim[oa]|seguinte)\\s*)${WeekDayRegex})|(${WeekDayRegex}((\\s+(pr[oó]xim[oa]|seguinte))|(\\s+(da\\s+)?(semana\\s+seguinte|pr[oó]xima\\s+semana))))\\b`; - export const SpecialDayRegex = `\\b((d?o\\s+)?(dia\\s+antes\\s+de\\s+ontem|antes\\s+de\\s+ontem|anteontem)|((d?o\\s+)?(dia\\s+|depois\\s+|dia\\s+depois\\s+)?de\\s+amanh[aã])|(o\\s)?dia\\s+seguinte|(o\\s)?pr[oó]ximo\\s+dia|(o\\s+)?[uú]ltimo\\s+dia|ontem|amanh[ãa]|hoje)|(do\\s+dia$)\\b`; - export const SpecialDayWithNumRegex = `^[.]`; - export const ForTheRegex = `.^`; - export const FlexibleDayRegex = `(?([a-z]+\\s)?(${WrittenDayRegex}|${DayRegex}))`; - export const WeekDayAndDayOfMonthRegex = `\\b${WeekDayRegex}\\s+(dia\\s+${FlexibleDayRegex})\\b`; - export const WeekDayAndDayRegex = `\\b${WeekDayRegex}\\s+(${DayRegex})(?!([-:/]|\\.\\d|(\\s+(${AmDescRegex}|${PmDescRegex}|${OclockRegex}))))\\b`; - export const WeekDayOfMonthRegex = `(?(n?[ao]\\s+)?(?primeir[ao]|1[ao]|segund[ao]|2[ao]|terceir[ao]|3[ao]|[qc]uart[ao]|4[ao]|quint[ao]|5[ao]|[uú]ltim[ao])\\s+${WeekDayRegex}\\s+${MonthSuffixRegex})`; - export const RelativeWeekDayRegex = `^[.]`; - export const AmbiguousRangeModifierPrefix = `^[.]`; - export const NumberEndingPattern = `^[.]`; - export const SpecialDateRegex = `(?<=\\bno\\s+)${DayRegex}\\b`; - export const OfMonthRegex = `^(\\s*de)?\\s*${MonthSuffixRegex}`; - export const MonthEndRegex = `(${MonthRegex}\\s*(o)?\\s*$)`; - export const WeekDayEnd = `${WeekDayRegex}\\s*,?\\s*$`; - export const WeekDayStart = `^\\b$`; - export const DateYearRegex = `(?${YearRegex}|${TwoDigitYearRegex})`; - export const DateExtractor1 = `\\b(${WeekDayRegex}(\\s+|\\s*,\\s*))?${DayRegex}((\\s*(de)|[/\\\\\\.\\- ])\\s*)?${MonthRegex}\\b`; - export const DateExtractor2 = `\\b(${WeekDayRegex}(\\s+|\\s*,\\s*))?(${DayRegex}(\\s*([/\\.\\-]|de)?\\s*${MonthRegex}|\\s+de\\s+${MonthNumRegex})(\\s*([,./-]|de|\\s+)\\s*)${DateYearRegex}|${BaseDateTime.FourDigitYearRegex}\\s*[/\\.\\- ]\\s*${DayRegex}\\s*[/\\.\\- ]\\s*${MonthRegex})\\b`; - export const DateExtractor3 = `\\b(${WeekDayRegex}(\\s+|\\s*,\\s*))?${MonthRegex}(\\s*[/\\.\\- ]\\s*|\\s+de\\s+)${DayRegex}(?!\\s*\\-\\s*\\d{2}\\b)((\\s*[/\\.\\- ]\\s*|\\s+de\\s+)${DateYearRegex})?\\b`; - export const DateExtractor4 = `\\b(${WeekDayRegex}(\\s+|\\s*,\\s*))?${MonthNumRegex}\\s*[/\\\\\\-]\\s*${DayRegex}\\s*[/\\\\\\-]\\s*${DateYearRegex}(?!\\s*[/\\\\\\-\\.]\\s*\\d+)`; - export const DateExtractor5 = `\\b(${WeekDayRegex}(\\s+|\\s*,\\s*))?${DayRegex}\\s*[/\\\\\\-\\.]\\s*(${MonthNumRegex}|${MonthRegex})\\s*[/\\\\\\-\\.]\\s*${DateYearRegex}(?!\\s*[/\\\\\\-\\.]\\s*\\d+)`; - export const DateExtractor6 = `(?<=\\b(em|no|o)\\s+)${MonthNumRegex}[\\-\\.]${DayRegex}${BaseDateTime.CheckDecimalRegex}\\b`; - export const DateExtractor7 = `\\b(${WeekDayRegex}(\\s+|\\s*,\\s*))?${MonthNumRegex}\\s*/\\s*${DayRegex}((\\s+|\\s*(,|de)\\s*)${DateYearRegex})?${BaseDateTime.CheckDecimalRegex}\\b`; - export const DateExtractor8 = `(?<=\\b(em|no|o)\\s+)${DayRegex}[\\\\\\-]${MonthNumRegex}${BaseDateTime.CheckDecimalRegex}\\b`; - export const DateExtractor9 = `\\b(${WeekDayRegex}(\\s+|\\s*,\\s*))?${DayRegex}\\s*/\\s*${MonthNumRegex}((\\s+|\\s*(,|de)\\s*)${DateYearRegex})?${BaseDateTime.CheckDecimalRegex}\\b`; - export const DateExtractor10 = `\\b(${WeekDayRegex}(\\s+|\\s*,\\s*))?(${YearRegex}\\s*[/\\\\\\-\\.]\\s*(${MonthNumRegex}|${MonthRegex})\\s*[/\\\\\\-\\.]\\s*${DayRegex}|${MonthRegex}\\s*[/\\\\\\-\\.]\\s*${BaseDateTime.FourDigitYearRegex}\\s*[/\\\\\\-\\.]\\s*${DayRegex}|${DayRegex}\\s*[/\\\\\\-\\.]\\s*${BaseDateTime.FourDigitYearRegex}\\s*[/\\\\\\-\\.]\\s*${MonthRegex})(?!\\s*[/\\\\\\-\\.:]\\s*\\d+)`; - export const DateExtractor11 = `(?<=\\b(dia)\\s+)${DayRegex}`; - export const HourNumRegex = `\\b(?zero|uma|duas|tr[êe]s|[qc]uatro|cinco|seis|sete|oito|nove|dez|onze|doze)\\b`; - export const MinuteNumRegex = `(?um|dois|tr[êe]s|[qc]uatro|cinco|seis|sete|oito|nove|dez|onze|doze|treze|catorze|quatorze|quinze|dez[ea]sseis|dez[ea]sete|dezoito|dez[ea]nove|vinte|trinta|[qc]uarenta|cin[qc]uenta)`; - export const DeltaMinuteNumRegex = `(?um|dois|tr[êe]s|[qc]uatro|cinco|seis|sete|oito|nove|dez|onze|doze|treze|catorze|quatorze|quinze|dez[ea]sseis|dez[ea]sete|dezoito|dez[ea]nove|vinte|trinta|[qc]uarenta|cin[qc]uenta)`; - export const PmRegex = `(horas\\s+)?(?((pela|de|da|\\b[àa]\\b|na)\\s+(tarde|noite)))|((depois\\s+do|ap[óo]s\\s+o)\\s+(almo[çc]o|meio dia|meio-dia))`; - export const AmRegex = `(horas\\s+)?(?(pela|de|da|na)\\s+(manh[ãa]|madrugada))`; - export const AmTimeRegex = `(?([dn]?es[st]a|(pela|de|da|na))\\s+(manh[ãa]|madrugada))`; - export const PmTimeRegex = `(?(([dn]?es[st]a|\\b[àa]\\b|(pela|de|da|na))\\s+(tarde|noite)))|((depois\\s+do|ap[óo]s\\s+o)\\s+(almo[çc]o|meio dia|meio-dia))`; - export const LessThanOneHour = `(?((\\s+e\\s+)?(quinze|(um\\s+|dois\\s+|tr[êes]\\s+)?quartos?)|quinze|(\\s*)(um\\s+|dois\\s+|tr[êes]\\s+)?quartos?|(\\s+e\\s+)(meia|trinta)|(${BaseDateTime.DeltaMinuteRegex}|${DeltaMinuteNumRegex})(\\s+(minuto|minutos|min|mins))?))`; - export const LessThanOneHourSuffix = `(?((\\s+e\\s+)?(quinze|(um\\s+|dois\\s+|tr[êes]\\s+)?quartos?)|quinze|(\\s*)(um\\s+|dois\\s+|tr[êes]\\s+)?quartos?|(\\s+e\\s+)(meia|trinta)))`; - export const TensTimeRegex = `(?dez|vinte|trinta|[qc]uarenta|cin[qc]uenta)`; - export const WrittenTimeRegex = `(?(${HourNumRegex}\\s*((e|menos)\\s+)?((${TensTimeRegex}((\\s*e\\s+)?${MinuteNumRegex}))|${MinuteNumRegex}))|((${MinuteNumRegex}|(${TensTimeRegex}((\\s*e\\s+)?${MinuteNumRegex})?))\\s*((para as|pras|antes da|antes das)\\s+)?(${HourNumRegex}|${BaseDateTime.HourRegex})))`; - export const TimePrefix = `(?${LessThanOneHour}(\\s+(passad[ao]s)\\s+(as)?|\\s+depois\\s+(das?|do)|\\s+pras?|\\s+(para|antes)?\\s+([àa]s?)))`; - export const TimeSuffix = `(?(${LessThanOneHour}\\s+)?(${AmRegex}|${PmRegex}|${OclockRegex}))`; - export const BasicTime = `(?${WrittenTimeRegex}|${HourNumRegex}|${BaseDateTime.HourRegex}:${BaseDateTime.MinuteRegex}(:${BaseDateTime.SecondRegex})?|${BaseDateTime.HourRegex})`; - export const MidnightRegex = `(?meia\\s*(-\\s*)?noite)`; - export const MidmorningRegex = `(?meio\\s+da\\s+manhã)`; - export const MidEarlyMorning = `(?meio\\s+da\\s+madrugada)`; - export const MidafternoonRegex = `(?meio\\s+da\\s+tarde)`; - export const MiddayRegex = `(?meio\\s*(-\\s*)?dia)`; - export const MidTimeRegex = `(?(${MidnightRegex}|${MidmorningRegex}|${MidEarlyMorning}|${MidafternoonRegex}|${MiddayRegex}))`; - export const AtRegex = `\\b(((?<=\\b(d?[aà]s?)\\s+)(${WrittenTimeRegex}|${HourNumRegex}|${BaseDateTime.HourRegex}(\\s+e\\s+${BaseDateTime.MinuteRegex})?)(\\s+horas?|\\s*h\\b)?|(?<=\\b(s(er)?[aã]o|v[aã]o\\s+ser|^[eé]h?)\\s+|^\\s*)(${WrittenTimeRegex}|${HourNumRegex}|${BaseDateTime.HourRegex})(\\s+horas?|\\s*h\\b))(\\s+${OclockRegex})?|${MidTimeRegex})\\b`; - export const ConnectNumRegex = `(${BaseDateTime.HourRegex}(?[0-5][0-9])\\s*${DescRegex})`; - export const TimeRegex1 = `(\\b${TimePrefix}\\s+)?(${WrittenTimeRegex}|${HourNumRegex}|${BaseDateTime.HourRegex})\\s*(${DescRegex})`; - export const TimeRegex2 = `(\\b${TimePrefix}\\s+)?(t)?${BaseDateTime.HourRegex}(\\s*)?:(\\s*)?${BaseDateTime.MinuteRegex}((\\s*)?:(\\s*)?${BaseDateTime.SecondRegex})?((\\s*${DescRegex})|\\b)`; - export const TimeRegex3 = `(\\b${TimePrefix}\\s+)?${BaseDateTime.HourRegex}\\.${BaseDateTime.MinuteRegex}(\\s*${DescRegex})`; - export const TimeRegex4 = `\\b((${DescRegex}\\s*)?((${TimePrefix}\\s*)(${HourNumRegex}|${BaseDateTime.HourRegex})|(${HourNumRegex}|${BaseDateTime.HourRegex})(\\s+${TensTimeRegex}(\\s+e\\s+)?${MinuteNumRegex}?)|${BasicTime}(\\s*${DescRegex})?(?${LessThanOneHourSuffix}))(\\s*(${DescRegex}|${OclockRegex}))?)\\b`; - export const TimeRegex5 = `\\b(${TimePrefix}|${BasicTime}(?${LessThanOneHourSuffix}))\\s+(\\s*${DescRegex})?${BasicTime}?\\s*${TimeSuffix}\\b`; - export const TimeRegex6 = `(${BasicTime}(\\s*${DescRegex})?\\s+${TimeSuffix}\\b)`; - export const TimeRegex7 = `\\b${TimeSuffix}\\s+[àa]s?\\s+${BasicTime}((\\s*${DescRegex})|\\b)`; - export const TimeRegex8 = `\\b${TimeSuffix}\\s+${BasicTime}((\\s*${DescRegex})|\\b)`; - export const TimeRegex9 = `\\b(?${HourNumRegex}\\s+(${TensTimeRegex}\\s*)(e\\s+)?${MinuteNumRegex}?)\\b`; - export const TimeRegex11 = `\\b(${WrittenTimeRegex})(\\s+${DescRegex})?\\b`; - export const TimeRegex12 = `(\\b${TimePrefix}\\s+)?${BaseDateTime.HourRegex}(\\s*h\\s*)${BaseDateTime.MinuteRegex}(\\s*${DescRegex})?`; - export const PrepositionRegex = `(?([àa]s?|em|por|pel[ao]|n[ao]|de|d[ao]?)?$)`; - export const NowRegex = `\\b(?((logo|exatamente)\\s+)?agora(\\s+mesmo)?|neste\\s+momento|(assim\\s+que|t[ãa]o\\s+cedo\\s+quanto)\\s+(poss[ií]vel|possas?|possamos)|o\\s+mais\\s+(cedo|r[aá]pido)\\s+poss[íi]vel|recentemente|previamente)\\b`; - export const SuffixRegex = `^\\s*((e|a|em|por|pel[ao]|n[ao]|de)\\s+)?(manh[ãa]|madrugada|meio\\s*dia|tarde|noite)\\b`; - export const TimeOfDayRegex = `\\b(?manh[ãa]|madrugada|tarde|noite|((depois\\s+do|ap[óo]s\\s+o)\\s+(almo[çc]o|meio[ -]dia)))\\b`; - export const SpecificTimeOfDayRegex = `\\b(((((a)?\\s+|[nd]?es[st]a|seguinte|pr[oó]xim[oa]|[uú]ltim[oa])\\s+)?${TimeOfDayRegex}))\\b`; - export const TimeOfTodayAfterRegex = `^\\s*(,\\s*)?([àa]|em|por|pel[ao]|de|no|na?\\s+)?${SpecificTimeOfDayRegex}`; - export const TimeOfTodayBeforeRegex = `(${SpecificTimeOfDayRegex}(\\s*,)?(\\s+([àa]s|para))?\\s*)`; - export const SimpleTimeOfTodayAfterRegex = `(${HourNumRegex}|${BaseDateTime.HourRegex})\\s*(,\\s*)?${SpecificTimeOfDayRegex}`; - export const SimpleTimeOfTodayBeforeRegex = `(${SpecificTimeOfDayRegex}(\\s*,)?(\\s+([àa]s|((cerca|perto|ao\\s+redor|por\\s+volta)\\s+(de|das))))?\\s*(${HourNumRegex}|${BaseDateTime.HourRegex}))`; - export const SpecificEndOfRegex = `([na]o\\s+)?(fi(m|nal)|t[ée]rmin(o|ar))(\\s+d?o(\\s+dia)?(\\s+de)?)?\\s*$`; - export const UnspecificEndOfRegex = `^[.]`; - export const UnspecificEndOfRangeRegex = `^[.]`; - export const UnitRegex = `(?anos?|meses|m[êe]s|semanas?|dias?|horas?|hrs?|hs?|minutos?|mins?|segundos?|segs?)\\b`; - export const ConnectorRegex = `^(,|t|para [ao]|para as|pras|(cerca|perto|ao\\s+redor|por\\s+volta)\\s+(de|das)|quase)$`; - export const TimeHourNumRegex = `(?vinte( e (um|dois|tr[êe]s|quatro))?|zero|uma?|dois|duas|tr[êe]s|quatro|cinco|seis|sete|oito|nove|dez|onze|doze|treze|quatorze|catorze|quinze|dez([ea]sseis|[ea]ssete|oito|[ea]nove))`; - export const PureNumFromTo = `(((desde|de|da|das)\\s+(a(s)?\\s+)?)?(${BaseDateTime.HourRegex}|${TimeHourNumRegex})(\\s*(?${DescRegex}|horas))?\\s*${TillRegex}(?${DescRegex}|horas))?\\s*${TillRegex})\\s*(${BaseDateTime.HourRegex}|${TimeHourNumRegex})\\s*(?${PmRegex}|${AmRegex}|${DescRegex}|horas)?`; - export const PureNumBetweenAnd = `(entre\\s+((a|as)?\\s+)?)(${BaseDateTime.HourRegex}|${TimeHourNumRegex})(\\s*(?${DescRegex}|horas))?\\s*e\\s*(a(s)?\\s+)?(${BaseDateTime.HourRegex}|${TimeHourNumRegex})\\s*(?${PmRegex}|${AmRegex}|${DescRegex}|horas)?`; - export const SpecificTimeFromTo = `^[.]`; - export const SpecificTimeBetweenAnd = `^[.]`; - export const TimeUnitRegex = `(?(hora|minuto|min|segundo|se[cg])(?s)?|h)\\b`; - export const TimeFollowedUnit = `^\\s*${TimeUnitRegex}`; - export const TimeNumberCombinedWithUnit = `\\b(?\\d+(\\,\\d*)?)\\s*${TimeUnitRegex}`; - export const DateTimePeriodNumberCombinedWithUnit = `\\b(?\\d+(\\.\\d*)?)\\s*${TimeUnitRegex}`; - export const PeriodTimeOfDayWithDateRegex = `\\b((e|[àa]|em|na|no|ao|pel[ao]|de)\\s+)?(?manh[ãa]|madrugada|(passado\\s+(o\\s+)?)?meio\\s+dia|tarde|noite)\\b`; - export const RelativeTimeUnitRegex = `(${PastRegex}|${FutureRegex})\\s+${UnitRegex}|${UnitRegex}\\s+(${PastRegex}|${FutureRegex})`; - export const SuffixAndRegex = `(?\\s*(e)\\s+(?meia|(um\\s+)?quarto))`; - export const FollowedUnit = `^\\s*${UnitRegex}`; - export const LessThanRegex = `^[.]`; - export const MoreThanRegex = `^[.]`; - export const DurationNumberCombinedWithUnit = `\\b(?\\d+(\\,\\d*)?)${UnitRegex}`; - export const AnUnitRegex = `\\b(um(a)?)\\s+${UnitRegex}`; - export const DuringRegex = `^[.]`; - export const AllRegex = `\\b(?tod[oa]?\\s+(o|a)\\s+(?ano|m[êe]s|semana|dia))\\b`; - export const HalfRegex = `\\b(?mei[oa]\\s+(?ano|m[êe]s|semana|dia|hora))\\b`; - export const ConjunctionRegex = `^[.]`; - export const InexactNumberRegex = `\\b(poucos|pouco|algum|alguns|v[áa]rios)\\b`; - export const InexactNumberUnitRegex = `\\b(poucos|pouco|algum|alguns|v[áa]rios)\\s+${UnitRegex}`; - export const HolidayRegex1 = `\\b(?sexta-feira santa|sexta-feira da paix[ãa]o|quarta-feira de cinzas|carnaval|dia dos? presidentes?|ano novo chin[eê]s|ano novo|v[ée]spera de ano novo|natal|v[ée]spera de natal|dia de a[cç][ãa]o de gra[çc]as|a[cç][ãa]o de gra[çc]as|yuandan|halloween|dia das bruxas|p[áa]scoa)(\\s+(d[eo]?\\s+)?(${YearRegex}|(?(pr[oó]xim[oa]?|[nd]?es[st][ea]|[uú]ltim[oa]?|em))\\s+ano))?\\b`; - export const HolidayRegex2 = `\\b(?(dia\\s+(d[eoa]s?\\s+)?)?(martin luther king|todos os santos|s[ãa]o (patr[íi]cio|francisco|jorge|jo[ãa]o)|independ[êe]ncia))(\\s+(d[eo]?\\s+)?(${YearRegex}|(?(pr[oó]xim[oa]?|[nd]?es[st][ea]|[uú]ltim[oa]?|em))\\s+ano))?\\b`; - export const HolidayRegex3 = `\\b(?(dia\\s+d[eoa]s?\\s+)(trabalh(o|ador(es)?)|m[ãa]es?|pais?|mulher(es)?|crian[çc]as?|marmota|professor(es)?))(\\s+(d[eo]?\\s+)?(${YearRegex}|(?(pr[oó]xim[oa]?|[nd]?es[st][ea]|[uú]ltim[oa]?|em))\\s+ano))?\\b`; - export const BeforeRegex = `(antes(\\s+(d(e\\s+)?[aeo]s?)?)?|at[ée]h?(\\s+[oàa]s?\\b)?)`; - export const AfterRegex = `((depois|ap[óo]s|a\\s+partir)(\\s*(de|d?[oa]s?)?)?)`; - export const SinceRegex = `(desde(\\s+(as?|o))?)`; - export const AroundRegex = `(?:\\b(?:cerca|perto|ao\\s+redor|por\\s+volta)\\s*?\\b)(\\s+(de|das))?`; - export const PeriodicRegex = `\\b(?di[áa]ri[ao]|(diaria|mensal|semanal|quinzenal|(bi|tri|se)mestral|anual)(mente)?)\\b`; - export const EachExpression = `cada|tod[oa]s?\\s*([oa]s)?`; - export const EachUnitRegex = `(?(${EachExpression})\\s*${UnitRegex})`; - export const EachPrefixRegex = `(?(${EachExpression})\\s*$)`; - export const EachDayRegex = `\\s*(${EachExpression})\\s*dias\\s*\\b`; - export const BeforeEachDayRegex = `(${EachExpression})\\s*dias(\\s+a[so])?\\s*\\b`; - export const SetEachRegex = `(?(${EachExpression})\\s*)`; - export const LaterEarlyPeriodRegex = `^[.]`; - export const WeekWithWeekDayRangeRegex = `^[.]`; - export const GeneralEndingRegex = `^[.]`; - export const MiddlePauseRegex = `^[.]`; - export const PrefixArticleRegex = `^[\\.]`; - export const OrRegex = `^[.]`; - export const SpecialYearTermsRegex = `\\b((${SpecialYearPrefixes}\\s+anos?\\s+|anos?\\s+(${SpecialYearPrefixes}\\s+)?)(d[oe]\\s+)?)`; - export const YearPlusNumberRegex = `\\b(${SpecialYearTermsRegex}((?(\\d{2,4}))|${FullTextYearRegex}))\\b`; - export const NumberAsTimeRegex = `\\b(${WrittenTimeRegex}|(${TimeHourNumRegex}|${BaseDateTime.HourRegex})(?\\s*horas)?)\\b`; - export const TimeBeforeAfterRegex = `^[.]`; - export const DateNumberConnectorRegex = `^[.]`; - export const ComplexDatePeriodRegex = `^[.]`; - export const AgoRegex = `\\b(antes(\\s+d[eoa]s?\\s+(?hoje|ontem|manhã))?|atr[áa]s|no passado)\\b`; - export const LaterRegex = `\\b(depois(\\s+d[eoa]s?\\s+(agora|(?hoje|ontem|manhã)))?|ap[óo]s (as)?|desde( (as|o))?|no futuro|mais tarde)\\b`; - export const Tomorrow = `amanh[ãa]`; - export const UnitMap: ReadonlyMap = new Map([["anos", "Y"],["ano", "Y"],["meses", "MON"],["mes", "MON"],["mês", "MON"],["semanas", "W"],["semana", "W"],["dias", "D"],["dia", "D"],["horas", "H"],["hora", "H"],["hrs", "H"],["hr", "H"],["h", "H"],["minutos", "M"],["minuto", "M"],["mins", "M"],["min", "M"],["segundos", "S"],["segundo", "S"],["segs", "S"],["seg", "S"]]); - export const UnitValueMap: ReadonlyMap = new Map([["anos", 31536000],["ano", 31536000],["meses", 2592000],["mes", 2592000],["mês", 2592000],["semanas", 604800],["semana", 604800],["dias", 86400],["dia", 86400],["horas", 3600],["hora", 3600],["hrs", 3600],["hr", 3600],["h", 3600],["minutos", 60],["minuto", 60],["mins", 60],["min", 60],["segundos", 1],["segundo", 1],["segs", 1],["seg", 1]]); - export const SpecialYearPrefixesMap: ReadonlyMap = new Map([["fiscal", "FY"],["escolar", "SY"],["letivo", "SY"]]); - export const SeasonMap: ReadonlyMap = new Map([["primavera", "SP"],["verao", "SU"],["verão", "SU"],["outono", "FA"],["inverno", "WI"]]); - export const SeasonValueMap: ReadonlyMap = new Map([["SP", 3],["SU", 6],["FA", 9],["WI", 12]]); - export const CardinalMap: ReadonlyMap = new Map([["primeiro", 1],["primeira", 1],["1o", 1],["1a", 1],["segundo", 2],["segunda", 2],["2o", 2],["2a", 2],["terceiro", 3],["terceira", 3],["3o", 3],["3a", 3],["cuarto", 4],["quarto", 4],["cuarta", 4],["quarta", 4],["4o", 4],["4a", 4],["quinto", 5],["quinta", 5],["5o", 5],["5a", 5],["sexto", 6],["sexta", 6],["6o", 6],["6a", 6],["setimo", 7],["sétimo", 7],["setima", 7],["sétima", 7],["7o", 7],["7a", 7],["oitavo", 8],["oitava", 8],["8o", 8],["8a", 8],["nono", 9],["nona", 9],["9o", 9],["9a", 9],["decimo", 10],["décimo", 10],["decima", 10],["décima", 10],["10o", 10],["10a", 10],["decimo primeiro", 11],["décimo primeiro", 11],["decima primeira", 11],["décima primeira", 11],["11o", 11],["11a", 11],["decimo segundo", 12],["décimo segundo", 12],["decima segunda", 12],["décima segunda", 12],["12o", 12],["12a", 12]]); - export const DayOfWeek: ReadonlyMap = new Map([["segunda-feira", 1],["segundas-feiras", 1],["segunda feira", 1],["segundas feiras", 1],["segunda", 1],["segundas", 1],["terça-feira", 2],["terças-feiras", 2],["terça feira", 2],["terças feiras", 2],["terça", 2],["terças", 2],["terca-feira", 2],["tercas-feiras", 2],["terca feira", 2],["tercas feiras", 2],["terca", 2],["tercas", 2],["quarta-feira", 3],["quartas-feiras", 3],["quarta feira", 3],["quartas feiras", 3],["quarta", 3],["quartas", 3],["quinta-feira", 4],["quintas-feiras", 4],["quinta feira", 4],["quintas feiras", 4],["quinta", 4],["quintas", 4],["sexta-feira", 5],["sextas-feiras", 5],["sexta feira", 5],["sextas feiras", 5],["sexta", 5],["sextas", 5],["sabado", 6],["sabados", 6],["sábado", 6],["sábados", 6],["domingo", 0],["domingos", 0],["seg", 1],["seg.", 1],["2a", 1],["ter", 2],["ter.", 2],["3a", 2],["qua", 3],["qua.", 3],["4a", 3],["qui", 4],["qui.", 4],["5a", 4],["sex", 5],["sex.", 5],["6a", 5],["sab", 6],["sab.", 6],["dom", 0],["dom.", 0]]); - export const MonthOfYear: ReadonlyMap = new Map([["1", 1],["2", 2],["3", 3],["4", 4],["5", 5],["6", 6],["7", 7],["8", 8],["9", 9],["10", 10],["11", 11],["12", 12],["janeiro", 1],["fevereiro", 2],["março", 3],["marco", 3],["abril", 4],["maio", 5],["junho", 6],["julho", 7],["agosto", 8],["septembro", 9],["setembro", 9],["outubro", 10],["novembro", 11],["dezembro", 12],["jan", 1],["fev", 2],["mar", 3],["abr", 4],["mai", 5],["jun", 6],["jul", 7],["ago", 8],["sept", 9],["set", 9],["out", 10],["nov", 11],["dez", 12],["01", 1],["02", 2],["03", 3],["04", 4],["05", 5],["06", 6],["07", 7],["08", 8],["09", 9]]); - export const Numbers: ReadonlyMap = new Map([["zero", 0],["um", 1],["uma", 1],["dois", 2],["tres", 3],["três", 3],["quatro", 4],["cinco", 5],["seis", 6],["sete", 7],["oito", 8],["nove", 9],["dez", 10],["onze", 11],["doze", 12],["dezena", 12],["dezenas", 12],["treze", 13],["catorze", 14],["quatorze", 14],["quinze", 15],["dezesseis", 16],["dezasseis", 16],["dezessete", 17],["dezassete", 17],["dezoito", 18],["dezenove", 19],["dezanove", 19],["vinte", 20],["vinte e um", 21],["vinte e uma", 21],["vinte e dois", 22],["vinte e duas", 22],["vinte e tres", 23],["vinte e três", 23],["vinte e quatro", 24],["vinte e cinco", 25],["vinte e seis", 26],["vinte e sete", 27],["vinte e oito", 28],["vinte e nove", 29],["trinta", 30],["trinta e um", 31],["quarenta", 40],["cinquenta", 50]]); - export const HolidayNames: ReadonlyMap = new Map([["pai", ["diadopai","diadospais"]],["mae", ["diadamae","diadasmaes"]],["acaodegracas", ["diadegracas","diadeacaodegracas","acaodegracas"]],["trabalho", ["diadotrabalho","diadotrabalhador","diadostrabalhadores"]],["pascoa", ["diadepascoa","pascoa"]],["natal", ["natal","diadenatal"]],["vesperadenatal", ["vesperadenatal"]],["anonovo", ["anonovo","diadeanonovo","diadoanonovo"]],["vesperadeanonovo", ["vesperadeanonovo","vesperadoanonovo"]],["yuandan", ["yuandan"]],["todosossantos", ["todosossantos"]],["professor", ["diadoprofessor","diadosprofessores"]],["crianca", ["diadacrianca","diadascriancas"]],["mulher", ["diadamulher"]]]); - export const VariableHolidaysTimexDictionary: ReadonlyMap = new Map([["pai", "-06-WXX-7-3"],["mae", "-05-WXX-7-2"],["acaodegracas", "-11-WXX-4-4"],["memoria", "-03-WXX-2-4"]]); - export const DoubleNumbers: ReadonlyMap = new Map([["metade", 0.5],["quarto", 0.25]]); - export const DateTokenPrefix = `em `; - export const TimeTokenPrefix = `as `; - export const TokenBeforeDate = `o `; - export const TokenBeforeTime = `as `; - export const PastPrefixRegex = `.^`; - export const PreviousPrefixRegex = `([uú]ltim[oa]s?|passad[oa]s?|${PastPrefixRegex})\\b`; - export const ThisPrefixRegex = `([nd]?es[st][ea])\\b`; - export const RelativeDayRegex = `^[\\.]`; - export const RestOfDateRegex = `^[\\.]`; - export const DurationUnitRegex = `(?${DateUnitRegex}|${TimeUnitRegex}|noites?)\\b`; - export const RelativeDurationUnitRegex = `(?:(?<=(${NextPrefixRegex}|${PreviousPrefixRegex}|${ThisPrefixRegex})\\s+)(${DurationUnitRegex}))`; - export const ReferenceDatePeriodRegex = `^[.]`; - export const FromToRegex = `\\b(from).+(to)\\b.+`; - export const SingleAmbiguousMonthRegex = `^(the\\s+)?(may|march)$`; - export const UnspecificDatePeriodRegex = `^[.]`; - export const PrepositionSuffixRegex = `\\b(on|in|at|around|from|to)$`; - export const RestOfDateTimeRegex = `^[\\.]`; - export const SetWeekDayRegex = `^[\\.]`; - export const NightRegex = `\\b(meia noite|noite|de noite)\\b`; - export const CommonDatePrefixRegex = `\\b(dia)\\s+$`; - export const DurationConnectorRegex = `^[.]`; - export const CenturyRegex = `^[.]`; - export const DecadeRegex = `^[.]`; - export const DecadeWithCenturyRegex = `^[.]`; - export const RelativeDecadeRegex = `\\b((n?as?\\s+)?${RelativeRegex}\\s+((?[\\w,]+)\\s+)?(d[eé]cada)s?)\\b`; - export const YearSuffix = `((,|\\sde)?\\s*(${YearRegex}|${FullTextYearRegex}))`; - export const SuffixAfterRegex = `^\\b$`; - export const YearPeriodRegex = `((((de(sde)?(\\s*a(s)?)?)\\s+)?${YearRegex}\\s*(${TillRegex})\\s*${YearRegex})|(((entre\\s*([oa](s)?)?)\\s+)${YearRegex}\\s*(${RangeConnectorRegex})\\s*${YearRegex}))`; - export const FutureSuffixRegex = `\\b(seguinte(s)?|pr[oó]xim[oa](s)?|no\\s+futuro)\\b`; - export const PastSuffixRegex = `^\\b$`; - export const ModPrefixRegex = `\\b(${RelativeRegex}|${AroundRegex}|${BeforeRegex}|${AfterRegex}|${SinceRegex})\\b`; - export const ModSuffixRegex = `\\b(${AgoRegex}|${LaterRegex}|${BeforeAfterRegex}|${FutureSuffixRegex}|${PastSuffixRegex})\\b`; - export const WrittenDecades: ReadonlyMap = new Map([["", 0]]); - export const SpecialDecadeCases: ReadonlyMap = new Map([["", 0]]); - export const DefaultLanguageFallback = `DMY`; - export const DurationDateRestrictions = [ ]; - export const AmbiguityFiltersDict: ReadonlyMap = new Map([["^\\d{4}$", "(\\d\\.\\d{4}|\\d{4}\\.\\d)"],["^(abr|ago|dez|fev|jan|ju[ln]|mar|maio?|nov|out|sep?t)$", "([$%£&!?@#])(abr|ago|dez|fev|jan|ju[ln]|mar|maio?|nov|out|sep?t)|(abr|ago|dez|fev|jan|ju[ln]|mar|maio?|nov|out|sep?t)([$%£&@#])"],["^\\d{1,4}-\\d{1,4}$", "\\d{1,4}-\\d{1,4}-\\d|\\d-\\d{1,4}-\\d{1,4}"],["^\\d{1,4}-\\d{1,4}-\\d{1,4}$", "\\d{1,4}-\\d{1,4}-\\d{1,4}-\\d|\\d-\\d{1,4}-\\d{1,4}-\\d{1,4}"]]); - export const AmbiguityTimeFiltersDict: ReadonlyMap = new Map([["horas?$", "\\b((por|duração\\s+de|durante)\\s+(\\S+\\s+){1,2}horas?|horas?\\s+(\\S+\\s+){0,2}dur(ação|ou|a(rá|va)?))\\b"]]); - export const EarlyMorningTermList = [ "madrugada" ]; - export const MorningTermList = [ "manha","manhã" ]; - export const AfternoonTermList = [ "passado o meio dia","depois do meio dia" ]; - export const EveningTermList = [ "tarde" ]; - export const NightTermList = [ "noite" ]; - export const SameDayTerms = [ "hoje","este dia","esse dia","o dia" ]; - export const PlusOneDayTerms = [ "amanha","de amanha","dia seguinte","o dia de amanha","proximo dia" ]; - export const MinusOneDayTerms = [ "ontem","ultimo dia" ]; - export const PlusTwoDayTerms = [ "depois de amanha","dia depois de amanha" ]; - export const MinusTwoDayTerms = [ "anteontem","dia antes de ontem" ]; - export const MonthTerms = [ "mes","meses" ]; - export const MonthToDateTerms = [ "mes ate agora","mes ate hoje","mes ate a data" ]; - export const WeekendTerms = [ "fim de semana" ]; - export const WeekTerms = [ "semana" ]; - export const FortnightTerms = [ "quinzena" ]; - export const YearTerms = [ "ano","anos" ]; - export const YearToDateTerms = [ "ano ate agora","ano ate hoje","ano ate a data","anos ate agora","anos ate hoje","anos ate a data" ]; - export const SpecialCharactersEquivalent: ReadonlyMap = new Map([["á", "a"],["é", "e"],["í", "i"],["ó", "o"],["ú", "u"],["ê", "e"],["ô", "o"],["ü", "u"],["ã", "a"],["õ", "o"],["ç", "c"]]); - export const DayTypeRegex = `(diari([ao]|amente))$`; - export const WeekTypeRegex = `(semanal(mente)?)$`; - export const BiWeekTypeRegex = `(quinzenal(mente)?)$`; - export const MonthTypeRegex = `(mensal(mente)?)$`; - export const BiMonthTypeRegex = `(bimestral(mente)?)$`; - export const QuarterTypeRegex = `(trimestral(mente)?)$`; - export const SemiAnnualTypeRegex = `(semestral(mente)?)$`; - export const YearTypeRegex = `(anual(mente)?)$`; -} diff --git a/JavaScript/packages/recognizers-date-time/src/resources/spanishDateTime.ts b/JavaScript/packages/recognizers-date-time/src/resources/spanishDateTime.ts deleted file mode 100644 index 268aad3e23..0000000000 --- a/JavaScript/packages/recognizers-date-time/src/resources/spanishDateTime.ts +++ /dev/null @@ -1,314 +0,0 @@ -// ------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// ------------------------------------------------------------------------------ - -import { BaseDateTime } from "./baseDateTime"; -export namespace SpanishDateTime { - export const LangMarker = `Spa`; - export const CheckBothBeforeAfter = false; - export const TillRegex = `(?\\b(hasta|hacia|al?)\\b(\\s+(el|la(s)?)\\b)?|${BaseDateTime.RangeConnectorSymbolRegex})`; - export const StrictTillRegex = `(?\\b(hasta|hacia|al?)(\\s+(el|la(s)?))?\\b|${BaseDateTime.RangeConnectorSymbolRegex}(?!\\s*[qt][1-4](?!(\\s+de|\\s*,\\s*))))`; - export const RangeConnectorRegex = `(?\\b(y\\s*(el|(la(s)?)?))\\b|${BaseDateTime.RangeConnectorSymbolRegex})`; - export const WrittenDayRegex = `(?uno|dos|tres|cuatro|cinco|seis|siete|ocho|nueve|diez|once|doce|trece|catorce|quince|dieciséis|diecisiete|dieciocho|diecinueve|veinte|veintiuno|veintidós|veintitrés|veinticuatro|veinticinco|veintiséis|veintisiete|veintiocho|veintinueve|treinta(\\s+y\\s+uno)?)`; - export const DayRegex = `\\b(?01|02|03|04|05|06|07|08|09|10|11|12|13|14|15|16|17|18|19|1|20|21|22|23|24|25|26|27|28|29|2|30|31|3|4|5|6|7|8|9)(?:\\.[º°])?(?=\\b|t)`; - export const MonthNumRegex = `(?1[0-2]|(0)?[1-9])\\b`; - export const OclockRegex = `(?en\\s+punto)`; - export const AmDescRegex = `(${BaseDateTime.BaseAmDescRegex})`; - export const PmDescRegex = `(${BaseDateTime.BasePmDescRegex})`; - export const AmPmDescRegex = `(${BaseDateTime.BaseAmPmDescRegex})`; - export const DescRegex = `(?(${AmDescRegex}|${PmDescRegex}))`; - export const OfPrepositionRegex = `(\\bd(o|al?|el?)\\b)`; - export const AfterNextSuffixRegex = `\\b(despu[eé]s\\s+de\\s+la\\s+pr[oó]xima)\\b`; - export const NextSuffixRegex = `\\b(que\\s+viene|pr[oó]xim[oa]|siguiente)\\b`; - export const PreviousSuffixRegex = `\\b(pasad[ao]|anterior(?!\\s+(al?|del?)\\b))\\b`; - export const RelativeSuffixRegex = `(${AfterNextSuffixRegex}|${NextSuffixRegex}|${PreviousSuffixRegex})`; - export const RangePrefixRegex = `((de(l|sde)?|entre)(\\s+la(s)?)?)`; - export const TwoDigitYearRegex = `\\b(?([0-9]\\d))(?!(\\s*((\\:\\d)|${AmDescRegex}|${PmDescRegex}|\\.\\d))|\\.?[º°ª])\\b`; - export const RelativeRegex = `(?est[ae]s?|pr[oó]xim[oa]s?|siguiente|(([uú]ltim|pasad)[ao]s?))\\b`; - export const StrictRelativeRegex = `(?est[ae]|pr[oó]xim[oa]|siguiente|(([uú]ltim|pasad)(o|as|os)))\\b`; - export const WrittenOneToNineRegex = `(un[ao]?|dos|tres|cuatro|cinco|seis|siete|ocho|nueve)`; - export const WrittenOneHundredToNineHundredRegex = `(doscient[oa]s|trescient[oa]s|cuatrocient[ao]s|quinient[ao]s|seiscient[ao]s|setecient[ao]s|ochocient[ao]s|novecient[ao]s|cien(to)?)`; - export const WrittenOneToNinetyNineRegex = `(((treinta|cuarenta|cincuenta|sesenta|setenta|ochenta|noventa)(\\s+y\\s+${WrittenOneToNineRegex})?)|diez|once|doce|trece|catorce|quince|dieciséis|dieciseis|diecisiete|dieciocho|diecinueve|veinte|veintiuno|veintiún|veintiun|veintiuna|veintidós|veintidos|veintitrés|veintitres|veinticuatro|veinticinco|veintiséis|veintisiete|veintiocho|veintinueve|un[ao]?|dos|tres|cuatro|cinco|seis|siete|ocho|nueve)`; - export const FullTextYearRegex = `\\b(?((dos\\s+)?mil)(\\s+${WrittenOneHundredToNineHundredRegex})?(\\s+${WrittenOneToNinetyNineRegex})?)`; - export const YearRegex = `(${BaseDateTime.FourDigitYearRegex}|${FullTextYearRegex})`; - export const RelativeMonthRegex = `(?(de\\s+)?((este|pr[oó]ximo|([uú]ltim(o|as|os)))\\s+mes)|(del\\s+)?(mes\\s+((que\\s+viene)|pasado)))\\b`; - export const MonthRegex = `\\b(?abr(\\.|(il)?\\b)|ago(\\.|(sto)?\\b)|dic(\\.|(iembre)?\\b)|feb(\\.|(rero)?\\b)|ene(\\.|(ro)?\\b)|ju[ln](\\.|(io)?\\b)|mar(\\.|(zo)?\\b)|may(\\.|(o)?\\b)|nov(\\.|(iembre)?\\b)|oct(\\.|(ubre)?\\b)|sep?t(\\.|(iembre)?\\b)|sep(\\.|\\b))`; - export const MonthSuffixRegex = `(?((del?|la|el)\\s+)?(${RelativeMonthRegex}|${MonthRegex}))`; - export const DateUnitRegex = `(?(año|(?semana))(?s)?|(?mes)(?es)?|(?d[ií]a)(?s)?(?\\s+(h[aá]biles|laborales))?)\\b`; - export const PastRegex = `(?\\b(pasad(a|o)(s)?|[uú]ltim[oa](s)?|anterior(es)?|previo(s)?)\\b)`; - export const FutureRegex = `\\b(siguiente(s)?|pr[oó]xim[oa](s)?)\\b`; - export const SimpleCasesRegex = `\\b((desde(\\s+el)?|entre|del?)\\s+)?(${DayRegex})\\s*${TillRegex}\\s*(${DayRegex})\\s+${MonthSuffixRegex}((\\s+|\\s*,\\s*)((en|del?)\\s+)?${YearRegex})?\\b`; - export const MonthFrontSimpleCasesRegex = `\\b${MonthSuffixRegex}\\s+((desde(\\s+el)?|entre|del)\\s+)?(${DayRegex})\\s*${TillRegex}\\s*(${DayRegex})((\\s+|\\s*,\\s*)((en|del?)\\s+)?${YearRegex})?\\b`; - export const MonthFrontBetweenRegex = `\\b${MonthSuffixRegex}\\s+((entre(\\s+el)?)\\s+)(${DayRegex})\\s*${RangeConnectorRegex}\\s*(${DayRegex})((\\s+|\\s*,\\s*)((en|del?)\\s+)?${YearRegex})?\\b`; - export const DayBetweenRegex = `\\b((entre(\\s+el)?)\\s+)(${DayRegex})\\s*${RangeConnectorRegex}\\s*(${DayRegex})\\s+${MonthSuffixRegex}((\\s+|\\s*,\\s*)((en|del?)\\s+)?${YearRegex})?\\b`; - export const SpecialYearPrefixes = `((del\\s+)?calend[aá]rio|(?fiscal|escolar))`; - export const OneWordPeriodRegex = `\\b(((((la|el)\\s+)?mes\\s+((${OfPrepositionRegex})\\s+)?)|((pr[oó]xim[oa]?|est[ea]|[uú]ltim[oa]?)\\s+))?(${MonthRegex})|((el\\s+)?${RelativeRegex}\\s+)?((${SpecialYearPrefixes}\\s+)año|año\\s+${SpecialYearPrefixes})|(((la|el)\\s+)?(((${RelativeRegex}\\s+)(${DateUnitRegex}|(fin\\s+de\\s+)?semana|finde)(\\s+${RelativeSuffixRegex})?)|${DateUnitRegex}(\\s+${RelativeSuffixRegex}))|va\\s+de\\s+${DateUnitRegex}|((año|mes)(\\s+(a|hasta)\\s+la\\s+fecha)?|((el\\s+)?fin\\s+de\\s+)?semana|(el\\s+)?finde))\\b)`; - export const MonthWithYearRegex = `\\b((((pr[oó]xim[oa](s)?|est?[ae]|[uú]ltim[oa]?)\\s+)?${MonthRegex}|((el\\s+)?(?primero?|1(er|ro)|segundo|2do|tercero?|3(er|ro)|uarto|4to|quinto|5to|sexto|6to|s[eé]ptimo|7mo|octavo|8vo|noveno|9no|d[eé]cimo|10mo|und[eé]cimo|11mo|duod[eé]cimo|12mo|[uú]ltimo)\\s+mes(?=\\s+(del?|en))))((\\s+|(\\s*[,-]\\s*))((de(l|\\s+la)?|en)\\s+)?(${YearRegex}|(?pr[oó]ximo(s)?|[uú]ltimo?|este)\\s+año)|\\s+(del?|en)\\s+${TwoDigitYearRegex}))\\b`; - export const MonthNumWithYearRegex = `\\b((${YearRegex}(\\s*?)[/\\-\\.~](\\s*?)${MonthNumRegex})|(${MonthNumRegex}(\\s*?)[/\\-\\.~](\\s*?)${YearRegex}))\\b`; - export const WeekOfMonthRegex = `(?(la\\s+)?(?primera?|1ra|segunda|2da|tercera?|3ra|cuarta|4ta|quinta|5ta|([12345](\\.)?ª)|[uú]ltima)\\s+semana\\s+${MonthSuffixRegex}((\\s+de)?\\s+(${BaseDateTime.FourDigitYearRegex}|${RelativeRegex}\\s+año))?)\\b`; - export const WeekOfYearRegex = `(?(la\\s+)?(?primera?|1ra|segunda|2da|tercera?|3ra|cuarta|4ta|quinta|5ta|[uú]ltima?|([12345]ª))\\s+semana(\\s+(del?|en))?\\s+(${YearRegex}|(?pr[oó]ximo|[uú]ltimo|este)\\s+año))`; - export const OfYearRegex = `\\b((del?)\\s+(${YearRegex}|${StrictRelativeRegex}\\s+año))\\b`; - export const FirstLastRegex = `\\b((el|las?|los?)\\s+)?((?primer([ao]s?)?)|(?[uú]ltim[ao]s?))\\b`; - export const FollowedDateUnit = `^\\s*${DateUnitRegex}`; - export const NumberCombinedWithDateUnit = `\\b(?\\d+(\\.\\d*)?)${DateUnitRegex}`; - export const QuarterTermRegex = `\\b((?primer|1er|segundo|2do|tercer|3ro|4to|([1234](\\.)?º))\\s+(trimestre|cuarto)|[tq](?[1-4]))\\b`; - export const RelativeQuarterTermRegex = `\\b((?${StrictRelativeRegex})\\s+(trimestre|cuarto)|(trimestre|cuarto)\\s+(?(actual|pr[oó]ximo|siguiente|pasado|anterior)))\\b`; - export const QuarterRegex = `(el\\s+)?${QuarterTermRegex}((\\s+(del?\\s+)?|\\s*[,-]\\s*)(${YearRegex}|(?pr[oó]ximo(s)?|[uú]ltimo?|este)\\s+a[ñn]o|a[ñn]o(\\s+${RelativeSuffixRegex}))|\\s+del\\s+a[ñn]o)?|${RelativeQuarterTermRegex}`; - export const QuarterRegexYearFront = `(${YearRegex}|(?pr[oó]ximo(s)?|[uú]ltimo?|este)\\s+a[ñn]o)(?:\\s*-\\s*|\\s+(el\\s+)?)?${QuarterTermRegex}`; - export const AllHalfYearRegex = `\\b(?primer|1er|segundo|2do|[12](\\.)?º)\\s+semestre(\\s+(de\\s+)?(${YearRegex}|${RelativeRegex}\\s+año))?\\b`; - export const EarlyPrefixRegex = `\\b(?(?m[aá]s\\s+temprano(\\s+(del?|en))?)|((comienzos?|inicios?|principios?|temprano)\\s+(${OfPrepositionRegex}(\\s+d[ií]a)?)))(\\s+(el|las?|los?))?\\b`; - export const MidPrefixRegex = `\\b(?(media[dn]os\\s+(${OfPrepositionRegex})))(\\s+(el|las?|los?))?\\b`; - export const LaterPrefixRegex = `\\b(?((fin(al)?(es)?|[uú]ltimos)\\s+(${OfPrepositionRegex}))|(?m[aá]s\\s+tarde(\\s+(del?|en))?))(\\s+(el|las?|los?))?\\b`; - export const PrefixPeriodRegex = `(${EarlyPrefixRegex}|${MidPrefixRegex}|${LaterPrefixRegex})`; - export const PrefixDayRegex = `\\b((?(comienzos?|inicios?|principios?|temprano))|(?mediados)|(?(fin((al)?es)?|m[aá]s\\s+tarde)))(\\s+(en|${OfPrepositionRegex}))?(\\s+([ae]l)(\\s+d[ií]a)?)?$`; - export const CenturySuffixRegex = `(^siglo)\\b`; - export const SeasonRegex = `\\b(?(([uú]ltim[oa]|est[ea]|el|la|(pr[oó]xim[oa]s?|siguiente)|${PrefixPeriodRegex})\\s+)?(?primavera|verano|otoño|invierno)((\\s+(del?|en)|\\s*,\\s*)?\\s+(${YearRegex}|(?pr[oó]ximo|[uú]ltimo|este)\\s+año))?)\\b`; - export const WhichWeekRegex = `\\b(semana)(\\s*)(?5[0-3]|[1-4]\\d|0?[1-9])(\\s+del?\\s+(${YearRegex}|(?pr[oó]ximo|[uú]ltimo|este)\\s+año|año\\s+(?pasado)))?\\b`; - export const WeekOfRegex = `((del?|el|la)\\s+)?(semana)(\\s*)(${OfPrepositionRegex}|que\\s+(inicia|comienza)\\s+el|(que\\s+va|a\\s+partir)\\s+del)`; - export const MonthOfRegex = `(mes)(\\s+)(${OfPrepositionRegex})`; - export const RangeUnitRegex = `\\b(?años?|mes(es)?|semanas?)\\b`; - export const BeforeAfterRegex = `^[.]`; - export const InConnectorRegex = `\\b(en)(?=\\s*$)\\b`; - export const TodayNowRegex = `\\b(hoy|ahora|este entonces)\\b`; - export const FromRegex = `((\\bde(sde)?)(\\s*la(s)?)?)$`; - export const BetweenRegex = `(\\bentre\\s*(la(s)?)?)`; - export const WeekDayRegex = `\\b(?(domingos?|lunes|martes|mi[eé]rcoles|jueves|viernes|s[aá]bados?)\\b|(lun|mar|mi[eé]|jue|vie|s[aá]b|dom|lu|ma|mi|ju|vi|s[aá]|do)(\\.|\\b))(?!ñ)`; - export const OnRegex = `((?<=\\b(e[ln])\\s+)|(\\be[ln]\\s+d[ií]a\\s+))(${DayRegex}s?)(?![.,]\\d)\\b`; - export const RelaxedOnRegex = `(?<=\\b(en|d?el)\\s+)((?10|11|12|13|14|15|16|17|18|19|1st|20|21|22|23|24|25|26|27|28|29|2|30|31|3|4|5|6|7|8|9)s?)(?![.,]\\d)\\b`; - export const SpecialDayRegex = `\\b((el\\s+)?(d[ií]a\\s+antes\\s+de\\s+ayer|anteayer)|((el\\s+)?d[ií]a\\s+(despu[eé]s\\s+)?de\\s+mañana|pasado\\s+mañana)|(el\\s)?d[ií]a\\s+(siguiente|anterior)|(el\\s)?pr[oó]ximo\\s+d[ií]a|(el\\s+)?[uú]ltimo\\s+d[ií]a|(d)?el\\s+d[ií]a(?!\\s+(de|internacional))|ayer|mañana|hoy)\\b`; - export const SpecialDayWithNumRegex = `^[.]`; - export const FlexibleDayRegex = `(?([a-z]+\\s)?(${WrittenDayRegex}|${DayRegex}))`; - export const ForTheRegex = `\\b((((?<=para\\s+el\\s+)${FlexibleDayRegex})|((?\\s*(,|\\.(?![º°ª])|!|\\?|-|$))(?!\\d))`; - export const WeekDayAndDayOfMonthRegex = `\\b${WeekDayRegex}\\s+((el\\s+(d[ií]a\\s+)?)${FlexibleDayRegex})\\b`; - export const WeekDayAndDayRegex = `\\b${WeekDayRegex}\\s+(${DayRegex}|${WrittenDayRegex})(?!([-:/]|\\.\\d|(\\s+(${AmDescRegex}|${PmDescRegex}|${OclockRegex}))))\\b`; - export const WeekDayOfMonthRegex = `(?(el\\s+)?(?primera?|1era?|segund[ao]|2d[ao]|tercera?|3era?|cuart[ao]|4t[ao]|quint[ao]|5t[ao]|((1|2|3|4|5)(\\.)?[ºª])|[uú]ltim[ao])\\s+(semana\\s+${MonthSuffixRegex}\\s+el\\s+${WeekDayRegex}|${WeekDayRegex}\\s+${MonthSuffixRegex}))`; - export const RelativeWeekDayRegex = `^[.]`; - export const AmbiguousRangeModifierPrefix = `^[.]`; - export const NumberEndingPattern = `^[.]`; - export const DateTokenPrefix = `en `; - export const TimeTokenPrefix = `a las `; - export const TokenBeforeDate = `el `; - export const TokenBeforeTime = `a las `; - export const HalfTokenRegex = `^((y\\s+)?media)`; - export const QuarterTokenRegex = `^((y\\s+)?cuarto|(?menos\\s+cuarto))`; - export const PastTokenRegex = `\\b(pasad[ao]s(\\s+(de\\s+)?las)?)$`; - export const ToTokenRegex = `\\b((para|antes)(\\s+(de\\s+)?las?)|(?^menos))$`; - export const SpecialDateRegex = `(?<=\\b(en)\\s+el\\s+)${DayRegex}\\b`; - export const OfMonthRegex = `^\\s*((d[ií]a\\s+)?d[eo]\\s+)?${MonthSuffixRegex}`; - export const MonthEndRegex = `(${MonthRegex}\\s*(el)?\\s*$)`; - export const WeekDayEnd = `${WeekDayRegex}\\s*,?\\s*$`; - export const WeekDayStart = `^\\b$`; - export const DateYearRegex = `(?${YearRegex}|(?2[0-4]|[0-1]?\\d)`; - export const HourNumRegex = `\\b(?cero|una|dos|tres|cuatro|cinco|seis|siete|ocho|nueve|diez|once|doce)\\b`; - export const MinuteNumRegex = `(?uno?|d[óo]s|tr[eé]s|cuatro|cinco|s[eé]is|siete|ocho|nueve|diez|once|doce|trece|catorce|quince|diecis[eé]is|diecisiete|dieciocho|diecinueve|veinte|treinta|cuarenta|cincuenta)`; - export const DeltaMinuteNumRegex = `(?uno?|d[óo]s|tr[eé]s|cuatro|cinco|s[eé]is|siete|ocho|nueve|diez|once|doce|trece|catorce|quince|diecis[eé]is|diecisiete|dieciocho|diecinueve|veinte|treinta|cuarenta|cincuenta)`; - export const PmRegex = `(?((por|de|a|en)\\s+la)\\s+(tarde|noche))`; - export const AmRegex = `(?((por|de|a|en)\\s+la)\\s+(mañana|madrugada))`; - export const AmTimeRegex = `(?(esta|(por|de|a|en)\\s+la)\\s+(mañana|madrugada))`; - export const PmTimeRegex = `(?(esta|(por|de|a|en)\\s+la)\\s+(tarde|noche))`; - export const NightTimeRegex = `(noche)`; - export const LastNightTimeRegex = `(anoche)`; - export const NowTimeRegex = `(ahora|mismo|momento)`; - export const RecentlyTimeRegex = `(mente)`; - export const AsapTimeRegex = `(posible|pueda[ns]?|podamos)`; - export const LessThanOneHour = `(?((\\s+y\\s+)?cuarto|(\\s*)menos cuarto|(\\s+y\\s+)media|${BaseDateTime.DeltaMinuteRegex}(\\s+(minutos?|mins?))|${DeltaMinuteNumRegex}(\\s+(minutos?|mins?))))`; - export const TensTimeRegex = `(?diez|veint(i|e)|treinta|cuarenta|cincuenta)`; - export const WrittenTimeRegex = `(?${HourNumRegex}\\s*((y|(?menos))\\s+)?((${TensTimeRegex}(\\s*y\\s+)?)?${MinuteNumRegex}))`; - export const TimePrefix = `(?${LessThanOneHour}(\\s+(pasad[ao]s)\\s+(de\\s+las|las)?|\\s+(para|antes\\s+de)?\\s+(las?))?)`; - export const TimeSuffix = `(?(${LessThanOneHour}\\s+)?(${AmRegex}|${PmRegex}|${OclockRegex}))`; - export const GeneralDescRegex = `(${DescRegex}|(?${AmRegex}|${PmRegex}))`; - export const BasicTime = `(?${WrittenTimeRegex}|${HourNumRegex}|${BaseDateTime.HourRegex}:${BaseDateTime.MinuteRegex}(:${BaseDateTime.SecondRegex})?|${BaseDateTime.HourRegex})`; - export const MidTimeRegex = `(?((?media\\s*noche)|(?media\\s*madrugada)|(?media\\s*mañana)|(?media\\s*tarde)|(?medio\\s*d[ií]a)))`; - export const AtRegex = `\\b((?<=\\b((a|de(sde)?)\\s+las?|al)\\s+)((${WrittenTimeRegex}|${HourNumRegex}|${BaseDateTime.HourRegex})\\b(\\s*\\bh\\b)?(DescRegex)?|${MidTimeRegex})|${MidTimeRegex})`; - export const ConnectNumRegex = `(${BaseDateTime.HourRegex}(?[0-5][0-9])\\s*${DescRegex})`; - export const TimeRegexWithDotConnector = `(${BaseDateTime.HourRegex}\\.${BaseDateTime.MinuteRegex})`; - export const TimeRegex1 = `(\\b${TimePrefix}\\s+)?(${WrittenTimeRegex}|${HourNumRegex}|${BaseDateTime.HourRegex})\\s*(${DescRegex}|\\s*\\bh\\b)`; - export const TimeRegex2 = `(\\b${TimePrefix}\\s+)?(t)?${BaseDateTime.HourRegex}(\\s*)?:(\\s*)?${BaseDateTime.MinuteRegex}((\\s*)?:(\\s*)?${BaseDateTime.SecondRegex})?(\\s*(${DescRegex}|\\bh\\b)|\\b)`; - export const TimeRegex3 = `\\b((${TimePrefix}\\s+)?${TimeRegexWithDotConnector}(\\s*(${DescRegex}|${TimeSuffix}|\\bh\\b))|((las\\s+${TimeRegexWithDotConnector})(?!\\s*(por\\s+cien(to)?|%))(\\s*(${DescRegex}|${TimeSuffix}|\\bh\\b)|\\b)))`; - export const TimeRegex4 = `\\b((${DescRegex}?)|(${BasicTime}\\s*)?(${GeneralDescRegex}?))${TimePrefix}(\\s*(${HourNumRegex}|${BaseDateTime.HourRegex}))?(\\s+${TensTimeRegex}(\\s*(y\\s+)?${MinuteNumRegex})?)?(\\s*(${OclockRegex}|${DescRegex}|\\bh\\b)|\\b)`; - export const TimeRegex5 = `\\b(${TimePrefix}|${BasicTime}${TimePrefix})\\s+(\\s*${DescRegex})?${BasicTime}?\\s*${TimeSuffix}\\b`; - export const TimeRegex6 = `(${BasicTime}(\\s*${DescRegex})?\\s+${TimeSuffix}\\b)`; - export const TimeRegex7 = `\\b${TimeSuffix}\\s+a\\s+las\\s+${BasicTime}((\\s*${DescRegex}|\\bh\\b)|\\b)`; - export const TimeRegex8 = `\\b${TimeSuffix}\\s+${BasicTime}((\\s*${DescRegex})|\\b)`; - export const TimeRegex9 = `\\b(?${HourNumRegex}\\s+(${TensTimeRegex}\\s*)(y\\s+)?${MinuteNumRegex}?)\\b`; - export const TimeRegex11 = `\\b(${WrittenTimeRegex})(\\s+${DescRegex})?\\b`; - export const TimeRegex12 = `(\\b${TimePrefix}\\s+)?${BaseDateTime.HourRegex}(\\s*h\\s*)${BaseDateTime.MinuteRegex}(\\s*${DescRegex})?`; - export const PrepositionRegex = `(?^(,\\s*)?(a(l)?|en|de(l)?)?(\\s*(la(s)?|el|los))?$)`; - export const LaterEarlyRegex = `((?temprano)|(?fin(al)?(\\s+de)?|m[aá]s\\s+tarde))`; - export const NowRegex = `\\b(?(justo\\s+)?ahora(\\s+mismo)?|en\\s+este\\s+momento|tan\\s+pronto\\s+como\\s+sea\\s+posible|tan\\s+pronto\\s+como\\s+(pueda|puedas|podamos|puedan)|lo\\s+m[aá]s\\s+pronto\\s+posible|recientemente|previamente|este entonces)\\b`; - export const SuffixRegex = `^\\s*(((y|a|en|por)\\s+la|al)\\s+)?(mañana|madrugada|medio\\s*d[ií]a|(?((${LaterEarlyRegex}\\s+)((del?|en|por)(\\s+(el|los?|las?))?\\s+)?)?(mañana|madrugada|pasado\\s+(el\\s+)?medio\\s?d[ií]a|(?mañana|madrugada|(?pasado\\s+(el\\s+)?medio\\s?d[ií]a|tarde|noche))\\b`; - export const PeriodTimeOfDayRegex = `\\b((en\\s+(el|la|lo)?\\s+)?(${LaterEarlyRegex}\\s+)?(est[ae]\\s+)?${DateTimeTimeOfDayRegex})\\b`; - export const PeriodSpecificTimeOfDayRegex = `\\b((${LaterEarlyRegex}\\s+)?est[ae]\\s+${DateTimeTimeOfDayRegex}|(${StrictRelativeRegex}\\s+${PeriodTimeOfDayRegex})|anoche)\\b`; - export const UnitRegex = `(?años?|(bi|tri|cuatri|se)mestre|mes(es)?|semanas?|fin(es)?\\s+de\\s+semana|finde|d[ií]as?|horas?|hra?s?|hs?|minutos?|mins?|segundos?|segs?|noches?)\\b`; - export const ConnectorRegex = `^(,|t|(para|y|a|en|por) las?|(\\s*,\\s*)?((cerca|alrededor)\\s+)?(de\\s+las?|del))$`; - export const TimeHourNumRegex = `(?veint(i(uno|dos|tres|cuatro)|e)|cero|uno|dos|tres|cuatro|cinco|seis|siete|ocho|nueve|diez|once|doce|trece|catorce|quince|dieci(s([eé])is|siete|ocho|nueve))`; - export const PureNumFromTo = `((\\b(desde|de)\\s+(la(s)?\\s+)?)?(${BaseDateTime.HourRegex}|${TimeHourNumRegex})(?!\\s+al?\\b)(\\s*(?${DescRegex}))?|(\\b(desde|de)\\s+(la(s)?\\s+)?)(${BaseDateTime.HourRegex}|${TimeHourNumRegex})(\\s*(?${DescRegex}))?)\\s*${TillRegex}\\s*(${BaseDateTime.HourRegex}|${TimeHourNumRegex})\\s*(?${PmRegex}|${AmRegex}|${DescRegex})?`; - export const PureNumBetweenAnd = `(\\bentre\\s+(la(s)?\\s+)?)((${BaseDateTime.TwoDigitHourRegex}${BaseDateTime.TwoDigitMinuteRegex})|${BaseDateTime.HourRegex}|${TimeHourNumRegex})(\\s*(?${DescRegex}))?\\s*${RangeConnectorRegex}\\s*((${BaseDateTime.TwoDigitHourRegex}${BaseDateTime.TwoDigitMinuteRegex})|${BaseDateTime.HourRegex}|${TimeHourNumRegex})\\s*(?${PmRegex}|${AmRegex}|${DescRegex})?`; - export const SpecificTimeFromTo = `(${RangePrefixRegex}\\s+)?(?((${TimeRegex2}|${TimeRegexWithDotConnector}(\\s*${DescRegex})?)|(${BaseDateTime.HourRegex}|${TimeHourNumRegex})(\\s*(?${DescRegex}))?))\\s*${TillRegex}\\s*(?((${TimeRegex2}|${TimeRegexWithDotConnector}(\\s*${DescRegex})?)|(${BaseDateTime.HourRegex}|${TimeHourNumRegex})(\\s*(?${DescRegex}))?))`; - export const SpecificTimeBetweenAnd = `(${BetweenRegex}\\s+)(?((${TimeRegex1}|${TimeRegex2}|${TimeRegexWithDotConnector}(\\s*${DescRegex})?)|(${BaseDateTime.HourRegex}|${TimeHourNumRegex})(\\s*(?${DescRegex}))?))\\s*${RangeConnectorRegex}\\s*(?((${TimeRegex1}|${TimeRegex2}|${TimeRegexWithDotConnector}(\\s*${DescRegex})?)|(${BaseDateTime.HourRegex}|${TimeHourNumRegex})(\\s*(?${DescRegex}))?))`; - export const TimeUnitRegex = `([^A-Za-z]{1,}|\\b)(?(hora|minuto|min|segundo|se[cg])(?s)?|h)\\b`; - export const TimeFollowedUnit = `^\\s*${TimeUnitRegex}`; - export const TimeNumberCombinedWithUnit = `\\b(?\\d+(\\,\\d*)?)\\s*${TimeUnitRegex}`; - export const DateTimePeriodNumberCombinedWithUnit = `\\b(?\\d+(\\.\\d*)?)\\s*${TimeUnitRegex}`; - export const PeriodTimeOfDayWithDateRegex = `\\b(((y|a|en|por)\\s+(la\\s+)?|al\\s+)?((((?primeras\\s+horas\\s+)|(?(últimas|altas)\\s+horas\\s+))(de\\s+la\\s+)?|${LaterEarlyRegex}\\s+(est[ae]\\s+)?)?(?(mañana|madrugada|pasado\\s+(el\\s+)?medio\\s?d[ií]a|(?\\s*(y)\\s+((un[ao]?)\\s+)?(?media|cuarto))`; - export const FollowedUnit = `^\\s*${UnitRegex}`; - export const DurationNumberCombinedWithUnit = `\\b(?\\d+(\\,\\d*)?)${UnitRegex}`; - export const AnUnitRegex = `\\b(una?|otr[ao])\\s+${UnitRegex}`; - export const DuringRegex = `^[.]`; - export const AllRegex = `\\b(?tod[oa]?\\s+(el|la)\\s+(?año|mes|semana|d[ií]a)|((una?|el|la)\\s+)?(?año|mes|semana|d[ií]a)\\s+enter[ao])\\b`; - export const HalfRegex = `\\b(?medi[oa]\\s+(?ano|mes|semana|d[íi]a|hora))\\b`; - export const ConjunctionRegex = `^[.]`; - export const InexactNumberRegex = `\\b(pocos?|algo|vari[ao]s|algun[ao]s|un[ao]s)\\b`; - export const InexactNumberUnitRegex = `(${InexactNumberRegex})\\s+${UnitRegex}`; - export const HolidayRegex1 = `\\b(?viernes\\s+(santo|negro)|mi[eé]rcoles de ceniza|martes de carnaval|d[ií]a (de|de los) presidentes?|clebraci[oó]n de mao|año nuevo chino|año nuevo|noche vieja|(festividad de )?los mayos|d[ií]a de los inocentes|navidad|noche buena|d[ií]a de acci[oó]n de gracias|acci[oó]n de gracias|yuandan|halloween|noches de brujas|pascuas)(\\s+(del?\\s+)?(${YearRegex}|(?(pr[oó]xim[oa]?|est[ea]|[uú]ltim[oa]?|en))\\s+año))?\\b`; - export const HolidayRegex2 = `\\b(?(d[ií]a( del?( la)?)? )?(martin luther king|todos los santos|tierra|blanco|san patricio|san valent[ií]n|san jorge|cinco de mayo|independencia|raza|trabajador))(\\s+(del?\\s+)?(${YearRegex}|(?(pr[oó]xim[oa]?|est[ea]|[uú]ltim[oa]?|en))\\s+año))?\\b`; - export const HolidayRegex3 = `\\b(?(d[ií]a( internacional)?( del?( l[ao]s?)?)? )(trabajador(es)?|madres?|padres?|[aá]rbol|mujer(es)?|solteros?|niños?|marmota|san valent[ií]n|maestro))(\\s+(del?\\s+)?(${YearRegex}|(?(pr[oó]xim[oa]?|est[ea]|[uú]ltim[oa]?|en))\\s+año))?\\b`; - export const BeforeRegex = `(\\b((ante(s|rior)|m[aá]s\\s+temprano|no\\s+m[aá]s\\s+tard(e|ar)|hasta|(?tan\\s+tarde\\s+como))(\\s+(del?|a|que)(\\s+(el|las?|los?))?)?)|(?)((?<\\s*=)|<))`; - export const AfterRegex = `((\\b(despu[eé]s|(año\\s+)?posterior|m[aá]s\\s+tarde|a\\s+primeros)(\\s*(del?|en|a)(\\s+(el|las?|los?))?)?|(empi?en?zando|comenzando)(\\s+(el|las?|los?))?)\\b|(?>\\s*=)|>))`; - export const SinceRegex = `\\b(((cualquier\\s+tiempo\\s+)?(desde|a\\s+partir\\s+del?)|tan\\s+(temprano|pronto)\\s+como(\\s+(de|a))?)(\\s+(el|las?|los?))?)\\b`; - export const SinceRegexExp = `(${SinceRegex}|\\bde\\b)`; - export const AroundRegex = `(?:\\b(?:cerca|alrededor|aproximadamente)(\\s+(de\\s+(las?|el)|del?))?\\s*\\b)`; - export const PeriodicRegex = `\\b(?a\\s*diario|diaria(s|mente)|(bi|tri)?(semanal|quincenal|mensual|(se|tri)mestral|anual)(es|mente)?)\\b`; - export const EachExpression = `\\b(cada|tod[oa]s\\s*(l[oa]s)?)\\b\\s*(?!\\s*l[oa]\\b)`; - export const EachUnitRegex = `(?(${EachExpression})\\s*(${UnitRegex}|(?fin(es)?\\s+de\\s+semana|finde)\\b))`; - export const EachPrefixRegex = `(?(${EachExpression})\\s*$)`; - export const EachDayRegex = `\\s*(${EachExpression})\\s*d[ií]as\\s*\\b`; - export const BeforeEachDayRegex = `(${EachExpression})\\s*d[ií]as(\\s+a\\s+las?)?\\s*\\b`; - export const SetEachRegex = `(?(${EachExpression})\\s*)`; - export const LaterEarlyPeriodRegex = `\\b((${PrefixPeriodRegex})\\s+(?${OneWordPeriodRegex}|(?${BaseDateTime.FourDigitYearRegex}))|(${UnspecificEndOfRangeRegex}))\\b`; - export const RelativeWeekRegex = `(((la|el)\\s+)?(((est[ae]|pr[oó]xim[oa]|[uú]ltim(o|as|os))\\s+semanas?)|(semanas?\\s+(que\\s+viene|pasad[oa]))))`; - export const WeekWithWeekDayRangeRegex = `\\b(((${RelativeWeekRegex})((\\s+entre\\s+${WeekDayRegex}\\s+y\\s+${WeekDayRegex})|(\\s+de\\s+${WeekDayRegex}\\s+a\\s+${WeekDayRegex})))|((entre\\s+${WeekDayRegex}\\s+y\\s+${WeekDayRegex})|(de\\s+${WeekDayRegex}\\s+a\\s+${WeekDayRegex}))${OfPrepositionRegex}\\s+${RelativeWeekRegex})\\b`; - export const GeneralEndingRegex = `^\\s*((\\.,)|\\.|,|!|\\?)?\\s*$`; - export const MiddlePauseRegex = `^[.]`; - export const PrefixArticleRegex = `\\b(e[ln]\\s+(d[ií]a\\s+)?)`; - export const OrRegex = `^[.]`; - export const SpecialYearTermsRegex = `\\b((${SpecialYearPrefixes}\\s+años?\\s+|años?\\s+(${SpecialYearPrefixes}\\s+)?)(de\\s+)?)`; - export const YearPlusNumberRegex = `\\b(${SpecialYearTermsRegex}((?(\\d{2,4}))|${FullTextYearRegex}))\\b`; - export const NumberAsTimeRegex = `\\b(${WrittenTimeRegex}|${HourRegex}(?\\s*h(oras)?)?)\\b`; - export const TimeBeforeAfterRegex = `\\b((?<=\\b(antes|no\\s+m[aá]s\\s+tard(e|ar)\\s+(de|a\\s+las?)|por| después)\\s+)(${WrittenTimeRegex}|${HourNumRegex}|${BaseDateTime.HourRegex}|${MidTimeRegex}))\\b`; - export const DateNumberConnectorRegex = `^\\s*(?a\\s+las)\\s*$`; - export const CenturyRegex = `^[.]`; - export const DecadeRegex = `(?diez|veinte|treinta|cuarenta|cincuenta|se[st]enta|ochenta|noventa)`; - export const DecadeWithCenturyRegex = `(los\\s+)?((((d[ée]cada(\\s+de)?)\\s+)(((?\\d|1\\d|2\\d)?(?\\d0))))|a[ñn]os\\s+((((dos\\s+)?mil\\s+)?(${WrittenOneHundredToNineHundredRegex}\\s+)?${DecadeRegex})|((dos\\s+)?mil\\s+)?(${WrittenOneHundredToNineHundredRegex})(\\s+${DecadeRegex}?)|((dos\\s+)?mil)(\\s+${WrittenOneHundredToNineHundredRegex}\\s+)?${DecadeRegex}?))`; - export const RelativeDecadeRegex = `\\b(((el|las?)\\s+)?${RelativeRegex}\\s+((?[\\w,]+)\\s+)?(d[eé]cada|decenio)s?)\\b`; - export const ComplexDatePeriodRegex = `(?:((de(sde)?)\\s+)?(?.+)\\s*(${StrictTillRegex})\\s*(?.+)|((entre)\\s+)(?.+)\\s*(${RangeConnectorRegex})\\s*(?.+))`; - export const AmbiguousPointRangeRegex = `^(mar\\.?)$`; - export const YearSuffix = `((,|\\sdel?)?\\s*(${YearRegex}|${FullTextYearRegex}))`; - export const SinceYearSuffixRegex = `(^\\s*${SinceRegex}(\\s*(el\\s+)?año\\s*)?${YearSuffix})`; - export const AgoRegex = `\\b(antes\\s+de\\s+(?hoy|ayer|mañana)|antes|hace)\\b`; - export const LaterRegex = `\\b(despu[eé]s(?!\\s+de\\b)|desde\\s+ahora|(a\\s+partir|despu[eé]s)\\s+de\\s+(ahora|(?hoy|ayer|mañana)))\\b`; - export const Tomorrow = `mañana`; - export const UnitMap: ReadonlyMap = new Map([["años", "Y"],["año", "Y"],["meses", "MON"],["mes", "MON"],["trimestre", "3MON"],["trimestres", "3MON"],["cuatrimestre", "4MON"],["cuatrimestres", "4MON"],["semestre", "6MON"],["semestres", "6MON"],["bimestre", "2MON"],["bimestres", "2MON"],["semanas", "W"],["semana", "W"],["fin de semana", "WE"],["fines de semana", "WE"],["finde", "WE"],["dias", "D"],["dia", "D"],["días", "D"],["día", "D"],["jornada", "D"],["noche", "D"],["noches", "D"],["horas", "H"],["hora", "H"],["hrs", "H"],["hras", "H"],["hra", "H"],["hr", "H"],["h", "H"],["minutos", "M"],["minuto", "M"],["mins", "M"],["min", "M"],["segundos", "S"],["segundo", "S"],["segs", "S"],["seg", "S"]]); - export const UnitValueMap: ReadonlyMap = new Map([["años", 31536000],["año", 31536000],["meses", 2592000],["mes", 2592000],["semanas", 604800],["semana", 604800],["fin de semana", 172800],["fines de semana", 172800],["finde", 172800],["dias", 86400],["dia", 86400],["días", 86400],["día", 86400],["noche", 86400],["noches", 86400],["horas", 3600],["hora", 3600],["hrs", 3600],["hras", 3600],["hra", 3600],["hr", 3600],["h", 3600],["minutos", 60],["minuto", 60],["mins", 60],["min", 60],["segundos", 1],["segundo", 1],["segs", 1],["seg", 1]]); - export const SpecialYearPrefixesMap: ReadonlyMap = new Map([["fiscal", "FY"],["escolar", "SY"]]); - export const SeasonMap: ReadonlyMap = new Map([["primavera", "SP"],["verano", "SU"],["otoño", "FA"],["invierno", "WI"]]); - export const SeasonValueMap: ReadonlyMap = new Map([["SP", 3],["SU", 6],["FA", 9],["WI", 12]]); - export const CardinalMap: ReadonlyMap = new Map([["primer", 1],["primero", 1],["primera", 1],["1er", 1],["1ro", 1],["1ra", 1],["1.º", 1],["1º", 1],["1ª", 1],["segundo", 2],["segunda", 2],["2do", 2],["2da", 2],["2.º", 2],["2º", 2],["2ª", 2],["tercer", 3],["tercero", 3],["tercera", 3],["3er", 3],["3ro", 3],["3ra", 3],["3.º", 3],["3º", 3],["3ª", 3],["cuarto", 4],["cuarta", 4],["4to", 4],["4ta", 4],["4.º", 4],["4º", 4],["4ª", 4],["quinto", 5],["quinta", 5],["5to", 5],["5ta", 5],["5.º", 5],["5º", 5],["5ª", 5],["sexto", 6],["sexta", 6],["6to", 6],["6ta", 6],["septimo", 7],["séptimo", 7],["septima", 7],["séptima", 7],["7mo", 7],["7ma", 7],["octavo", 8],["octava", 8],["8vo", 8],["8va", 8],["noveno", 9],["novena", 9],["9no", 9],["9na", 9],["decimo", 10],["décimo", 10],["decima", 10],["décima", 10],["10mo", 10],["10ma", 10],["undecimo", 11],["undécimo", 11],["undecima", 11],["undécima", 11],["11mo", 11],["11ma", 11],["duodecimo", 12],["duodécimo", 12],["duodecima", 12],["duodécima", 12],["12mo", 12],["12ma", 12]]); - export const DayOfWeek: ReadonlyMap = new Map([["lunes", 1],["martes", 2],["miercoles", 3],["miércoles", 3],["jueves", 4],["viernes", 5],["sabado", 6],["sábado", 6],["domingo", 0],["dom", 0],["lun", 1],["mar", 2],["mie", 3],["mié", 3],["jue", 4],["vie", 5],["sab", 6],["sáb", 6],["dom.", 0],["lun.", 1],["mar.", 2],["mie.", 3],["mié.", 3],["jue.", 4],["vie.", 5],["sab.", 6],["sáb.", 6],["do", 0],["lu", 1],["ma", 2],["mi", 3],["ju", 4],["vi", 5],["sa", 6]]); - export const MonthOfYear: ReadonlyMap = new Map([["1", 1],["2", 2],["3", 3],["4", 4],["5", 5],["6", 6],["7", 7],["8", 8],["9", 9],["10", 10],["11", 11],["12", 12],["enero", 1],["febrero", 2],["marzo", 3],["abril", 4],["mayo", 5],["junio", 6],["julio", 7],["agosto", 8],["septiembre", 9],["setiembre", 9],["octubre", 10],["noviembre", 11],["diciembre", 12],["ene", 1],["feb", 2],["mar", 3],["abr", 4],["may", 5],["jun", 6],["jul", 7],["ago", 8],["sept", 9],["sep", 9],["set", 9],["oct", 10],["nov", 11],["dic", 12],["ene.", 1],["feb.", 2],["mar.", 3],["abr.", 4],["may.", 5],["jun.", 6],["jul.", 7],["ago.", 8],["sept.", 9],["sep.", 9],["set.", 9],["oct.", 10],["nov.", 11],["dic.", 12],["01", 1],["02", 2],["03", 3],["04", 4],["05", 5],["06", 6],["07", 7],["08", 8],["09", 9]]); - export const Numbers: ReadonlyMap = new Map([["cero", 0],["un", 1],["una", 1],["uno", 1],["dos", 2],["dós", 2],["tres", 3],["trés", 3],["cuatro", 4],["cinco", 5],["seis", 6],["séis", 6],["siete", 7],["ocho", 8],["nueve", 9],["diez", 10],["once", 11],["doce", 12],["docena", 12],["docenas", 12],["trece", 13],["catorce", 14],["quince", 15],["dieciseis", 16],["dieciséis", 16],["diecisiete", 17],["dieciocho", 18],["diecinueve", 19],["veinte", 20],["veinti", 20],["ventiuna", 21],["ventiuno", 21],["veintiun", 21],["veintiún", 21],["veintiuno", 21],["veintiuna", 21],["veintidos", 22],["veintidós", 22],["veintitres", 23],["veintitrés", 23],["veinticuatro", 24],["veinticinco", 25],["veintiseis", 26],["veintiséis", 26],["veintisiete", 27],["veintiocho", 28],["veintinueve", 29],["treinta", 30],["cuarenta", 40],["cincuenta", 50]]); - export const HolidayNames: ReadonlyMap = new Map([["padres", ["diadelpadre"]],["madres", ["diadelamadre"]],["acciondegracias", ["diadegracias","diadeacciondegracias","acciondegracias"]],["trabajador", ["diadeltrabajador","diadelostrabajadores","diainternacionaldeltrabajador","diainternacionaldelostrabajadores"]],["delaraza", ["diadelaraza","diadeladiversidadcultural"]],["memoria", ["diadelamemoria"]],["pascuas", ["diadepascuas","pascuas"]],["navidad", ["navidad","diadenavidad"]],["nochebuena", ["diadenochebuena","nochebuena"]],["añonuevo", ["añonuevo","diadeañonuevo"]],["nochevieja", ["nochevieja","diadenochevieja"]],["yuandan", ["yuandan"]],["earthday", ["diadelatierra"]],["maestro", ["diadelmaestro"]],["todoslossantos", ["todoslossantos"]],["niño", ["diadelniño"]],["mujer", ["diadelamujer"]],["independencia", ["diadelaindependencia","diadeindependencia","independencia"]],["blackfriday", ["viernesnegro"]],["goodfriday", ["viernessanto"]],["stpatrickday", ["sanpatricio","diadesanpatricio"]],["valentinesday", ["sanvalentin","diadesanvalentin"]]]); - export const VariableHolidaysTimexDictionary: ReadonlyMap = new Map([["padres", "-06-WXX-7-3"],["madres", "-05-WXX-7-2"],["acciondegracias", "-11-WXX-4-4"],["delaraza", "-10-WXX-1-2"],["memoria", "-03-WXX-2-4"]]); - export const DoubleNumbers: ReadonlyMap = new Map([["mitad", 0.5],["cuarto", 0.25]]); - export const UpcomingPrefixRegex = `((este\\s+))`; - export const NextPrefixRegex = `\\b(${UpcomingPrefixRegex}?pr[oó]xim[oa]s?|siguiente|que\\s+viene)\\b`; - export const PastPrefixRegex = `((este\\s+))`; - export const PreviousPrefixRegex = `\\b(${PastPrefixRegex}?pasad[oa]s?(?!(\\s+el)?\\s+medio\\s*d[ií]a)|[uú]ltim[oa]s?|anterior)\\b`; - export const ThisPrefixRegex = `(est?[ea]|actual)\\b`; - export const PrefixWeekDayRegex = `(\\s*((,?\\s*el)|[-—–]))`; - export const ThisRegex = `\\b((est[ae]\\s*)(semana${PrefixWeekDayRegex}?)?\\s*${WeekDayRegex})|(${WeekDayRegex}\\s*((de\\s+)?esta\\s+semana))\\b`; - export const LastDateRegex = `\\b((${PreviousPrefixRegex}\\s+(semana${PrefixWeekDayRegex}?)?|(la\\s+)?semana\\s+${PreviousPrefixRegex}${PrefixWeekDayRegex})\\s*${WeekDayRegex})|(este\\s+)?(${WeekDayRegex}\\s+([uú]ltimo|pasado|anterior))|(${WeekDayRegex}(\\s+((de\\s+)?((esta|la)\\s+([uú]ltima\\s+)?semana)|(de\\s+)?(la\\s+)?semana\\s+(pasada|anterior))))\\b`; - export const NextDateRegex = `\\b(((${NextPrefixRegex}\\s+)(semana${PrefixWeekDayRegex}?)?|(la\\s+)?semana\\s+${NextPrefixRegex}${PrefixWeekDayRegex})\\s*${WeekDayRegex})|(este\\s+)?(${WeekDayRegex}\\s+(pr[oó]ximo|siguiente|que\\s+viene))|(${WeekDayRegex}(\\s+(de\\s+)?(la\\s+)?((pr[oó]xima|siguiente)\\s+semana|semana\\s+(pr[oó]xima|siguiente))))\\b`; - export const RelativeDayRegex = `(?((este|pr[oó]ximo|([uú]ltim(o|as|os)))\\s+días)|(días\\s+((que\\s+viene)|pasado)))\\b`; - export const RestOfDateRegex = `\\bresto\\s+((del|de)\\s+)?((la|el|est?[ae])\\s+)?(?semana|mes|año|decada)(\\s+actual)?\\b`; - export const WithinNextPrefixRegex = `\\b(dentro\\s+de((\\s+(el|l[ao]s?))?\\s+(?${NextPrefixRegex}))?)(?=\\s*$)\\b`; - export const DurationUnitRegex = `(?${DateUnitRegex}|horas?|hra?s?|hs?|minutos?|mins?|segundos?|segs?|noches?)\\b`; - export const DurationConnectorRegex = `^\\s*(?\\s+|y|,)\\s*$`; - export const RelativeDurationUnitRegex = `(?:(?<=(${NextPrefixRegex}|${PreviousPrefixRegex}|${ThisPrefixRegex})\\s+)(${DurationUnitRegex}))`; - export const ReferencePrefixRegex = `(mism[ao]|aquel|est?e)\\b`; - export const ReferenceDatePeriodRegex = `\\b${ReferencePrefixRegex}\\s+(${DateUnitRegex}|fin\\s+de\\s+semana)\\b`; - export const FromToRegex = `\\b(from).+(to)\\b.+`; - export const SingleAmbiguousMonthRegex = `^(the\\s+)?(may|march)$`; - export const UnspecificDatePeriodRegex = `^[\\.]`; - export const PrepositionSuffixRegex = `\\b(en|el|la|cerca|alrededor|desde|durante|hasta|hacia)$`; - export const RestOfDateTimeRegex = `\\bresto\\s+((del?)\\s+)?((la|el|est[ae])\\s+)?(?(día|jornada))(\\s+de\\s+hoy)?\\b`; - export const SetWeekDayRegex = `^[\\.]`; - export const NightRegex = `\\b(medionoche|noche)\\b`; - export const CommonDatePrefixRegex = `^[\\.]`; - export const SuffixAfterRegex = `\\b((a\\s+)?(o|y)\\s+(arriba|despu[eé]s|posterior|mayor|m[aá]s\\s+tarde)(?!\\s+(que|de)))\\b`; - export const YearPeriodRegex = `((((de(sde)?|durante|en)\\s+)?${YearRegex}\\s*(${TillRegex})\\s*${YearRegex})|(((entre)\\s+)${YearRegex}\\s*(${RangeConnectorRegex})\\s*${YearRegex}))`; - export const FutureSuffixRegex = `\\b(siguiente(s)?|pr[oó]xim[oa](s)?|(en\\s+el\\s+)?futuro)\\b`; - export const PastSuffixRegex = `^\\b$`; - export const ModPrefixRegex = `\\b(${RelativeRegex}|${AroundRegex}|${BeforeRegex}|${AfterRegex}|${SinceRegex})\\b`; - export const ModSuffixRegex = `\\b(${AgoRegex}|${LaterRegex}|${BeforeAfterRegex}|${FutureSuffixRegex}|${PastSuffixRegex})\\b`; - export const WrittenDecades: ReadonlyMap = new Map([["", 0]]); - export const SpecialDecadeCases: ReadonlyMap = new Map([["", 0]]); - export const DefaultLanguageFallback = `DMY`; - export const DurationDateRestrictions = [ "hoy" ]; - export const AmbiguityFiltersDict: ReadonlyMap = new Map([["^\\d{4}$", "(\\d\\.\\d{4}|\\d{4}\\.\\d)"],["^(este\\s+)?mi(\\s+([uú]ltimo|pasado|anterior|pr[oó]ximo|siguiente|que\\s+viene))?$", "\\b(este\\s+)?mi(\\s+([uú]ltimo|pasado|anterior|pr[oó]ximo|siguiente|que\\s+viene))?\\b"],["^a[nñ]o$", "(? = new Map([["á", "a"],["é", "e"],["í", "i"],["ó", "o"],["ú", "u"]]); - export const DoubleMultiplierRegex = `^(bi)(-|\\s)?`; - export const DayTypeRegex = `(d[ií]as?|diari(o|as|amente))$`; - export const WeekTypeRegex = `(semanas?|semanalmente)$`; - export const BiWeekTypeRegex = `(quincenalmente)$`; - export const WeekendTypeRegex = `(fin(es)?\\s+de\\s+semana|finde)$`; - export const MonthTypeRegex = `(mes(es)?|mensual(es|mente)?)$`; - export const QuarterTypeRegex = `(trimestral(es|mente)?)$`; - export const SemiAnnualTypeRegex = `(semestral(es|mente)?)$`; - export const YearTypeRegex = `(años?|anual(mente)?)$`; -} diff --git a/JavaScript/packages/recognizers-date-time/tsconfig.json b/JavaScript/packages/recognizers-date-time/tsconfig.json deleted file mode 100644 index 4c43817e54..0000000000 --- a/JavaScript/packages/recognizers-date-time/tsconfig.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "target": "es2015", - "outDir": "compiled", - "sourceMap": true, - "rootDir": "src", - "moduleResolution": "node", - "declaration": true, - "declarationDir": "dist/types", - "typeRoots": [ - "node_modules/@types" - ] - }, - "include": [ - "src" - ] -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-number-with-unit/.npmignore b/JavaScript/packages/recognizers-number-with-unit/.npmignore deleted file mode 100644 index 757fb9517d..0000000000 --- a/JavaScript/packages/recognizers-number-with-unit/.npmignore +++ /dev/null @@ -1,4 +0,0 @@ -* -!dist/*.js -!dist/types/**/* -!README.md \ No newline at end of file diff --git a/JavaScript/packages/recognizers-number-with-unit/README.md b/JavaScript/packages/recognizers-number-with-unit/README.md deleted file mode 100644 index 65e270f5ad..0000000000 --- a/JavaScript/packages/recognizers-number-with-unit/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# Microsoft.Recognizers.Text for JavaScript - -This module (`recognizers-text-number-with-unit`) is a sub-module of `recognizers-text-suite`. - -Please check the [main README](https://github.com/Microsoft/Recognizers-Text/tree/master/JavaScript/packages/recognizers-text-suite) for more details. \ No newline at end of file diff --git a/JavaScript/packages/recognizers-number-with-unit/package-lock.json b/JavaScript/packages/recognizers-number-with-unit/package-lock.json deleted file mode 100644 index 53404db853..0000000000 --- a/JavaScript/packages/recognizers-number-with-unit/package-lock.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "requires": true, - "lockfileVersion": 1, - "dependencies": { - "lodash.escaperegexp": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/lodash.escaperegexp/-/lodash.escaperegexp-4.1.2.tgz", - "integrity": "sha1-ZHYsSGGAglGKw99Mz11YhtriA0c=" - }, - "lodash.last": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/lodash.last/-/lodash.last-3.0.0.tgz", - "integrity": "sha1-JC9mMRLdTG5jcoxgo8kJ0b2tvUw=" - }, - "lodash.max": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/lodash.max/-/lodash.max-4.0.1.tgz", - "integrity": "sha1-hzVWbGGLNan3YFILSHrnllivE2o=" - } - }, - "version": "1.3.0" -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-number-with-unit/package.json b/JavaScript/packages/recognizers-number-with-unit/package.json deleted file mode 100644 index 12c3e36569..0000000000 --- a/JavaScript/packages/recognizers-number-with-unit/package.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "name": "@microsoft/recognizers-text-number-with-unit", - "version": "1.3.0", - "description": "recognizers-text-number-with-unit provides robust recognition and resolution of numbers with units expressed in multiple languages.", - "author": "Microsoft Corp.", - "license": "MIT", - "keywords": [ - "nlp", - "nlp-entity-extraction", - "entity-extraction", - "numex", - "parser-library" - ], - "main": "dist/recognizers-text-number-with-unit.umd.js", - "module": "dist/recognizers-text-number-with-unit.es5.js", - "typings": "dist/types/recognizers-text-number-with-unit.d.ts", - "browser": "dist/recognizers-text-number-with-unit.browser.js", - "repository": { - "type": "git", - "url": "https://github.com/Microsoft/Recognizers-Text" - }, - "bugs": { - "url": "https://github.com/Microsoft/Recognizers-Text/issues" - }, - "engines": { - "node": ">=10.3.0" - }, - "scripts": { - "build-resources": "ts-node --project ../resource-generator/tsconfig.json ../resource-generator/ ../recognizers-number-with-unit/resource-definitions.json", - "clean-build": "rimraf dist && rimraf compiled", - "prepare": "npm run build-resources && npm run clean-build && tsc && rollup -c" - }, - "dependencies": { - "lodash.escaperegexp": "^4.1.2", - "lodash.last": "^3.0.0", - "lodash.max": "^4.0.1", - "@microsoft/recognizers-text": "~1.3.0", - "@microsoft/recognizers-text-number": "~1.3.0" - } -} diff --git a/JavaScript/packages/recognizers-number-with-unit/resource-definitions.json b/JavaScript/packages/recognizers-number-with-unit/resource-definitions.json deleted file mode 100644 index 43425a1e08..0000000000 --- a/JavaScript/packages/recognizers-number-with-unit/resource-definitions.json +++ /dev/null @@ -1,83 +0,0 @@ -{ - "outputPath": "./src/resources/", - "configFiles": [ - { - "input": [ "Base-Units" ], - "output": "baseUnits", - "header": [ - "export namespace BaseUnits {" - ], - "footer": [ "}" ] - }, - { - "input": [ "Base-Numbers" ], - "output": "baseNumbers", - "header": [ - "export namespace BaseNumbers {" - ], - "footer": [ "}" ] - }, - { - "input": [ "Base-Currency" ], - "output": "baseCurrency", - "header": [ - "export namespace BaseCurrency {" - ], - "footer": [ "}" ] - }, - { - "input": [ "English", "English-NumbersWithUnit" ], - "output": "englishNumericWithUnit", - "header": [ - "import { BaseNumbers } from \"./baseNumbers\";", - "export namespace EnglishNumericWithUnit {" - ], - "footer": [ "}" ] - }, - { - "input": [ "Spanish", "Spanish-NumbersWithUnit" ], - "output": "spanishNumericWithUnit", - "header": [ - "import { BaseNumbers } from \"./baseNumbers\";", - "export namespace SpanishNumericWithUnit {" - ], - "footer": [ "}" ] - }, - { - "input": [ "Portuguese", "Portuguese-NumbersWithUnit" ], - "output": "portugueseNumericWithUnit", - "header": [ - "import { BaseNumbers } from \"./baseNumbers\";", - "export namespace PortugueseNumericWithUnit {" - ], - "footer": [ "}" ] - }, - { - "input": [ "Chinese", "Chinese-NumbersWithUnit" ], - "output": "chineseNumericWithUnit", - "header": [ - "import { BaseNumbers } from \"./baseNumbers\";", - "export namespace ChineseNumericWithUnit {" - ], - "footer": [ "}" ] - }, - { - "input": [ "Japanese", "Japanese-NumbersWithUnit" ], - "output": "japaneseNumericWithUnit", - "header": [ - "import { BaseNumbers } from \"./baseNumbers\";", - "export namespace JapaneseNumericWithUnit {" - ], - "footer": [ "}" ] - }, - { - "input": [ "French", "French-NumbersWithUnit" ], - "output": "frenchNumericWithUnit", - "header": [ - "import { BaseNumbers } from \"./baseNumbers\";", - "export namespace FrenchNumericWithUnit {" - ], - "footer": [ "}" ] - } - ] -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-number-with-unit/rollup.config.js b/JavaScript/packages/recognizers-number-with-unit/rollup.config.js deleted file mode 100644 index 773a491bca..0000000000 --- a/JavaScript/packages/recognizers-number-with-unit/rollup.config.js +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import resolve from 'rollup-plugin-node-resolve'; -import commonjs from 'rollup-plugin-commonjs'; -import sourceMaps from 'rollup-plugin-sourcemaps'; -import pkg from './package.json'; -import camelCase from 'lodash.camelcase'; -import alias from 'rollup-plugin-alias'; -import path from 'path'; - -export default { - input: `compiled/recognizers-text-number-with-unit.js`, - output: [ - { file: pkg.module, format: 'es' }, - { file: pkg.main, name: camelCase(pkg.name), format: 'umd', exports: 'named' }, - { file: pkg.browser, format: 'iife', name: camelCase(pkg.name), exports: 'named' } - ], - exports: 'named', - sourcemap: true, - plugins: [ - alias({ - '@microsoft/recognizers-text': path.resolve(__dirname, '../recognizers-text/compiled/recognizers-text.js'), - '@microsoft/recognizers-text-number': path.resolve(__dirname, '../recognizers-number/compiled/recognizers-text-number.js') - }), - // Allow bundling cjs modules (unlike webpack, rollup doesn't understand cjs) - commonjs(), - // Allow node_modules resolution, so you can use 'external' to control - // which external modules to include in the bundle - // https://github.com/rollup/rollup-plugin-node-resolve#usage - resolve(), - - // Resolve source maps to the original source - sourceMaps() - ] -}; diff --git a/JavaScript/packages/recognizers-number-with-unit/src/numberWithUnit/chinese/age.ts b/JavaScript/packages/recognizers-number-with-unit/src/numberWithUnit/chinese/age.ts deleted file mode 100644 index 921f1d48e6..0000000000 --- a/JavaScript/packages/recognizers-number-with-unit/src/numberWithUnit/chinese/age.ts +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { CultureInfo, Culture } from "@microsoft/recognizers-text-number"; -import { Constants } from "../constants"; -import { ChineseNumberWithUnitExtractorConfiguration, ChineseNumberWithUnitParserConfiguration } from "./base"; -import { ChineseNumericWithUnit } from "../../resources/chineseNumericWithUnit"; - -export class ChineseAgeExtractorConfiguration extends ChineseNumberWithUnitExtractorConfiguration { - readonly suffixList: ReadonlyMap; - readonly prefixList: ReadonlyMap; - readonly ambiguousUnitList: readonly string[]; - readonly extractType: string; - - constructor(ci?: CultureInfo) { - if (!ci) { - ci = new CultureInfo(Culture.Chinese); - } - - super(ci); - - this.extractType = Constants.SYS_UNIT_AGE; - - this.suffixList = ChineseNumericWithUnit.AgeSuffixList; - this.prefixList = new Map(); - this.ambiguousUnitList = ChineseNumericWithUnit.AgeAmbiguousValues; - } -} - -export class ChineseAgeParserConfiguration extends ChineseNumberWithUnitParserConfiguration { - constructor(ci?: CultureInfo) { - if(!ci) { - ci = new CultureInfo(Culture.Chinese); - } - - super(ci); - - this.BindDictionary(ChineseNumericWithUnit.AgeSuffixList); - } -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-number-with-unit/src/numberWithUnit/chinese/base.ts b/JavaScript/packages/recognizers-number-with-unit/src/numberWithUnit/chinese/base.ts deleted file mode 100644 index ee53196839..0000000000 --- a/JavaScript/packages/recognizers-number-with-unit/src/numberWithUnit/chinese/base.ts +++ /dev/null @@ -1,93 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { ExtractResult, IExtractor, IParser, RegExpUtility } from "@microsoft/recognizers-text"; -import { Culture, CultureInfo, NumberMode, AgnosticNumberParserFactory, AgnosticNumberParserType, ChineseNumberExtractor, ChineseNumberParserConfiguration, ChineseNumberExtractorMode } from "@microsoft/recognizers-text-number"; -import { Constants } from "../constants"; -import { INumberWithUnitExtractorConfiguration } from "../extractors"; -import { BaseNumberWithUnitParserConfiguration } from "../parsers"; -import { ChineseNumericWithUnit } from "../../resources/chineseNumericWithUnit"; -import { BaseUnits } from "../../resources/baseUnits"; - -export abstract class ChineseNumberWithUnitExtractorConfiguration implements INumberWithUnitExtractorConfiguration { - private readonly halfUnitRegex = RegExpUtility.getSafeRegExp(ChineseNumericWithUnit.HalfUnitRegex); - - abstract readonly suffixList: ReadonlyMap; - abstract readonly prefixList: ReadonlyMap; - abstract readonly ambiguousUnitList: readonly string[]; - readonly abstract extractType: string; - - readonly cultureInfo: CultureInfo; - readonly unitNumExtractor: IExtractor; - readonly buildPrefix: string; - readonly buildSuffix: string; - readonly connectorToken: string; - readonly compoundUnitConnectorRegex: RegExp; - readonly nonUnitRegex: RegExp; - readonly ambiguousUnitNumberMultiplierRegex: RegExp; - - constructor(ci: CultureInfo) { - this.cultureInfo = ci; - this.unitNumExtractor = new ChineseNumberExtractor(ChineseNumberExtractorMode.ExtractAll); - - this.buildPrefix = ChineseNumericWithUnit.BuildPrefix; - this.buildSuffix = ChineseNumericWithUnit.BuildSuffix; - this.connectorToken = ChineseNumericWithUnit.ConnectorToken; - this.compoundUnitConnectorRegex = RegExpUtility.getSafeRegExp(ChineseNumericWithUnit.CompoundUnitConnectorRegex); - this.nonUnitRegex = RegExpUtility.getSafeRegExp(BaseUnits.PmNonUnitRegex); - } - - expandHalfSuffix(source: string, result: ExtractResult[], numbers: ExtractResult[]) { - // expand Chinese phrase to the `half` patterns when it follows closely origin phrase. - if (this.halfUnitRegex != null){ - let match = new Array(); - for (let number of numbers) { - if (RegExpUtility.getMatches(this.halfUnitRegex, number.text).length > 0){ - match.push(number); - } - } - if (match.length > 0){ - let res = new Array(); - for (let er of result){ - let start = er.start; - let length = er.length; - let matchSuffix = new Array(); - for (let mr of match){ - if (mr.start == start + length){ - matchSuffix.push(mr); - } - } - if (matchSuffix.length === 1){ - let mr = matchSuffix[0]; - er.length += mr.length; - er.text += mr.text; - let tmp = new Array(); - tmp.push(er.data); - tmp.push(mr); - er.data = tmp; - } - res.push(er); - } - result = res; - } - } - } -} - -export class ChineseNumberWithUnitParserConfiguration extends BaseNumberWithUnitParserConfiguration { - readonly internalNumberParser: IParser; - readonly internalNumberExtractor: IExtractor; - readonly connectorToken: string; - readonly currencyNameToIsoCodeMap: ReadonlyMap; - readonly currencyFractionCodeList: ReadonlyMap; - - constructor(ci: CultureInfo) { - super(ci); - - this.internalNumberExtractor = new ChineseNumberExtractor(ChineseNumberExtractorMode.Default); - this.internalNumberParser = AgnosticNumberParserFactory.getParser(AgnosticNumberParserType.Number, new ChineseNumberParserConfiguration()); - this.connectorToken = ''; - this.currencyNameToIsoCodeMap = ChineseNumericWithUnit.CurrencyNameToIsoCodeMap; - this.currencyFractionCodeList = ChineseNumericWithUnit.FractionalUnitNameToCodeMap; - } -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-number-with-unit/src/numberWithUnit/chinese/currency.ts b/JavaScript/packages/recognizers-number-with-unit/src/numberWithUnit/chinese/currency.ts deleted file mode 100644 index d02198fcf4..0000000000 --- a/JavaScript/packages/recognizers-number-with-unit/src/numberWithUnit/chinese/currency.ts +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { CultureInfo, Culture } from "@microsoft/recognizers-text-number"; -import { Constants } from "../constants"; -import { ChineseNumberWithUnitExtractorConfiguration, ChineseNumberWithUnitParserConfiguration } from "./base"; -import { ChineseNumericWithUnit } from "../../resources/chineseNumericWithUnit"; - -export class ChineseCurrencyExtractorConfiguration extends ChineseNumberWithUnitExtractorConfiguration { - readonly suffixList: ReadonlyMap; - readonly prefixList: ReadonlyMap; - readonly ambiguousUnitList: readonly string[]; - readonly extractType: string; - - constructor(ci?: CultureInfo) { - if (!ci) { - ci = new CultureInfo(Culture.Chinese); - } - - super(ci); - - this.extractType = Constants.SYS_UNIT_CURRENCY; - - // Reference Source: https:// en.wikipedia.org/wiki/List_of_circulating_currencies - this.suffixList = ChineseNumericWithUnit.CurrencySuffixList; - this.prefixList = ChineseNumericWithUnit.CurrencyPrefixList; - this.ambiguousUnitList = ChineseNumericWithUnit.CurrencyAmbiguousValues;; - } -} - -export class ChineseCurrencyParserConfiguration extends ChineseNumberWithUnitParserConfiguration { - constructor(ci?: CultureInfo) { - if (!ci) { - ci = new CultureInfo(Culture.Chinese); - } - - super(ci); - - this.BindDictionary(ChineseNumericWithUnit.CurrencySuffixList); - this.BindDictionary(ChineseNumericWithUnit.CurrencyPrefixList); - } -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-number-with-unit/src/numberWithUnit/chinese/dimension.ts b/JavaScript/packages/recognizers-number-with-unit/src/numberWithUnit/chinese/dimension.ts deleted file mode 100644 index 18182bfc8e..0000000000 --- a/JavaScript/packages/recognizers-number-with-unit/src/numberWithUnit/chinese/dimension.ts +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { CultureInfo, Culture } from "@microsoft/recognizers-text-number"; -import { Constants } from "../constants"; -import { ChineseNumberWithUnitExtractorConfiguration, ChineseNumberWithUnitParserConfiguration } from "./base"; -import { ChineseNumericWithUnit } from "../../resources/chineseNumericWithUnit"; - -export class ChineseDimensionExtractorConfiguration extends ChineseNumberWithUnitExtractorConfiguration { - - readonly suffixList: ReadonlyMap; - readonly prefixList: ReadonlyMap; - readonly ambiguousUnitList: readonly string[]; - readonly extractType: string; - - constructor(ci?: CultureInfo) { - if (!ci) { - ci = new CultureInfo(Culture.Chinese); - } - - super(ci); - - this.extractType = Constants.SYS_UNIT_DIMENSION; - - this.suffixList = ChineseNumericWithUnit.DimensionSuffixList; - this.prefixList = new Map(); - this.ambiguousUnitList = ChineseNumericWithUnit.DimensionAmbiguousValues; - } -} - -export class ChineseDimensionParserConfiguration extends ChineseNumberWithUnitParserConfiguration { - constructor(ci?: CultureInfo) { - if (!ci) { - ci = new CultureInfo(Culture.Chinese); - } - - super(ci); - - this.BindDictionary(ChineseNumericWithUnit.DimensionSuffixList); - } -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-number-with-unit/src/numberWithUnit/chinese/temperature.ts b/JavaScript/packages/recognizers-number-with-unit/src/numberWithUnit/chinese/temperature.ts deleted file mode 100644 index 1f5ef995c5..0000000000 --- a/JavaScript/packages/recognizers-number-with-unit/src/numberWithUnit/chinese/temperature.ts +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { CultureInfo, Culture, RegExpUtility } from "@microsoft/recognizers-text-number"; -import { Constants } from "../constants"; -import { ChineseNumberWithUnitExtractorConfiguration, ChineseNumberWithUnitParserConfiguration } from "./base"; -import { BaseUnits } from "../../resources/baseUnits"; -import { ChineseNumericWithUnit } from "../../resources/chineseNumericWithUnit"; - -export class ChineseTemperatureExtractorConfiguration extends ChineseNumberWithUnitExtractorConfiguration { - readonly suffixList: ReadonlyMap; - readonly prefixList: ReadonlyMap; - readonly ambiguousUnitList: readonly string[]; - readonly extractType: string; - readonly ambiguousUnitNumberMultiplierRegex: RegExp; - - constructor(ci?: CultureInfo) { - if (!ci) { - ci = new CultureInfo(Culture.Chinese); - } - - super(ci); - - this.extractType = Constants.SYS_UNIT_TEMPERATURE; - - this.suffixList = ChineseNumericWithUnit.TemperatureSuffixList; - this.prefixList = ChineseNumericWithUnit.TemperaturePrefixList; - this.ambiguousUnitList = ChineseNumericWithUnit.TemperatureAmbiguousValues; - - this.ambiguousUnitNumberMultiplierRegex = RegExpUtility.getSafeRegExp(BaseUnits.AmbiguousUnitNumberMultiplierRegex, "gs"); - } -} - -export class ChineseTemperatureParserConfiguration extends ChineseNumberWithUnitParserConfiguration { - constructor(ci?: CultureInfo) { - if (!ci) { - ci = new CultureInfo(Culture.Chinese); - } - - super(ci); - - this.BindDictionary(ChineseNumericWithUnit.TemperaturePrefixList); - this.BindDictionary(ChineseNumericWithUnit.TemperatureSuffixList); - } -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-number-with-unit/src/numberWithUnit/constants.ts b/JavaScript/packages/recognizers-number-with-unit/src/numberWithUnit/constants.ts deleted file mode 100644 index dfd8c7bdac..0000000000 --- a/JavaScript/packages/recognizers-number-with-unit/src/numberWithUnit/constants.ts +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { BaseUnits } from "../resources/baseUnits"; - -export class Constants { - static readonly SYS_UNIT: string = "builtin.unit"; - static readonly SYS_UNIT_DIMENSION: string = "builtin.unit.dimension"; - static readonly SYS_UNIT_AGE: string = "builtin.unit.age"; - static readonly SYS_UNIT_AREA: string = "builtin.unit.area"; - static readonly SYS_UNIT_CURRENCY: string = "builtin.unit.currency"; - static readonly SYS_UNIT_LENGTH: string = "builtin.unit.length"; - static readonly SYS_UNIT_SPEED: string = "builtin.unit.speed"; - static readonly SYS_UNIT_TEMPERATURE: string = "builtin.unit.temperature"; - static readonly SYS_UNIT_VOLUME: string = "builtin.unit.volume"; - static readonly SYS_UNIT_WEIGHT: string = "builtin.unit.weight"; - static readonly SYS_NUM: string = "builtin.num"; - - // For cases like '2:00 pm', both 'pm' and '00 pm' are not dimension - static readonly AMBIGUOUS_TIME_TERM: string = BaseUnits.AmbiguousTimeTerm; - - // For currencies without ISO codes, we use internal values prefixed by '_'. - // These values should never be present in parse output. - static readonly FAKE_ISO_CODE_PREFIX: string = "_"; -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-number-with-unit/src/numberWithUnit/english/age.ts b/JavaScript/packages/recognizers-number-with-unit/src/numberWithUnit/english/age.ts deleted file mode 100644 index 958764a847..0000000000 --- a/JavaScript/packages/recognizers-number-with-unit/src/numberWithUnit/english/age.ts +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { CultureInfo, Culture } from "@microsoft/recognizers-text-number"; -import { Constants } from "../constants"; -import { EnglishNumberWithUnitExtractorConfiguration, EnglishNumberWithUnitParserConfiguration } from "./base"; -import { EnglishNumericWithUnit } from "../../resources/englishNumericWithUnit"; - -export class EnglishAgeExtractorConfiguration extends EnglishNumberWithUnitExtractorConfiguration { - readonly suffixList: ReadonlyMap; - readonly prefixList: ReadonlyMap; - readonly ambiguousUnitList: readonly string[]; - readonly extractType: string; - - constructor(ci?: CultureInfo) { - if (!ci) { - ci = new CultureInfo(Culture.English); - } - - super(ci); - - this.extractType = Constants.SYS_UNIT_AGE; - - this.suffixList = EnglishNumericWithUnit.AgeSuffixList; - this.prefixList = EnglishNumericWithUnit.AgePrefixList; - this.ambiguousUnitList = EnglishNumericWithUnit.AmbiguousAgeUnitList; - } -} - -export class EnglishAgeParserConfiguration extends EnglishNumberWithUnitParserConfiguration { - constructor(ci?: CultureInfo) { - if (!ci) { - ci = new CultureInfo(Culture.English); - } - - super(ci); - - this.BindDictionary(EnglishNumericWithUnit.AgeSuffixList); - this.BindDictionary(EnglishNumericWithUnit.AgePrefixList); - } -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-number-with-unit/src/numberWithUnit/english/base.ts b/JavaScript/packages/recognizers-number-with-unit/src/numberWithUnit/english/base.ts deleted file mode 100644 index ba4ff7f39e..0000000000 --- a/JavaScript/packages/recognizers-number-with-unit/src/numberWithUnit/english/base.ts +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { ExtractResult, IExtractor, IParser, RegExpUtility } from "@microsoft/recognizers-text"; -import { Culture, CultureInfo, NumberMode, AgnosticNumberParserFactory, AgnosticNumberParserType, EnglishNumberExtractor, EnglishNumberParserConfiguration } from "@microsoft/recognizers-text-number"; -import { Constants } from "../constants"; -import { INumberWithUnitExtractorConfiguration } from "../extractors"; -import { BaseNumberWithUnitParserConfiguration } from "../parsers"; -import { EnglishNumericWithUnit } from "../../resources/englishNumericWithUnit"; -import { BaseUnits } from "../../resources/baseUnits"; - -export abstract class EnglishNumberWithUnitExtractorConfiguration implements INumberWithUnitExtractorConfiguration { - abstract readonly suffixList: ReadonlyMap; - abstract readonly prefixList: ReadonlyMap; - abstract readonly ambiguousUnitList: readonly string[]; - readonly abstract extractType: string; - - readonly cultureInfo: CultureInfo; - readonly unitNumExtractor: IExtractor; - readonly buildPrefix: string; - readonly buildSuffix: string; - readonly connectorToken: string; - readonly compoundUnitConnectorRegex: RegExp; - readonly nonUnitRegex: RegExp; - readonly ambiguousUnitNumberMultiplierRegex: RegExp; - - constructor(ci: CultureInfo) { - this.cultureInfo = ci; - this.unitNumExtractor = new EnglishNumberExtractor(NumberMode.Unit); - - this.buildPrefix = EnglishNumericWithUnit.BuildPrefix; - this.buildSuffix = EnglishNumericWithUnit.BuildSuffix; - this.connectorToken = ''; - this.compoundUnitConnectorRegex = RegExpUtility.getSafeRegExp(EnglishNumericWithUnit.CompoundUnitConnectorRegex); - this.nonUnitRegex = RegExpUtility.getSafeRegExp(BaseUnits.PmNonUnitRegex); - } - - expandHalfSuffix(source: string, result: ExtractResult[], numbers: ExtractResult[]) { - } -} - -export class EnglishNumberWithUnitParserConfiguration extends BaseNumberWithUnitParserConfiguration { - readonly internalNumberParser: IParser; - readonly internalNumberExtractor: IExtractor; - readonly connectorToken: string; - readonly currencyNameToIsoCodeMap: ReadonlyMap; - readonly currencyFractionCodeList: ReadonlyMap; - - constructor(ci: CultureInfo) { - super(ci); - - this.internalNumberExtractor = new EnglishNumberExtractor(NumberMode.Default); - this.internalNumberParser = AgnosticNumberParserFactory.getParser(AgnosticNumberParserType.Number, new EnglishNumberParserConfiguration()); - this.connectorToken = ''; - this.currencyNameToIsoCodeMap = EnglishNumericWithUnit.CurrencyNameToIsoCodeMap; - this.currencyFractionCodeList = EnglishNumericWithUnit.FractionalUnitNameToCodeMap; - } -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-number-with-unit/src/numberWithUnit/english/currency.ts b/JavaScript/packages/recognizers-number-with-unit/src/numberWithUnit/english/currency.ts deleted file mode 100644 index 0d11410b24..0000000000 --- a/JavaScript/packages/recognizers-number-with-unit/src/numberWithUnit/english/currency.ts +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { CultureInfo, Culture } from "@microsoft/recognizers-text-number"; -import { Constants } from "../constants"; -import { EnglishNumberWithUnitExtractorConfiguration, EnglishNumberWithUnitParserConfiguration } from "./base"; -import { EnglishNumericWithUnit } from "../../resources/englishNumericWithUnit"; - -export class EnglishCurrencyExtractorConfiguration extends EnglishNumberWithUnitExtractorConfiguration { - readonly suffixList: ReadonlyMap; - readonly prefixList: ReadonlyMap; - readonly ambiguousUnitList: readonly string[]; - readonly extractType: string; - - constructor(ci?: CultureInfo) { - if (!ci) { - ci = new CultureInfo(Culture.English); - } - - super(ci); - - this.extractType = Constants.SYS_UNIT_CURRENCY; - - // Reference Source: https:// en.wikipedia.org/wiki/List_of_circulating_currencies - this.suffixList = EnglishNumericWithUnit.CurrencySuffixList; - this.prefixList = EnglishNumericWithUnit.CurrencyPrefixList; - this.ambiguousUnitList = EnglishNumericWithUnit.AmbiguousCurrencyUnitList; - } -} - -export class EnglishCurrencyParserConfiguration extends EnglishNumberWithUnitParserConfiguration { - constructor(ci?: CultureInfo) { - if (!ci) { - ci = new CultureInfo(Culture.English); - } - - super(ci); - - this.BindDictionary(EnglishNumericWithUnit.CurrencySuffixList); - this.BindDictionary(EnglishNumericWithUnit.CurrencyPrefixList); - } -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-number-with-unit/src/numberWithUnit/english/dimension.ts b/JavaScript/packages/recognizers-number-with-unit/src/numberWithUnit/english/dimension.ts deleted file mode 100644 index 17a949b042..0000000000 --- a/JavaScript/packages/recognizers-number-with-unit/src/numberWithUnit/english/dimension.ts +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { CultureInfo, Culture } from "@microsoft/recognizers-text-number"; -import { Constants } from "../constants"; -import { EnglishNumberWithUnitExtractorConfiguration, EnglishNumberWithUnitParserConfiguration } from "./base"; -import { EnglishNumericWithUnit } from "../../resources/englishNumericWithUnit"; - -const dimensionSuffixList = new Map([ - ...EnglishNumericWithUnit.InformationSuffixList, - ...EnglishNumericWithUnit.AreaSuffixList, - ...EnglishNumericWithUnit.LengthSuffixList, - ...EnglishNumericWithUnit.SpeedSuffixList, - ...EnglishNumericWithUnit.VolumeSuffixList, - ...EnglishNumericWithUnit.WeightSuffixList -]); - -export class EnglishDimensionExtractorConfiguration extends EnglishNumberWithUnitExtractorConfiguration { - - readonly suffixList: ReadonlyMap; - readonly prefixList: ReadonlyMap; - readonly ambiguousUnitList: readonly string[]; - readonly extractType: string; - - constructor(ci?: CultureInfo) { - if (!ci) { - ci = new CultureInfo(Culture.English); - } - - super(ci); - - this.extractType = Constants.SYS_UNIT_DIMENSION; - - this.suffixList = dimensionSuffixList; - this.prefixList = new Map(); - this.ambiguousUnitList = EnglishNumericWithUnit.AmbiguousDimensionUnitList.concat( - EnglishNumericWithUnit.AmbiguousAngleUnitList.concat( - EnglishNumericWithUnit.AmbiguousLengthUnitList.concat( - EnglishNumericWithUnit.AmbiguousSpeedUnitList.concat( - EnglishNumericWithUnit.AmbiguousWeightUnitList)))); - } -} - -export class EnglishDimensionParserConfiguration extends EnglishNumberWithUnitParserConfiguration { - constructor(ci?: CultureInfo) { - if (!ci) { - ci = new CultureInfo(Culture.English); - } - - super(ci); - - this.BindDictionary(dimensionSuffixList); - } -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-number-with-unit/src/numberWithUnit/english/temperature.ts b/JavaScript/packages/recognizers-number-with-unit/src/numberWithUnit/english/temperature.ts deleted file mode 100644 index 005eacf77c..0000000000 --- a/JavaScript/packages/recognizers-number-with-unit/src/numberWithUnit/english/temperature.ts +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { CultureInfo, Culture, RegExpUtility } from "@microsoft/recognizers-text-number"; -import { Constants } from "../constants"; -import { EnglishNumberWithUnitExtractorConfiguration, EnglishNumberWithUnitParserConfiguration } from "./base"; -import { BaseUnits } from "../../resources/baseUnits"; -import { EnglishNumericWithUnit } from "../../resources/englishNumericWithUnit"; - -export class EnglishTemperatureExtractorConfiguration extends EnglishNumberWithUnitExtractorConfiguration { - readonly suffixList: ReadonlyMap; - readonly prefixList: ReadonlyMap; - readonly ambiguousUnitList: readonly string[]; - readonly extractType: string; - readonly ambiguousUnitNumberMultiplierRegex: RegExp; - - constructor(ci?: CultureInfo) { - if (!ci) { - ci = new CultureInfo(Culture.English); - } - - super(ci); - - this.extractType = Constants.SYS_UNIT_TEMPERATURE; - - this.suffixList = EnglishNumericWithUnit.TemperatureSuffixList; - this.prefixList = new Map(); - this.ambiguousUnitList = EnglishNumericWithUnit.AmbiguousTemperatureUnitList; - - this.ambiguousUnitNumberMultiplierRegex = RegExpUtility.getSafeRegExp(BaseUnits.AmbiguousUnitNumberMultiplierRegex, "gs"); - } -} - -export class EnglishTemperatureParserConfiguration extends EnglishNumberWithUnitParserConfiguration { - constructor(ci?: CultureInfo) { - if (!ci) { - ci = new CultureInfo(Culture.English); - } - - super(ci); - - this.BindDictionary(EnglishNumericWithUnit.TemperatureSuffixList); - } -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-number-with-unit/src/numberWithUnit/extractors.ts b/JavaScript/packages/recognizers-number-with-unit/src/numberWithUnit/extractors.ts deleted file mode 100644 index 4ec8a47147..0000000000 --- a/JavaScript/packages/recognizers-number-with-unit/src/numberWithUnit/extractors.ts +++ /dev/null @@ -1,599 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { IExtractor, ExtractResult, RegExpUtility, Match, StringUtility } from "@microsoft/recognizers-text"; -import { Culture, CultureInfo, Constants as NumberConstants } from "@microsoft/recognizers-text-number"; -import { Constants } from "./constants"; -import max = require("lodash.max"); -import escapeRegExp = require("lodash.escaperegexp"); -import { BaseUnits } from "../resources/baseUnits"; - -export interface INumberWithUnitExtractorConfiguration { - readonly suffixList: ReadonlyMap; - readonly prefixList: ReadonlyMap; - readonly ambiguousUnitList: readonly string[]; - - readonly extractType: string; - readonly cultureInfo: CultureInfo; - readonly unitNumExtractor: IExtractor; - readonly buildPrefix: string; - readonly buildSuffix: string; - readonly connectorToken: string; - readonly compoundUnitConnectorRegex: RegExp; - readonly nonUnitRegex: RegExp; - readonly ambiguousUnitNumberMultiplierRegex: RegExp; - expandHalfSuffix(source: string, result: ExtractResult[], numbers: ExtractResult[]): void; -} - -export class NumberWithUnitExtractor implements IExtractor { - private readonly config: INumberWithUnitExtractorConfiguration; - private readonly suffixRegexes: Set; - private readonly prefixRegexes: Set; - - private readonly separateRegex: RegExp; - private readonly singleCharUnitRegex: RegExp; - - private readonly maxPrefixMatchLen: number; - - constructor(config: INumberWithUnitExtractorConfiguration) { - this.config = config; - if (this.config.suffixList && this.config.suffixList.size > 0) { - this.suffixRegexes = this.buildRegexFromSet(Array.from(this.config.suffixList.values())); - } - else { - this.suffixRegexes = new Set(); // empty - } - - if (this.config.prefixList && this.config.prefixList.size > 0) { - let maxLength = 0; - - this.config.prefixList.forEach(preMatch => { - let len = max(preMatch.split('|').filter(s => s && s.length).map(s => s.length)); - maxLength = maxLength >= len ? maxLength : len; - }); - - // 2 is the maximum length of spaces. - this.maxPrefixMatchLen = maxLength + 2; - - this.prefixRegexes = this.buildRegexFromSet(Array.from(this.config.prefixList.values())); - } - else { - this.prefixRegexes = new Set(); // empty - } - - this.separateRegex = this.buildSeparateRegexFromSet(); - - this.singleCharUnitRegex = RegExpUtility.getSafeRegExp(BaseUnits.SingleCharUnitRegex, "gs"); - } - - extract(source: string): ExtractResult[] { - if (!this.preCheckStr(source)) { - return new Array(); - } - - let mappingPrefix = new Map(); - let matched = new Array(source.length); - let numbers = this.config.unitNumExtractor.extract(source); - let result = new Array(); - let sourceLen = source.length; - - if (numbers.length > 0 && this.config.extractType == Constants.SYS_UNIT_CURRENCY) { - numbers.forEach(extNumber => { - let start = extNumber.start; - let length = extNumber.length; - let numberPrefix = false; - let numberSuffix = false; - this.prefixRegexes.forEach(regex => { - let collection = RegExpUtility.getMatches(regex, source).filter(m => m.length); - if (collection.length === 0) { - return; - } - collection.forEach(match => { - if (match.index + match.length == start) { - numberPrefix = true; - } - }); - }); - this.suffixRegexes.forEach(regex => { - let collection = RegExpUtility.getMatches(regex, source).filter(m => m.length); - if (collection.length === 0) { - return; - } - collection.forEach(match => { - if (start + length == match.index) { - numberSuffix = true; - } - }); - }); - if (numberPrefix && numberSuffix && extNumber.text.indexOf(",") != -1) { - let commaIndex = start + extNumber.text.indexOf(","); - source = source.substring(0, commaIndex) + " " + source.substring(commaIndex + 1) - } - - }) - numbers = this.config.unitNumExtractor.extract(source); - } - - /* Special case for cases where number multipliers clash with unit */ - let ambiguousMultiplierRegex = this.config.ambiguousUnitNumberMultiplierRegex; - if (ambiguousMultiplierRegex !== null) { - - numbers.forEach(extNumber => { - let match = RegExpUtility.getMatches(ambiguousMultiplierRegex, extNumber.text); - if (match.length === 1) { - let newLength = extNumber.length - match[0].length; - extNumber.text = extNumber.text.substring(0, newLength); - extNumber.length = newLength; - } - }); - } - - /* Mix prefix and numbers, make up a prefix-number combination */ - if (this.maxPrefixMatchLen !== 0) { - numbers.forEach(num => { - - if (num.start === undefined || num.length === undefined) { - return; - } - let maxFindPref = Math.min(this.maxPrefixMatchLen, num.start); - if (maxFindPref === 0) { - return; - } - - /* Scan from left to right , find the longest match */ - let leftStr = source.substring(num.start - maxFindPref, num.start - maxFindPref + maxFindPref);; - let lastIndex = leftStr.length; - let bestMatch: Match = null; - this.prefixRegexes.forEach(regex => { - let collection = RegExpUtility.getMatches(regex, leftStr).filter(m => m.length); - if (collection.length === 0) { - return; - } - - collection.forEach(match => { - if (leftStr.substring(match.index, lastIndex).trim() === match.value) { - if (bestMatch === null || bestMatch.index >= match.index) { - bestMatch = match; - } - } - }); - }); - - if (bestMatch !== null) { - let offSet = lastIndex - bestMatch.index; - let unitStr = leftStr.substring(bestMatch.index, lastIndex); - mappingPrefix.set(num.start, { - offset: lastIndex - bestMatch.index, - unitString: unitStr - }); - } - }); - } - - for (let num of numbers) { - if (num.start === undefined || num.length === undefined) { - continue; - } - - let start = num.start; - let length = num.length; - let maxFindLen = sourceLen - start - length; - - let prefixUnit: PrefixUnitResult = mappingPrefix.has(start) ? mappingPrefix.get(start) : null; - - if (maxFindLen > 0) { - let rightSub = source.substring(start + length, start + length + maxFindLen); - let unitMatch = Array.from(this.suffixRegexes.values()).map(r => RegExpUtility.getMatches(r, rightSub)) - .filter(m => m.length > 0); - - let maxlen = 0; - for (let i = 0; i < unitMatch.length; i++) { - for (let m of unitMatch[i]) { - if (m.length > 0) { - let endpos = m.index + m.length; - if (m.index >= 0) { - let midStr = rightSub.substring(0, Math.min(m.index, rightSub.length)); - if (maxlen < endpos && (StringUtility.isNullOrWhitespace(midStr) || midStr.trim() === this.config.connectorToken)) { - maxlen = endpos; - } - } - } - } - } - - if (maxlen !== 0) { - for (let i = 0; i < length + maxlen; i++) { - matched[i + start] = true; - } - - let substr = source.substring(start, start + length + maxlen); - let er = { - start: start, - length: length + maxlen, - text: substr, - type: this.config.extractType - } as ExtractResult; - - if (prefixUnit !== null) { - er.start -= prefixUnit.offset; - er.length += prefixUnit.offset; - er.text = prefixUnit.unitString + er.text; - } - - /* Relative position will be used in Parser */ - num.start = start - er.start; - er.data = num; - - let isNotUnit = false; - if (er.type === Constants.SYS_UNIT_DIMENSION) { - let nonUnitMatch = RegExpUtility.getMatches(this.config.nonUnitRegex, source); - - nonUnitMatch.forEach(match => { - if (er.start >= match.index && er.start + er.length <= match.index + match.length) { - isNotUnit = true; - } - }); - } - - if (isNotUnit) { - continue; - } - - result.push(er); - continue; - } - } - - if (prefixUnit !== null) { - let er = { - start: num.start - prefixUnit.offset, - length: num.length + prefixUnit.offset, - text: prefixUnit.unitString + num.text, - type: this.config.extractType - } as ExtractResult; - - /* Relative position will be used in Parser */ - num.start = start - er.start; - er.data = num; - result.push(er); - } - } - - // extract Separate unit - if (this.separateRegex !== null) { - this.extractSeparateUnits(source, result); - } - - // remove common ambiguous cases - result = this.filterAmbiguity(result, source); - - // expand Chinese phrase to the `half` patterns when it follows closely origin phrase. - this.config.expandHalfSuffix(source, result, numbers); - - return result; - } - - validateUnit(source: string): boolean { - return source.substring(0, 1) !== '-'; - } - - protected filterAmbiguity(ers: ExtractResult[], input: string): ExtractResult[] { - - - // Filter single-char units if not exact match - ers = ers.filter(er => { - return !(er.length !== input.length && RegExpUtility.isMatch(this.singleCharUnitRegex, er.text)); - }); - - return ers; - } - - protected preCheckStr(str: string): number { - return str && str.length; - } - - protected extractSeparateUnits(source: string, numDependResults: ExtractResult[]): void { - // Default is false - let matchResult = new Array(source.length); - numDependResults.forEach(numDependResult => { - let start = numDependResult.start; - let i = 0; - do { - matchResult[start + i++] = true; - } while (i < numDependResult.length); - }); - - // Extract all SeparateUnits, then merge it with numDependResults - let matchCollection = RegExpUtility.getMatches(this.separateRegex, source); - if (matchCollection.length > 0) { - matchCollection.forEach(match => { - let i = 0; - while (i < match.length && !matchResult[match.index + i]) { - i++; - } - if (i === match.length) { - // Mark as extracted - for (let j = 0; j < i; j++) { - matchResult[j] = true; - } - - let isNotUnit = false; - if (match.value === Constants.AMBIGUOUS_TIME_TERM) { - let nonUnitMatch = RegExpUtility.getMatches(this.config.nonUnitRegex, source); - - nonUnitMatch.forEach(time => { - if (this.DimensionInsideTime(match, time)) { - isNotUnit = true; - } - }); - } - - if (isNotUnit === false) { - numDependResults.push({ - start: match.index, - length: match.length, - text: match.value, - type: this.config.extractType, - data: null - } as ExtractResult); - } - } - }); - } - } - - protected buildRegexFromSet(collection: string[], ignoreCase: boolean = true): Set { - return new Set( - collection.map(regexString => { - let regexTokens = regexString.split('|').map(escapeRegExp); - let pattern = `${this.config.buildPrefix}(${regexTokens.join('|')})${this.config.buildSuffix}`; - pattern += this.getRegexWithBrackets(`(${regexTokens.join('|')})`); - let options = "gs"; - if (ignoreCase) { - options += "i"; - } - return RegExpUtility.getSafeRegExp(pattern, options); - })); - } - - protected getRegexWithBrackets(regex: string): string { - let result = ""; - let openingBrackets = ['(\\()', '(\\[)', '(\\{)', '(\\<)']; - let closingBrackets = ['(\\))', '(\\])', '(\\})', '(\\>)']; - let i = 0; - while (i < 4) { - result += "|"; - result += openingBrackets[i]; - result += regex; - result += closingBrackets[i]; - i++; - } - return result; - } - - protected buildSeparateRegexFromSet(ignoreCase: boolean = true): RegExp { - - let separateWords = new Set(); - if (this.config.prefixList && this.config.prefixList.size) { - for (let addWord of this.config.prefixList.values()) { - addWord.split('|').filter(s => s && s.length) - .filter(this.validateUnit) - .forEach(word => separateWords.add(word)); - } - } - - if (this.config.suffixList && this.config.suffixList.size) { - for (let addWord of this.config.suffixList.values()) { - addWord.split('|').filter(s => s && s.length) - .filter(this.validateUnit) - .forEach(word => separateWords.add(word)); - } - } - - if (this.config.ambiguousUnitList && this.config.ambiguousUnitList.length) { - for (let abandonWord of this.config.ambiguousUnitList) { - if (separateWords.has(abandonWord)) { - separateWords.delete(abandonWord); - } - } - } - - let regexTokens = Array.from(separateWords.values()).map(escapeRegExp); - if (regexTokens.length === 0) { - return null; - } - - // Sort SeparateWords using descending length. - regexTokens = regexTokens.sort(this.stringComparer); - - let pattern = `${this.config.buildPrefix}(${regexTokens.join('|')})${this.config.buildSuffix}`; - let options = "gs"; - if (ignoreCase) { - options += "i"; - } - return RegExpUtility.getSafeRegExp(pattern, options); - } - - protected stringComparer(stringA: string, stringB: string): number { - if (!stringA && !stringB) { - return 0; - } - else { - if (!stringA) { - return 1; - } - if (!stringB) { - return -1; - } - return stringB.localeCompare(stringA); - } - } - - - private DimensionInsideTime(dimension: Match, time: Match): boolean { - let isSubMatch = false; - if (dimension.index >= time.index && dimension.index + dimension.length <= time.index + time.length) { - isSubMatch = true; - } - - return isSubMatch; - } -} - -export class BaseMergedUnitExtractor implements IExtractor { - private readonly config: INumberWithUnitExtractorConfiguration; - private readonly innerExtractor: NumberWithUnitExtractor; - - constructor(config: INumberWithUnitExtractorConfiguration) { - this.config = config; - this.innerExtractor = new NumberWithUnitExtractor(config); - } - - extract(source: string): ExtractResult[] { - let result = new Array(); - - if (this.config.extractType === Constants.SYS_UNIT_CURRENCY) { - result = this.mergeCompoundUnits(source); - } - else { - result = this.innerExtractor.extract(source); - } - - return result; - } - - private mergeCompoundUnits(source: string): ExtractResult[] { - let result = new Array(); - let ers = this.innerExtractor.extract(source); - this.MergePureNumber(source, ers); - - let groups: number[] = []; - groups[0] = 0; - for (let i = 0; i < ers.length - 1; i++) { - if (ers[i].type !== ers[i + 1].type && ers[i].type !== NumberConstants.SYS_NUM && ers[i + 1].type !== NumberConstants.SYS_NUM) { - continue; - } - - if (ers[i].data != null && (ers[i].data as ExtractResult).data != null && !ers[i].data.data.startsWith('Integer')) { - groups[i + 1] = groups[i] + 1; - continue; - } - - let middleBegin = ers[i].start + ers[i].length; - let middleEnd = ers[i + 1].start; - - let middleStr = source.substring(middleBegin, middleEnd).trim().toLowerCase(); - - // Separated by whitespace - if (StringUtility.isNullOrEmpty(middleStr)) { - groups[i + 1] = groups[i]; - continue; - } - - // Separated by connectors - let match = RegExpUtility.getMatches(this.config.compoundUnitConnectorRegex, middleStr).pop(); - if (match && match.index === 0 && match.length === middleStr.length) { - groups[i + 1] = groups[i]; - } - else { - groups[i + 1] = groups[i] + 1; - } - } - - for (let i = 0; i < ers.length; i++) { - if (i === 0 || groups[i] !== groups[i - 1]) { - let tmpInner = new ExtractResult(); - tmpInner.data = ers[i].data; - tmpInner.length = ers[i].length; - tmpInner.start = ers[i].start; - tmpInner.text = ers[i].text; - tmpInner.type = ers[i].type; - - let tmpExtractResult = ers[i]; - tmpExtractResult.data = new Array(); - tmpExtractResult.data.push(tmpInner); - - result.push(tmpExtractResult); - } - - // Reduce extract results in same group - if (i + 1 < ers.length && groups[i + 1] === groups[i]) { - let group = groups[i]; - - let periodBegin = result[group].start; - let periodEnd = ers[i + 1].start + ers[i + 1].length; - - result[group].length = periodEnd - periodBegin; - result[group].text = source.substring(periodBegin, periodEnd); - result[group].type = Constants.SYS_UNIT_CURRENCY; - result[group].data.push(ers[i + 1]); - } - } - - for (let i = 0; i < result.length; i++) { - let innerData: ExtractResult[] = result[i].data; - if (innerData && innerData.length === 1) { - result[i] = innerData[0]; - } - } - - result = result.filter(er => er.type !== NumberConstants.SYS_NUM); - - return result; - } - - private MergePureNumber(source: string, result: ExtractResult[]) { - let numErs = this.config.unitNumExtractor.extract(source); - let unitNumbers = new Array(); - let i: number; - let j: number; - for (i = 0, j = 0; i < numErs.length; i++) { - let hasBehindExtraction = false; - while (j < result.length && result[j].start + result[j].length < numErs[i].start) { - hasBehindExtraction = true; - j++; - } - - if (!hasBehindExtraction) { - continue; - } - - let middleBegin = result[j - 1].start + result[j - 1].length; - let middleEnd = numErs[i].start; - - let middleStr = source.substring(middleBegin, middleEnd).trim().toLowerCase(); - - // Separated by whitespace - if (StringUtility.isNullOrEmpty(middleStr)) { - unitNumbers.push(numErs[i]); - continue; - } - - // Separated by connectors - let match = RegExpUtility.getMatches(this.config.compoundUnitConnectorRegex, middleStr).pop(); - if (match && match.index === 0 && match.length === middleStr.length) { - unitNumbers.push(numErs[i]); - } - } - - unitNumbers.forEach(extractResult => { - let overlap = false; - result.forEach(er => { - if (er.start <= extractResult.start && er.start + er.length >= extractResult.start) { - overlap = true; - } - }); - - if (!overlap) { - result.push(extractResult); - } - }); - - result.sort((x, y) => x.start - y.start); - } -} - -export class PrefixUnitResult { - offset: number; - unitString: string; -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-number-with-unit/src/numberWithUnit/french/age.ts b/JavaScript/packages/recognizers-number-with-unit/src/numberWithUnit/french/age.ts deleted file mode 100644 index ab4bb5e8d8..0000000000 --- a/JavaScript/packages/recognizers-number-with-unit/src/numberWithUnit/french/age.ts +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { CultureInfo, Culture } from "@microsoft/recognizers-text-number"; -import { Constants } from "../constants"; -import { FrenchNumberWithUnitExtractorConfiguration, FrenchNumberWithUnitParserConfiguration } from "./base"; -import { FrenchNumericWithUnit } from "../../resources/frenchNumericWithUnit"; - -export class FrenchAgeExtractorConfiguration extends FrenchNumberWithUnitExtractorConfiguration { - readonly suffixList: ReadonlyMap; - readonly prefixList: ReadonlyMap; - readonly ambiguousUnitList: readonly string[]; - readonly extractType: string; - - constructor(ci?: CultureInfo) { - if (!ci) { - ci = new CultureInfo(Culture.French); - } - - super(ci); - - this.extractType = Constants.SYS_UNIT_AGE; - - this.suffixList = FrenchNumericWithUnit.AgeSuffixList; - this.prefixList = new Map(); - this.ambiguousUnitList = new Array(); - } -} - -export class FrenchAgeParserConfiguration extends FrenchNumberWithUnitParserConfiguration { - constructor(ci?: CultureInfo) { - if (!ci) { - ci = new CultureInfo(Culture.French); - } - - super(ci); - - this.BindDictionary(FrenchNumericWithUnit.AgeSuffixList); - } -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-number-with-unit/src/numberWithUnit/french/base.ts b/JavaScript/packages/recognizers-number-with-unit/src/numberWithUnit/french/base.ts deleted file mode 100644 index 5f5907cd30..0000000000 --- a/JavaScript/packages/recognizers-number-with-unit/src/numberWithUnit/french/base.ts +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { ExtractResult, IExtractor, IParser, RegExpUtility } from "@microsoft/recognizers-text"; -import { Culture, CultureInfo, NumberMode, AgnosticNumberParserFactory, AgnosticNumberParserType, FrenchNumberExtractor, FrenchNumberParserConfiguration } from "@microsoft/recognizers-text-number"; -import { Constants } from "../constants"; -import { INumberWithUnitExtractorConfiguration } from "../extractors"; -import { BaseNumberWithUnitParserConfiguration } from "../parsers"; -import { FrenchNumericWithUnit } from "../../resources/frenchNumericWithUnit"; -import { BaseUnits } from "../../resources/baseUnits"; - -export abstract class FrenchNumberWithUnitExtractorConfiguration implements INumberWithUnitExtractorConfiguration { - abstract readonly suffixList: ReadonlyMap; - abstract readonly prefixList: ReadonlyMap; - abstract readonly ambiguousUnitList: readonly string[]; - readonly abstract extractType: string; - - readonly cultureInfo: CultureInfo; - readonly unitNumExtractor: IExtractor; - readonly buildPrefix: string; - readonly buildSuffix: string; - readonly connectorToken: string; - readonly compoundUnitConnectorRegex: RegExp; - readonly nonUnitRegex: RegExp; - readonly ambiguousUnitNumberMultiplierRegex: RegExp; - - constructor(ci: CultureInfo) { - this.cultureInfo = ci; - this.unitNumExtractor = new FrenchNumberExtractor(NumberMode.Unit); - - this.buildPrefix = FrenchNumericWithUnit.BuildPrefix; - this.buildSuffix = FrenchNumericWithUnit.BuildSuffix; - this.connectorToken = FrenchNumericWithUnit.ConnectorToken; - this.compoundUnitConnectorRegex = RegExpUtility.getSafeRegExp(FrenchNumericWithUnit.CompoundUnitConnectorRegex); - this.nonUnitRegex = RegExpUtility.getSafeRegExp(BaseUnits.PmNonUnitRegex); - } - - expandHalfSuffix(source: string, result: ExtractResult[], numbers: ExtractResult[]) { - } -} - -export class FrenchNumberWithUnitParserConfiguration extends BaseNumberWithUnitParserConfiguration { - readonly internalNumberParser: IParser; - readonly internalNumberExtractor: IExtractor; - readonly connectorToken: string; - readonly currencyNameToIsoCodeMap: ReadonlyMap; - readonly currencyFractionCodeList: ReadonlyMap; - - constructor(ci: CultureInfo) { - super(ci); - - this.internalNumberExtractor = new FrenchNumberExtractor(NumberMode.Default); - this.internalNumberParser = AgnosticNumberParserFactory.getParser(AgnosticNumberParserType.Number, new FrenchNumberParserConfiguration()); - this.connectorToken = FrenchNumericWithUnit.ConnectorToken; - } -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-number-with-unit/src/numberWithUnit/french/currency.ts b/JavaScript/packages/recognizers-number-with-unit/src/numberWithUnit/french/currency.ts deleted file mode 100644 index 9b9ce6427e..0000000000 --- a/JavaScript/packages/recognizers-number-with-unit/src/numberWithUnit/french/currency.ts +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { CultureInfo, Culture } from "@microsoft/recognizers-text-number"; -import { Constants } from "../constants"; -import { FrenchNumberWithUnitExtractorConfiguration, FrenchNumberWithUnitParserConfiguration } from "./base"; -import { FrenchNumericWithUnit } from "../../resources/frenchNumericWithUnit"; - -export class FrenchCurrencyExtractorConfiguration extends FrenchNumberWithUnitExtractorConfiguration { - readonly suffixList: ReadonlyMap; - readonly prefixList: ReadonlyMap; - readonly ambiguousUnitList: readonly string[]; - readonly extractType: string; - - constructor(ci?: CultureInfo) { - if (!ci) { - ci = new CultureInfo(Culture.French); - } - - super(ci); - - this.extractType = Constants.SYS_UNIT_CURRENCY; - - // Reference Source: https:// en.wikipedia.org/wiki/List_of_circulating_currencies - this.suffixList = FrenchNumericWithUnit.CurrencySuffixList; - this.prefixList = FrenchNumericWithUnit.CurrencyPrefixList; - this.ambiguousUnitList = FrenchNumericWithUnit.AmbiguousCurrencyUnitList; - } -} - -export class FrenchCurrencyParserConfiguration extends FrenchNumberWithUnitParserConfiguration { - constructor(ci?: CultureInfo) { - if (!ci) { - ci = new CultureInfo(Culture.French); - } - - super(ci); - - this.BindDictionary(FrenchNumericWithUnit.CurrencySuffixList); - this.BindDictionary(FrenchNumericWithUnit.CurrencyPrefixList); - } -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-number-with-unit/src/numberWithUnit/french/dimension.ts b/JavaScript/packages/recognizers-number-with-unit/src/numberWithUnit/french/dimension.ts deleted file mode 100644 index 467de2c3f1..0000000000 --- a/JavaScript/packages/recognizers-number-with-unit/src/numberWithUnit/french/dimension.ts +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { CultureInfo, Culture } from "@microsoft/recognizers-text-number"; -import { Constants } from "../constants"; -import { FrenchNumberWithUnitExtractorConfiguration, FrenchNumberWithUnitParserConfiguration } from "./base"; -import { FrenchNumericWithUnit } from "../../resources/frenchNumericWithUnit"; - -const dimensionSuffixList = new Map([ - ...FrenchNumericWithUnit.InformationSuffixList, - ...FrenchNumericWithUnit.AreaSuffixList, - ...FrenchNumericWithUnit.LengthSuffixList, - ...FrenchNumericWithUnit.SpeedSuffixList, - ...FrenchNumericWithUnit.VolumeSuffixList, - ...FrenchNumericWithUnit.WeightSuffixList -]); - -export class FrenchDimensionExtractorConfiguration extends FrenchNumberWithUnitExtractorConfiguration { - - readonly suffixList: ReadonlyMap; - readonly prefixList: ReadonlyMap; - readonly ambiguousUnitList: readonly string[]; - readonly extractType: string; - - constructor(ci?: CultureInfo) { - if (!ci) { - ci = new CultureInfo(Culture.French); - } - - super(ci); - - this.extractType = Constants.SYS_UNIT_DIMENSION; - - this.suffixList = dimensionSuffixList; - this.prefixList = new Map(); - this.ambiguousUnitList = FrenchNumericWithUnit.AmbiguousDimensionUnitList.concat( - FrenchNumericWithUnit.AmbiguousAngleUnitList.concat( - FrenchNumericWithUnit.AmbiguousLengthUnitList.concat( - FrenchNumericWithUnit.AmbiguousSpeedUnitList.concat( - FrenchNumericWithUnit.AmbiguousWeightUnitList)))); - } -} - -export class FrenchDimensionParserConfiguration extends FrenchNumberWithUnitParserConfiguration { - constructor(ci?: CultureInfo) { - if (!ci) { - ci = new CultureInfo(Culture.French); - } - - super(ci); - - this.BindDictionary(dimensionSuffixList); - } -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-number-with-unit/src/numberWithUnit/french/temperature.ts b/JavaScript/packages/recognizers-number-with-unit/src/numberWithUnit/french/temperature.ts deleted file mode 100644 index a63d254f91..0000000000 --- a/JavaScript/packages/recognizers-number-with-unit/src/numberWithUnit/french/temperature.ts +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { CultureInfo, Culture, RegExpUtility } from "@microsoft/recognizers-text-number"; -import { Constants } from "../constants"; -import { FrenchNumberWithUnitExtractorConfiguration, FrenchNumberWithUnitParserConfiguration } from "./base"; -import { FrenchNumericWithUnit } from "../../resources/frenchNumericWithUnit"; -import { BaseUnits } from "../../resources/baseUnits"; - -export class FrenchTemperatureExtractorConfiguration extends FrenchNumberWithUnitExtractorConfiguration { - readonly suffixList: ReadonlyMap; - readonly prefixList: ReadonlyMap; - readonly ambiguousUnitList: readonly string[]; - readonly extractType: string; - readonly ambiguousUnitNumberMultiplierRegex: RegExp; - - constructor(ci?: CultureInfo) { - if (!ci) { - ci = new CultureInfo(Culture.French); - } - - super(ci); - - this.extractType = Constants.SYS_UNIT_TEMPERATURE; - - this.suffixList = FrenchNumericWithUnit.TemperatureSuffixList; - this.prefixList = new Map(); - this.ambiguousUnitList = new Array(); - - this.ambiguousUnitNumberMultiplierRegex = RegExpUtility.getSafeRegExp(BaseUnits.AmbiguousUnitNumberMultiplierRegex, "gs"); - } -} - -export class FrenchTemperatureParserConfiguration extends FrenchNumberWithUnitParserConfiguration { - constructor(ci?: CultureInfo) { - if (!ci) { - ci = new CultureInfo(Culture.French); - } - - super(ci); - - this.connectorToken = null; - this.BindDictionary(FrenchNumericWithUnit.TemperatureSuffixList); - } - - readonly connectorToken: string; -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-number-with-unit/src/numberWithUnit/japanese/age.ts b/JavaScript/packages/recognizers-number-with-unit/src/numberWithUnit/japanese/age.ts deleted file mode 100644 index 2ce53654fe..0000000000 --- a/JavaScript/packages/recognizers-number-with-unit/src/numberWithUnit/japanese/age.ts +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { CultureInfo, Culture } from "@microsoft/recognizers-text-number"; -import { Constants } from "../constants"; -import { JapaneseNumberWithUnitExtractorConfiguration, JapaneseNumberWithUnitParserConfiguration } from "./base"; -import { JapaneseNumericWithUnit } from "../../resources/japaneseNumericWithUnit"; - -export class JapaneseAgeExtractorConfiguration extends JapaneseNumberWithUnitExtractorConfiguration { - readonly suffixList: ReadonlyMap; - readonly prefixList: ReadonlyMap; - readonly ambiguousUnitList: readonly string[]; - readonly extractType: string; - - constructor(ci?: CultureInfo) { - if (!ci) { - ci = new CultureInfo(Culture.Japanese); - } - - super(ci); - - this.extractType = Constants.SYS_UNIT_AGE; - - this.suffixList = JapaneseNumericWithUnit.AgeSuffixList; - this.prefixList = new Map(); - this.ambiguousUnitList = JapaneseNumericWithUnit.AgeAmbiguousValues; - } -} - -export class JapaneseAgeParserConfiguration extends JapaneseNumberWithUnitParserConfiguration { - constructor(ci?: CultureInfo) { - if (!ci) { - ci = new CultureInfo(Culture.Japanese); - } - - super(ci); - - this.BindDictionary(JapaneseNumericWithUnit.AgeSuffixList); - } -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-number-with-unit/src/numberWithUnit/japanese/base.ts b/JavaScript/packages/recognizers-number-with-unit/src/numberWithUnit/japanese/base.ts deleted file mode 100644 index 14c5286174..0000000000 --- a/JavaScript/packages/recognizers-number-with-unit/src/numberWithUnit/japanese/base.ts +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { ExtractResult, IExtractor, IParser, RegExpUtility } from "@microsoft/recognizers-text"; -import { Culture, CultureInfo, NumberMode, AgnosticNumberParserFactory, AgnosticNumberParserType, JapaneseNumberExtractor, JapaneseNumberParserConfiguration, JapaneseNumberExtractorMode } from "@microsoft/recognizers-text-number"; -import { Constants } from "../constants"; -import { INumberWithUnitExtractorConfiguration } from "../extractors"; -import { BaseNumberWithUnitParserConfiguration } from "../parsers"; -import { JapaneseNumericWithUnit } from "../../resources/japaneseNumericWithUnit"; -import { BaseUnits } from "../../resources/baseUnits"; - -export abstract class JapaneseNumberWithUnitExtractorConfiguration implements INumberWithUnitExtractorConfiguration { - abstract readonly suffixList: ReadonlyMap; - abstract readonly prefixList: ReadonlyMap; - abstract readonly ambiguousUnitList: readonly string[]; - readonly abstract extractType: string; - - readonly cultureInfo: CultureInfo; - readonly unitNumExtractor: IExtractor; - readonly buildPrefix: string; - readonly buildSuffix: string; - readonly connectorToken: string; - readonly compoundUnitConnectorRegex: RegExp; - readonly nonUnitRegex: RegExp; - readonly ambiguousUnitNumberMultiplierRegex: RegExp; - - constructor(ci: CultureInfo) { - this.cultureInfo = ci; - this.unitNumExtractor = new JapaneseNumberExtractor(JapaneseNumberExtractorMode.ExtractAll); - - this.buildPrefix = JapaneseNumericWithUnit.BuildPrefix; - this.buildSuffix = JapaneseNumericWithUnit.BuildSuffix; - this.connectorToken = JapaneseNumericWithUnit.ConnectorToken; - this.compoundUnitConnectorRegex = RegExpUtility.getSafeRegExp(JapaneseNumericWithUnit.CompoundUnitConnectorRegex); - this.nonUnitRegex = RegExpUtility.getSafeRegExp(BaseUnits.PmNonUnitRegex); - } - - expandHalfSuffix(source: string, result: ExtractResult[], numbers: ExtractResult[]) { - } -} - -export class JapaneseNumberWithUnitParserConfiguration extends BaseNumberWithUnitParserConfiguration { - readonly internalNumberParser: IParser; - readonly internalNumberExtractor: IExtractor; - readonly connectorToken: string; - readonly currencyNameToIsoCodeMap: ReadonlyMap; - readonly currencyFractionCodeList: ReadonlyMap; - - constructor(ci: CultureInfo) { - super(ci); - - this.internalNumberExtractor = new JapaneseNumberExtractor(JapaneseNumberExtractorMode.Default); - this.internalNumberParser = AgnosticNumberParserFactory.getParser(AgnosticNumberParserType.Number, new JapaneseNumberParserConfiguration()); - this.connectorToken = ''; - this.currencyNameToIsoCodeMap = JapaneseNumericWithUnit.CurrencyNameToIsoCodeMap; - this.currencyFractionCodeList = JapaneseNumericWithUnit.FractionalUnitNameToCodeMap; - } -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-number-with-unit/src/numberWithUnit/japanese/currency.ts b/JavaScript/packages/recognizers-number-with-unit/src/numberWithUnit/japanese/currency.ts deleted file mode 100644 index e9789bc17a..0000000000 --- a/JavaScript/packages/recognizers-number-with-unit/src/numberWithUnit/japanese/currency.ts +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { CultureInfo, Culture } from "@microsoft/recognizers-text-number"; -import { Constants } from "../constants"; -import { JapaneseNumberWithUnitExtractorConfiguration, JapaneseNumberWithUnitParserConfiguration } from "./base"; -import { JapaneseNumericWithUnit } from "../../resources/japaneseNumericWithUnit"; - -export class JapaneseCurrencyExtractorConfiguration extends JapaneseNumberWithUnitExtractorConfiguration { - readonly suffixList: ReadonlyMap; - readonly prefixList: ReadonlyMap; - readonly ambiguousUnitList: readonly string[]; - readonly extractType: string; - - constructor(ci?: CultureInfo) { - if (!ci) { - ci = new CultureInfo(Culture.Japanese); - } - - super(ci); - - this.extractType = Constants.SYS_UNIT_CURRENCY; - - // Reference Source: https:// en.wikipedia.org/wiki/List_of_circulating_currencies - this.suffixList = JapaneseNumericWithUnit.CurrencySuffixList; - this.prefixList = JapaneseNumericWithUnit.CurrencyPrefixList; - this.ambiguousUnitList = JapaneseNumericWithUnit.CurrencyAmbiguousValues;; - } -} - -export class JapaneseCurrencyParserConfiguration extends JapaneseNumberWithUnitParserConfiguration { - constructor(ci?: CultureInfo) { - if (!ci) { - ci = new CultureInfo(Culture.Japanese); - } - - super(ci); - - this.BindDictionary(JapaneseNumericWithUnit.CurrencySuffixList); - this.BindDictionary(JapaneseNumericWithUnit.CurrencyPrefixList); - } -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-number-with-unit/src/numberWithUnit/models.ts b/JavaScript/packages/recognizers-number-with-unit/src/numberWithUnit/models.ts deleted file mode 100644 index b5a205107b..0000000000 --- a/JavaScript/packages/recognizers-number-with-unit/src/numberWithUnit/models.ts +++ /dev/null @@ -1,111 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { IModel, ModelResult, ParseResult, IExtractor, IParser, QueryProcessor } from "@microsoft/recognizers-text"; -import { UnitValue, UnitValueIso } from "./parsers"; - -export enum CompositeEntityType { - Age, - Currency, - Dimension, - Temperature -} - -export abstract class AbstractNumberWithUnitModel implements IModel { - protected extractorParsersMap: Map; - - abstract modelTypeName: string; - - constructor(extractorParsersMap: Map) { - this.extractorParsersMap = extractorParsersMap; - } - - parse(query: string): ModelResult[] { - query = QueryProcessor.preProcess(query, true); - - let extractionResults = new Array(); - - try { - for (let kv of this.extractorParsersMap.entries()) { - let extractor = kv[0]; - let parser = kv[1]; - let extractResults = extractor.extract(query); - let parseResults: ParseResult[] = []; - for (let i = 0; i < extractResults.length; i++) { - let r = parser.parse(extractResults[i]); - if (r.value !== null) { - if (r.value instanceof Array) { - for (let j = 0; j < r.value.length; j++) { - parseResults.push(r.value[j]); - } - } - else { - parseResults.push(r); - } - } - } - let modelResults = parseResults.map(o => - ({ - start: o.start, - end: o.start + o.length - 1, - resolution: this.getResolution(o.value), - text: o.text, - typeName: this.modelTypeName - } as ModelResult)); - - modelResults.forEach(result => { - let bAdd = true; - - extractionResults.forEach(extractionResult => { - if (extractionResult.start === result.start && extractionResult.end === result.end) { - bAdd = false; - } - }); - - if (bAdd) { - extractionResults.push(result); - } - }); - } - } - catch (err) { - // Nothing to do. Exceptions in result process should not affect other extracted entities. - // No result. - } - finally { - return extractionResults; - } - } - - private getResolution(data: any): any { - if (typeof data === 'undefined') { - return null; - } - - let result = typeof data === "string" - ? { value: data.toString() } - : { value: (data as UnitValue).number, unit: (data as UnitValue).unit }; - - if ((data as UnitValueIso).isoCurrency) { - result['isoCurrency'] = data.isoCurrency; - } - - return result; - } -} - -export class AgeModel extends AbstractNumberWithUnitModel { - modelTypeName: string = "age" -} - -export class CurrencyModel extends AbstractNumberWithUnitModel { - modelTypeName: string = "currency"; -} - -export class DimensionModel extends AbstractNumberWithUnitModel { - modelTypeName: string = "dimension"; -} - -export class TemperatureModel extends AbstractNumberWithUnitModel { - modelTypeName: string = "temperature" -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-number-with-unit/src/numberWithUnit/numberWithUnitRecognizer.ts b/JavaScript/packages/recognizers-number-with-unit/src/numberWithUnit/numberWithUnitRecognizer.ts deleted file mode 100644 index a6ab7076d5..0000000000 --- a/JavaScript/packages/recognizers-number-with-unit/src/numberWithUnit/numberWithUnitRecognizer.ts +++ /dev/null @@ -1,174 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { IModel, ModelResult, Recognizer, IExtractor, IParser } from "@microsoft/recognizers-text"; -import { Culture } from "@microsoft/recognizers-text-number"; -import { CurrencyModel, TemperatureModel, DimensionModel, AgeModel } from "./models"; -import { NumberWithUnitExtractor, BaseMergedUnitExtractor } from "./extractors"; -import { NumberWithUnitParser, BaseMergedUnitParser } from "./parsers"; -import { EnglishCurrencyExtractorConfiguration, EnglishCurrencyParserConfiguration } from "./english/currency"; -import { EnglishTemperatureExtractorConfiguration, EnglishTemperatureParserConfiguration } from "./english/temperature"; -import { EnglishDimensionExtractorConfiguration, EnglishDimensionParserConfiguration } from "./english/dimension"; -import { EnglishAgeExtractorConfiguration, EnglishAgeParserConfiguration } from "./english/age"; -import { SpanishCurrencyExtractorConfiguration, SpanishCurrencyParserConfiguration } from "./spanish/currency"; -import { SpanishTemperatureExtractorConfiguration, SpanishTemperatureParserConfiguration } from "./spanish/temperature"; -import { SpanishDimensionExtractorConfiguration, SpanishDimensionParserConfiguration } from "./spanish/dimension"; -import { SpanishAgeExtractorConfiguration, SpanishAgeParserConfiguration } from "./spanish/age"; -import { PortugueseCurrencyExtractorConfiguration, PortugueseCurrencyParserConfiguration } from "./portuguese/currency"; -import { PortugueseTemperatureExtractorConfiguration, PortugueseTemperatureParserConfiguration } from "./portuguese/temperature"; -import { PortugueseDimensionExtractorConfiguration, PortugueseDimensionParserConfiguration } from "./portuguese/dimension"; -import { PortugueseAgeExtractorConfiguration, PortugueseAgeParserConfiguration } from "./portuguese/age"; -import { ChineseCurrencyExtractorConfiguration, ChineseCurrencyParserConfiguration } from "./chinese/currency"; -import { ChineseTemperatureExtractorConfiguration, ChineseTemperatureParserConfiguration } from "./chinese/temperature"; -import { ChineseDimensionExtractorConfiguration, ChineseDimensionParserConfiguration } from "./chinese/dimension"; -import { ChineseAgeExtractorConfiguration, ChineseAgeParserConfiguration } from "./chinese/age"; -import { JapaneseCurrencyExtractorConfiguration, JapaneseCurrencyParserConfiguration } from "./japanese/currency"; -import { JapaneseAgeExtractorConfiguration, JapaneseAgeParserConfiguration } from "./japanese/age"; -import { FrenchCurrencyExtractorConfiguration, FrenchCurrencyParserConfiguration } from "./french/currency"; -import { FrenchTemperatureExtractorConfiguration, FrenchTemperatureParserConfiguration } from "./french/temperature"; -import { FrenchDimensionExtractorConfiguration, FrenchDimensionParserConfiguration } from "./french/dimension"; -import { FrenchAgeExtractorConfiguration, FrenchAgeParserConfiguration } from "./french/age"; - -export enum NumberWithUnitOptions { - None = 0, -} - -export function recognizeCurrency(query: string, culture: string, options: NumberWithUnitOptions = NumberWithUnitOptions.None, fallbackToDefaultCulture: boolean = true): ModelResult[] { - return recognizeByModel(recognizer => recognizer.getCurrencyModel(culture, fallbackToDefaultCulture), query, culture, options); -} - -export function recognizeTemperature(query: string, culture: string, options: NumberWithUnitOptions = NumberWithUnitOptions.None, fallbackToDefaultCulture: boolean = true): ModelResult[] { - return recognizeByModel(recognizer => recognizer.getTemperatureModel(culture, fallbackToDefaultCulture), query, culture, options); -} - -export function recognizeDimension(query: string, culture: string, options: NumberWithUnitOptions = NumberWithUnitOptions.None, fallbackToDefaultCulture: boolean = true): ModelResult[] { - return recognizeByModel(recognizer => recognizer.getDimensionModel(culture, fallbackToDefaultCulture), query, culture, options); -} - -export function recognizeAge(query: string, culture: string, options: NumberWithUnitOptions = NumberWithUnitOptions.None, fallbackToDefaultCulture: boolean = true): ModelResult[] { - return recognizeByModel(recognizer => recognizer.getAgeModel(culture, fallbackToDefaultCulture), query, culture, options); -} - -function recognizeByModel(getModelFunc: (n: NumberWithUnitRecognizer) => IModel, query: string, culture: string, options: NumberWithUnitOptions): ModelResult[] { - let recognizer = new NumberWithUnitRecognizer(culture, options); - let model = getModelFunc(recognizer); - return model.parse(query); -} - -export default class NumberWithUnitRecognizer extends Recognizer { - constructor(culture: string, options: NumberWithUnitOptions = NumberWithUnitOptions.None, lazyInitialization: boolean = false) { - super(culture, options, lazyInitialization); - } - - protected InitializeConfiguration() { - // #region English - this.registerModel("CurrencyModel", Culture.English, (options) => new CurrencyModel(new Map([ - [new BaseMergedUnitExtractor(new EnglishCurrencyExtractorConfiguration()), new BaseMergedUnitParser(new EnglishCurrencyParserConfiguration())] - ]))); - this.registerModel("TemperatureModel", Culture.English, (options) => new TemperatureModel(new Map([ - [new NumberWithUnitExtractor(new EnglishTemperatureExtractorConfiguration()), new NumberWithUnitParser(new EnglishTemperatureParserConfiguration())] - ]))); - this.registerModel("DimensionModel", Culture.English, (options) => new DimensionModel(new Map([ - [new NumberWithUnitExtractor(new EnglishDimensionExtractorConfiguration()), new NumberWithUnitParser(new EnglishDimensionParserConfiguration())] - ]))); - this.registerModel("AgeModel", Culture.English, (options) => new AgeModel(new Map([ - [new NumberWithUnitExtractor(new EnglishAgeExtractorConfiguration()), new NumberWithUnitParser(new EnglishAgeParserConfiguration())] - ]))); - // #endregion - - // #region Spanish - this.registerModel("CurrencyModel", Culture.Spanish, (options) => new CurrencyModel(new Map([ - [new NumberWithUnitExtractor(new SpanishCurrencyExtractorConfiguration()), new NumberWithUnitParser(new SpanishCurrencyParserConfiguration())] - ]))); - this.registerModel("TemperatureModel", Culture.Spanish, (options) => new TemperatureModel(new Map([ - [new NumberWithUnitExtractor(new SpanishTemperatureExtractorConfiguration()), new NumberWithUnitParser(new SpanishTemperatureParserConfiguration())] - ]))); - this.registerModel("DimensionModel", Culture.Spanish, (options) => new DimensionModel(new Map([ - [new NumberWithUnitExtractor(new SpanishDimensionExtractorConfiguration()), new NumberWithUnitParser(new SpanishDimensionParserConfiguration())] - ]))); - this.registerModel("AgeModel", Culture.Spanish, (options) => new AgeModel(new Map([ - [new NumberWithUnitExtractor(new SpanishAgeExtractorConfiguration()), new NumberWithUnitParser(new SpanishAgeParserConfiguration())] - ]))); - // #endregion - - // #region Portuguese - this.registerModel("CurrencyModel", Culture.Portuguese, (options) => new CurrencyModel(new Map([ - [new NumberWithUnitExtractor(new PortugueseCurrencyExtractorConfiguration()), new NumberWithUnitParser(new PortugueseCurrencyParserConfiguration())] - ]))); - this.registerModel("TemperatureModel", Culture.Portuguese, (options) => new TemperatureModel(new Map([ - [new NumberWithUnitExtractor(new PortugueseTemperatureExtractorConfiguration()), new NumberWithUnitParser(new PortugueseTemperatureParserConfiguration())] - ]))); - this.registerModel("DimensionModel", Culture.Portuguese, (options) => new DimensionModel(new Map([ - [new NumberWithUnitExtractor(new PortugueseDimensionExtractorConfiguration()), new NumberWithUnitParser(new PortugueseDimensionParserConfiguration())] - ]))); - this.registerModel("AgeModel", Culture.Portuguese, (options) => new AgeModel(new Map([ - [new NumberWithUnitExtractor(new PortugueseAgeExtractorConfiguration()), new NumberWithUnitParser(new PortugueseAgeParserConfiguration())] - ]))); - // #endregion - - // #region Chinese - this.registerModel("CurrencyModel", Culture.Chinese, (options) => new CurrencyModel(new Map([ - [new BaseMergedUnitExtractor(new ChineseCurrencyExtractorConfiguration()), new BaseMergedUnitParser(new ChineseCurrencyParserConfiguration())], - [new NumberWithUnitExtractor(new EnglishCurrencyExtractorConfiguration()), new NumberWithUnitParser(new EnglishCurrencyParserConfiguration())] - ]))); - this.registerModel("TemperatureModel", Culture.Chinese, (options) => new TemperatureModel(new Map([ - [new NumberWithUnitExtractor(new ChineseTemperatureExtractorConfiguration()), new NumberWithUnitParser(new ChineseTemperatureParserConfiguration())], - [new NumberWithUnitExtractor(new EnglishTemperatureExtractorConfiguration()), new NumberWithUnitParser(new EnglishTemperatureParserConfiguration())] - ]))); - this.registerModel("DimensionModel", Culture.Chinese, (options) => new DimensionModel(new Map([ - [new NumberWithUnitExtractor(new ChineseDimensionExtractorConfiguration()), new NumberWithUnitParser(new ChineseDimensionParserConfiguration())], - [new NumberWithUnitExtractor(new EnglishDimensionExtractorConfiguration()), new NumberWithUnitParser(new EnglishDimensionParserConfiguration())] - ]))); - this.registerModel("AgeModel", Culture.Chinese, (options) => new AgeModel(new Map([ - [new NumberWithUnitExtractor(new ChineseAgeExtractorConfiguration()), new NumberWithUnitParser(new ChineseAgeParserConfiguration())], - [new NumberWithUnitExtractor(new EnglishAgeExtractorConfiguration()), new NumberWithUnitParser(new EnglishAgeParserConfiguration())] - ]))); - // #endregion - - // #region Japanese - this.registerModel("CurrencyModel", Culture.Japanese, (options) => new CurrencyModel(new Map([ - [new BaseMergedUnitExtractor(new JapaneseCurrencyExtractorConfiguration()), new BaseMergedUnitParser(new JapaneseCurrencyParserConfiguration())], - [new NumberWithUnitExtractor(new EnglishCurrencyExtractorConfiguration()), new NumberWithUnitParser(new EnglishCurrencyParserConfiguration())] - ]))); - this.registerModel("AgeModel", Culture.Japanese, (options) => new AgeModel(new Map([ - [new NumberWithUnitExtractor(new JapaneseAgeExtractorConfiguration()), new NumberWithUnitParser(new JapaneseAgeParserConfiguration())], - [new NumberWithUnitExtractor(new EnglishAgeExtractorConfiguration()), new NumberWithUnitParser(new EnglishAgeParserConfiguration())] - ]))); - // #endregion - - // #region French - this.registerModel("CurrencyModel", Culture.French, (options) => new CurrencyModel(new Map([ - [new NumberWithUnitExtractor(new FrenchCurrencyExtractorConfiguration()), new NumberWithUnitParser(new FrenchCurrencyParserConfiguration())] - ]))); - this.registerModel("TemperatureModel", Culture.French, (options) => new TemperatureModel(new Map([ - [new NumberWithUnitExtractor(new FrenchTemperatureExtractorConfiguration()), new NumberWithUnitParser(new FrenchTemperatureParserConfiguration())] - ]))); - this.registerModel("DimensionModel", Culture.French, (options) => new DimensionModel(new Map([ - [new NumberWithUnitExtractor(new FrenchDimensionExtractorConfiguration()), new NumberWithUnitParser(new FrenchDimensionParserConfiguration())] - ]))); - this.registerModel("AgeModel", Culture.French, (options) => new AgeModel(new Map([ - [new NumberWithUnitExtractor(new FrenchAgeExtractorConfiguration()), new NumberWithUnitParser(new FrenchAgeParserConfiguration())] - ]))); - // #endregion - } - - protected IsValidOptions(options: number): boolean { - return options >= 0 && options <= NumberWithUnitOptions.None; - } - - getCurrencyModel(culture: string = null, fallbackToDefaultCulture: boolean = true): IModel { - return this.getModel("CurrencyModel", culture, fallbackToDefaultCulture); - } - - getTemperatureModel(culture: string = null, fallbackToDefaultCulture: boolean = true): IModel { - return this.getModel("TemperatureModel", culture, fallbackToDefaultCulture); - } - - getDimensionModel(culture: string = null, fallbackToDefaultCulture: boolean = true): IModel { - return this.getModel("DimensionModel", culture, fallbackToDefaultCulture); - } - - getAgeModel(culture: string = null, fallbackToDefaultCulture: boolean = true): IModel { - return this.getModel("AgeModel", culture, fallbackToDefaultCulture); - } -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-number-with-unit/src/numberWithUnit/parsers.ts b/JavaScript/packages/recognizers-number-with-unit/src/numberWithUnit/parsers.ts deleted file mode 100644 index 4394f75728..0000000000 --- a/JavaScript/packages/recognizers-number-with-unit/src/numberWithUnit/parsers.ts +++ /dev/null @@ -1,385 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { IExtractor, ExtractResult, IParser, ParseResult, StringUtility } from "@microsoft/recognizers-text"; -import { CultureInfo, Constants as NumberConstants } from "@microsoft/recognizers-text-number"; -import last = require("lodash.last"); -import { Constants } from "./constants"; -import { DictionaryUtils } from "./utilities"; -import { BaseCurrency } from "../resources/baseCurrency"; - -export class UnitValue { - public number: string = ""; - public unit: string = ""; -} - -export class UnitValueIso extends UnitValue { - public isoCurrency: string = ""; -} - -export interface INumberWithUnitParserConfiguration { - readonly unitMap: Map; - readonly cultureInfo: CultureInfo; - readonly internalNumberParser: IParser; - readonly internalNumberExtractor: IExtractor; - readonly connectorToken: string; - readonly currencyNameToIsoCodeMap: ReadonlyMap; - readonly currencyFractionCodeList: ReadonlyMap; - readonly currencyFractionNumMap: ReadonlyMap; - readonly currencyFractionMapping: ReadonlyMap; - BindDictionary(dictionary: Map): void; -} - -export abstract class BaseNumberWithUnitParserConfiguration implements INumberWithUnitParserConfiguration { - unitMap: Map; - cultureInfo: CultureInfo; - abstract internalNumberParser: IParser; - abstract internalNumberExtractor: IExtractor; - abstract connectorToken: string; - abstract currencyNameToIsoCodeMap: ReadonlyMap; - abstract currencyFractionCodeList: ReadonlyMap; - readonly currencyFractionNumMap: ReadonlyMap; - readonly currencyFractionMapping: ReadonlyMap; - - constructor(cultureInfo: CultureInfo) { - this.cultureInfo = cultureInfo; - this.unitMap = new Map(); - this.currencyFractionNumMap = BaseCurrency.CurrencyFractionalRatios; - this.currencyFractionMapping = BaseCurrency.CurrencyFractionMapping; - } - - BindDictionary(dictionary: ReadonlyMap): void { - DictionaryUtils.bindDictionary(dictionary, this.unitMap); - } -} - -export class NumberWithUnitParser implements IParser { - protected readonly config: INumberWithUnitParserConfiguration; - - constructor(config: INumberWithUnitParserConfiguration) { - this.config = config; - } - - parse(extResult: ExtractResult): ParseResult { - let ret = new ParseResult(extResult); - let numberResult: ExtractResult; - let halfResult: ExtractResult; - if (extResult.data && extResult.data instanceof Array && extResult.data.length === 2) { - numberResult = extResult.data[0]; - halfResult = extResult.data[1]; - } - else if (extResult.data && typeof extResult.data === "object") { - numberResult = extResult.data as ExtractResult; - halfResult = null; - } - else if (extResult.type === Constants.SYS_NUM) { - ret.value = this.config.internalNumberParser.parse(extResult).value; - return ret; - } - else { - // if there is no unitResult, means there is just unit - numberResult = { start: -1, length: 0, text: null, type: null }; - halfResult = null; - } - - // key contains units - let key = extResult.text; - let unitKeyBuild = ''; - let unitKeys = new Array(); - for (let i = 0; i <= key.length; i++) { - if (i === key.length) { - if (unitKeyBuild.length !== 0) { - this.addIfNotContained(unitKeys, unitKeyBuild.trim()); - } - } - - // numberResult.start is a relative position - else if (i === numberResult.start) { - if (unitKeyBuild.length !== 0) { - this.addIfNotContained(unitKeys, unitKeyBuild.trim()); - unitKeyBuild = ''; - } - - let o = numberResult.start + numberResult.length - 1; - if (o !== null && !isNaN(o)) { - i = o; - } - } - else { - unitKeyBuild += key[i]; - } - } - - /* Unit type depends on last unit in suffix.*/ - let lastUnit = last(unitKeys); - if (halfResult != null) { - lastUnit = lastUnit.substring(0, lastUnit.length - halfResult.text.length); - } - let normalizedLastUnit = lastUnit.toLowerCase(); - if (this.config.connectorToken && this.config.connectorToken.length && normalizedLastUnit.indexOf(this.config.connectorToken) === 0) { - normalizedLastUnit = normalizedLastUnit.substring(this.config.connectorToken.length).trim(); - lastUnit = lastUnit.substring(this.config.connectorToken.length).trim(); - } - - lastUnit = this.deleteBracketsIfExisted(lastUnit); - normalizedLastUnit = this.deleteBracketsIfExisted(normalizedLastUnit); - - if (key && key.length && (this.config.unitMap !== null)) { - let unitValue = null; - if (this.config.unitMap.has(lastUnit)) { - unitValue = this.config.unitMap.get(lastUnit); - } - else if (this.config.unitMap.has(normalizedLastUnit)) { - unitValue = this.config.unitMap.get(normalizedLastUnit); - } - - if (unitValue) { - let numValue = numberResult.text && numberResult.text.length ? this.config.internalNumberParser.parse(numberResult) : null; - let resolutionStr = numValue ? numValue.resolutionStr : null; - if (halfResult != null) { - let halfValue = this.config.internalNumberParser.parse(halfResult); - resolutionStr += halfValue.resolutionStr.substring(1); - } - ret.value = { number: resolutionStr, unit: unitValue } as UnitValue; - ret.resolutionStr = (`${resolutionStr} ${unitValue}`).trim(); - } - } - - ret.text = ret.text.toLowerCase(); - - return ret; - } - - private addIfNotContained(keys: string[], newKey: string): void { - if (!keys.some(key => key.includes(newKey))) { - keys.push(newKey); - } - } - - private deleteBracketsIfExisted(unit: string) { - let hasBrackets = false; - - if (unit.startsWith('(') && unit.endsWith(')')) { - hasBrackets = true; - } - - if (unit.startsWith('[') && unit.endsWith(']')) { - hasBrackets = true; - } - - if (unit.startsWith('{') && unit.endsWith('}')) { - hasBrackets = true; - } - - if (unit.startsWith('<') && unit.endsWith('>')) { - hasBrackets = true; - } - - if (hasBrackets) { - unit = unit.substr(1, unit.length - 2) - } - - return unit; - } - -} - -export class BaseCurrencyParser implements IParser { - protected readonly config: INumberWithUnitParserConfiguration; - private readonly numberWithUnitParser: NumberWithUnitParser; - - constructor(config: INumberWithUnitParserConfiguration) { - this.config = config; - this.numberWithUnitParser = new NumberWithUnitParser(config); - } - - public parse(extResult: ExtractResult): ParseResult { - let result: ParseResult = null; - - if (extResult.data instanceof Array) { - result = this.mergeCompoundUnit(extResult); - } - else { - result = this.numberWithUnitParser.parse(extResult); - let value: UnitValue = result.value; - if (!this.config.currencyNameToIsoCodeMap.has(value.unit) || this.config.currencyNameToIsoCodeMap.get(value.unit).startsWith(Constants.FAKE_ISO_CODE_PREFIX)) { - result.value = { - unit: value.unit, - number: value.number - } as UnitValue; - } - else { - result.value = { - unit: value.unit, - number: value.number, - isoCurrency: this.config.currencyNameToIsoCodeMap.get(value.unit) - } as UnitValueIso; - } - } - return result; - } - - private mergeCompoundUnit(compoundResult: ExtractResult): ParseResult { - let results: ParseResult[] = []; - let compoundUnit: ParseResult[] = compoundResult.data; - - let count = 0; - let result: ParseResult = null; - let numberValue = null; - let mainUnitValue = ''; - let mainUnitIsoCode = ''; - let fractionUnitsString = ''; - - for (let i = 0; i < compoundUnit.length; i++) { - let extractResult = compoundUnit[i]; - let parseResult = this.numberWithUnitParser.parse(extractResult); - let parseResultValue: UnitValue = parseResult.value; - let unitValue = parseResultValue != null ? parseResultValue.unit : null; - - // Process a new group - if (count === 0) { - if (extractResult.type !== Constants.SYS_UNIT_CURRENCY) { - continue; - } - - // Initialize a new result - result = new ParseResult(extractResult); - - mainUnitValue = unitValue; - if (parseResultValue.number != null) { - numberValue = parseFloat(parseResultValue.number); - } - result.resolutionStr = parseResult.resolutionStr; - - if (this.config.currencyNameToIsoCodeMap.has(unitValue)) { - mainUnitIsoCode = this.config.currencyNameToIsoCodeMap.get(unitValue); - } - - // If the main unit can't be recognized, finish process this group. - if (StringUtility.isNullOrEmpty(mainUnitIsoCode)) { - result.value = { - number: numberValue.toString(), - unit: mainUnitValue - } as UnitValue; - - results.push(result); - result = null; - continue; - } - - if (this.config.currencyFractionMapping.has(mainUnitIsoCode)) { - fractionUnitsString = this.config.currencyFractionMapping.get(mainUnitIsoCode); - } - } - else { - // Match pure number as fraction unit. - if (extractResult.type === NumberConstants.SYS_NUM) { - numberValue += parseResult.value * (1.0 / 100); - result.resolutionStr += ' ' + parseResult.resolutionStr; - result.length = parseResult.start + parseResult.length - result.start; - count++; - continue; - } - - let fractionUnitCode: string; - let fractionNumValue: number; - - if (this.config.currencyFractionCodeList.has(unitValue)) { - fractionUnitCode = this.config.currencyFractionCodeList.get(unitValue); - } - - if (this.config.currencyFractionNumMap.has(unitValue)) { - fractionNumValue = this.config.currencyFractionNumMap.get(unitValue); - } - - if (fractionUnitCode && fractionNumValue !== 0 && this.checkUnitsStringContains(fractionUnitCode, fractionUnitsString)) { - numberValue += parseFloat(parseResultValue.number) * (1.0 / fractionNumValue); - result.resolutionStr += ' ' + parseResult.resolutionStr; - result.length = parseResult.start + parseResult.length - result.start; - } - else { - // If the fraction unit doesn't match the main unit, finish process this group. - if (result !== null) { - result = this.createCurrencyResult(result, mainUnitIsoCode, numberValue, mainUnitValue); - results.push(result); - result = null; - } - - count = 0; - i -= 1; - numberValue = null; - continue; - } - } - - count++; - } - - if (result !== null) { - result = this.createCurrencyResult(result, mainUnitIsoCode, numberValue, mainUnitValue); - results.push(result); - } - - this.resolveText(results, compoundResult.text, compoundResult.start); - - return { value: results } as ParseResult; - } - - private checkUnitsStringContains(fractionUnitCode: string, fractionUnitsString: string): boolean { - let unitsMap = new Map(); - DictionaryUtils.bindUnitsString(unitsMap, '', fractionUnitsString); - - return unitsMap.has(fractionUnitCode); - } - - private resolveText(prs: ParseResult[], source: string, bias: number): void { - prs.forEach(parseResult => { - if (parseResult.start !== null && parseResult.length !== null) { - parseResult.text = source.substr(parseResult.start - bias, parseResult.length); - } - }); - } - - private createCurrencyResult(result: ParseResult, mainUnitIsoCode: string, numberValue: number, mainUnitValue: string): ParseResult{ - if (StringUtility.isNullOrEmpty(mainUnitIsoCode) || mainUnitIsoCode.startsWith(Constants.FAKE_ISO_CODE_PREFIX)) { - result.value = { - number: numberValue ? numberValue.toString() : 'null', - unit: mainUnitValue - } as UnitValue; - } - else { - result.value = { - number: numberValue ? numberValue.toString() : 'null', - unit: mainUnitValue, - isoCurrency: mainUnitIsoCode - } as UnitValueIso; - } - - return result; - } -} - -export class BaseMergedUnitParser implements IParser { - protected readonly config: INumberWithUnitParserConfiguration; - private readonly numberWithUnitParser: NumberWithUnitParser; - private readonly currencyParser: BaseCurrencyParser; - - constructor(config: INumberWithUnitParserConfiguration) { - this.config = config; - this.numberWithUnitParser = new NumberWithUnitParser(config); - this.currencyParser = new BaseCurrencyParser(config); - } - - parse(extResult: ExtractResult): ParseResult { - let result: ParseResult; - - if (extResult.type === Constants.SYS_UNIT_CURRENCY) { - result = this.currencyParser.parse(extResult); - } - else { - result = this.numberWithUnitParser.parse(extResult); - } - - return result; - } -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-number-with-unit/src/numberWithUnit/portuguese/age.ts b/JavaScript/packages/recognizers-number-with-unit/src/numberWithUnit/portuguese/age.ts deleted file mode 100644 index ff253204b3..0000000000 --- a/JavaScript/packages/recognizers-number-with-unit/src/numberWithUnit/portuguese/age.ts +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { CultureInfo, Culture } from "@microsoft/recognizers-text-number"; -import { Constants } from "../constants"; -import { PortugueseNumberWithUnitExtractorConfiguration, PortugueseNumberWithUnitParserConfiguration } from "./base"; -import { PortugueseNumericWithUnit } from "../../resources/portugueseNumericWithUnit"; - -export class PortugueseAgeExtractorConfiguration extends PortugueseNumberWithUnitExtractorConfiguration { - readonly suffixList: ReadonlyMap; - readonly prefixList: ReadonlyMap; - readonly ambiguousUnitList: readonly string[]; - readonly extractType: string; - - constructor(ci?: CultureInfo) { - if (!ci) { - ci = new CultureInfo(Culture.Portuguese); - } - - super(ci); - - this.extractType = Constants.SYS_UNIT_AGE; - - this.suffixList = PortugueseNumericWithUnit.AgeSuffixList; - this.prefixList = new Map(); - this.ambiguousUnitList = PortugueseNumericWithUnit.AmbiguousAgeUnitList; - } -} - -export class PortugueseAgeParserConfiguration extends PortugueseNumberWithUnitParserConfiguration { - constructor(ci?: CultureInfo) { - if (!ci) { - ci = new CultureInfo(Culture.Portuguese); - } - - super(ci); - - this.BindDictionary(PortugueseNumericWithUnit.AgeSuffixList); - } -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-number-with-unit/src/numberWithUnit/portuguese/base.ts b/JavaScript/packages/recognizers-number-with-unit/src/numberWithUnit/portuguese/base.ts deleted file mode 100644 index 28b6015e2b..0000000000 --- a/JavaScript/packages/recognizers-number-with-unit/src/numberWithUnit/portuguese/base.ts +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { ExtractResult, IExtractor, IParser, RegExpUtility } from "@microsoft/recognizers-text"; -import { Culture, CultureInfo, NumberMode, AgnosticNumberParserFactory, AgnosticNumberParserType, PortugueseNumberExtractor, PortugueseNumberParserConfiguration } from "@microsoft/recognizers-text-number"; -import { Constants } from "../constants"; -import { INumberWithUnitExtractorConfiguration } from "../extractors"; -import { BaseNumberWithUnitParserConfiguration } from "../parsers"; -import { PortugueseNumericWithUnit } from "../../resources/portugueseNumericWithUnit"; -import { BaseUnits } from "../../resources/baseUnits"; - -export abstract class PortugueseNumberWithUnitExtractorConfiguration implements INumberWithUnitExtractorConfiguration { - abstract readonly suffixList: ReadonlyMap; - abstract readonly prefixList: ReadonlyMap; - abstract readonly ambiguousUnitList: readonly string[]; - readonly abstract extractType: string; - - readonly cultureInfo: CultureInfo; - readonly unitNumExtractor: IExtractor; - readonly buildPrefix: string; - readonly buildSuffix: string; - readonly connectorToken: string; - readonly compoundUnitConnectorRegex: RegExp; - readonly nonUnitRegex: RegExp; - readonly ambiguousUnitNumberMultiplierRegex: RegExp; - - constructor(ci: CultureInfo) { - this.cultureInfo = ci; - this.unitNumExtractor = new PortugueseNumberExtractor(NumberMode.Unit); - - this.buildPrefix = PortugueseNumericWithUnit.BuildPrefix; - this.buildSuffix = PortugueseNumericWithUnit.BuildSuffix; - this.connectorToken = PortugueseNumericWithUnit.ConnectorToken; - this.compoundUnitConnectorRegex = RegExpUtility.getSafeRegExp(PortugueseNumericWithUnit.CompoundUnitConnectorRegex); - this.nonUnitRegex = RegExpUtility.getSafeRegExp(BaseUnits.PmNonUnitRegex); - } - - expandHalfSuffix(source: string, result: ExtractResult[], numbers: ExtractResult[]) { - } -} - -export class PortugueseNumberWithUnitParserConfiguration extends BaseNumberWithUnitParserConfiguration { - readonly internalNumberParser: IParser; - readonly internalNumberExtractor: IExtractor; - readonly connectorToken: string; - readonly currencyNameToIsoCodeMap: ReadonlyMap; - readonly currencyFractionCodeList: ReadonlyMap; - - constructor(ci: CultureInfo) { - super(ci); - - this.internalNumberExtractor = new PortugueseNumberExtractor(NumberMode.Default); - this.internalNumberParser = AgnosticNumberParserFactory.getParser(AgnosticNumberParserType.Number, new PortugueseNumberParserConfiguration()); - this.connectorToken = PortugueseNumericWithUnit.ConnectorToken; - } -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-number-with-unit/src/numberWithUnit/portuguese/currency.ts b/JavaScript/packages/recognizers-number-with-unit/src/numberWithUnit/portuguese/currency.ts deleted file mode 100644 index 4ed98404d3..0000000000 --- a/JavaScript/packages/recognizers-number-with-unit/src/numberWithUnit/portuguese/currency.ts +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { CultureInfo, Culture } from "@microsoft/recognizers-text-number"; -import { Constants } from "../constants"; -import { PortugueseNumberWithUnitExtractorConfiguration, PortugueseNumberWithUnitParserConfiguration } from "./base"; -import { PortugueseNumericWithUnit } from "../../resources/portugueseNumericWithUnit"; - -export class PortugueseCurrencyExtractorConfiguration extends PortugueseNumberWithUnitExtractorConfiguration { - readonly suffixList: ReadonlyMap; - readonly prefixList: ReadonlyMap; - readonly ambiguousUnitList: readonly string[]; - readonly extractType: string; - - constructor(ci?: CultureInfo) { - if (!ci) { - ci = new CultureInfo(Culture.Portuguese); - } - - super(ci); - - this.extractType = Constants.SYS_UNIT_CURRENCY; - - // Reference Source: https:// en.wikipedia.org/wiki/List_of_circulating_currencies - this.suffixList = PortugueseNumericWithUnit.CurrencySuffixList; - this.prefixList = PortugueseNumericWithUnit.CurrencyPrefixList; - this.ambiguousUnitList = PortugueseNumericWithUnit.AmbiguousCurrencyUnitList; - } -} - -export class PortugueseCurrencyParserConfiguration extends PortugueseNumberWithUnitParserConfiguration { - constructor(ci?: CultureInfo) { - if (!ci) { - ci = new CultureInfo(Culture.Portuguese); - } - - super(ci); - - this.BindDictionary(PortugueseNumericWithUnit.CurrencySuffixList); - this.BindDictionary(PortugueseNumericWithUnit.CurrencyPrefixList); - } -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-number-with-unit/src/numberWithUnit/portuguese/dimension.ts b/JavaScript/packages/recognizers-number-with-unit/src/numberWithUnit/portuguese/dimension.ts deleted file mode 100644 index 08c2e12959..0000000000 --- a/JavaScript/packages/recognizers-number-with-unit/src/numberWithUnit/portuguese/dimension.ts +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { CultureInfo, Culture } from "@microsoft/recognizers-text-number"; -import { Constants } from "../constants"; -import { PortugueseNumberWithUnitExtractorConfiguration, PortugueseNumberWithUnitParserConfiguration } from "./base"; -import { PortugueseNumericWithUnit } from "../../resources/portugueseNumericWithUnit"; - -const dimensionSuffixList = new Map([ - ...PortugueseNumericWithUnit.InformationSuffixList, - ...PortugueseNumericWithUnit.AreaSuffixList, - ...PortugueseNumericWithUnit.LengthSuffixList, - ...PortugueseNumericWithUnit.SpeedSuffixList, - ...PortugueseNumericWithUnit.VolumeSuffixList, - ...PortugueseNumericWithUnit.WeightSuffixList -]); - -export class PortugueseDimensionExtractorConfiguration extends PortugueseNumberWithUnitExtractorConfiguration { - - readonly suffixList: ReadonlyMap; - readonly prefixList: ReadonlyMap; - readonly ambiguousUnitList: readonly string[]; - readonly extractType: string; - - constructor(ci?: CultureInfo) { - if (!ci) { - ci = new CultureInfo(Culture.Portuguese); - } - - super(ci); - - this.extractType = Constants.SYS_UNIT_DIMENSION; - - this.suffixList = dimensionSuffixList; - this.prefixList = new Map(); - this.ambiguousUnitList = PortugueseNumericWithUnit.AmbiguousDimensionUnitList.concat( - PortugueseNumericWithUnit.AmbiguousAngleUnitList.concat( - PortugueseNumericWithUnit.AmbiguousLengthUnitList.concat( - PortugueseNumericWithUnit.AmbiguousSpeedUnitList.concat( - PortugueseNumericWithUnit.AmbiguousWeightUnitList)))); - } -} - -export class PortugueseDimensionParserConfiguration extends PortugueseNumberWithUnitParserConfiguration { - constructor(ci?: CultureInfo) { - if (!ci) { - ci = new CultureInfo(Culture.Portuguese); - } - - super(ci); - - this.BindDictionary(dimensionSuffixList); - } -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-number-with-unit/src/numberWithUnit/portuguese/temperature.ts b/JavaScript/packages/recognizers-number-with-unit/src/numberWithUnit/portuguese/temperature.ts deleted file mode 100644 index 8056760296..0000000000 --- a/JavaScript/packages/recognizers-number-with-unit/src/numberWithUnit/portuguese/temperature.ts +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { CultureInfo, Culture, RegExpUtility } from "@microsoft/recognizers-text-number"; -import { Constants } from "../constants"; -import { PortugueseNumberWithUnitExtractorConfiguration, PortugueseNumberWithUnitParserConfiguration } from "./base"; -import { PortugueseNumericWithUnit } from "../../resources/portugueseNumericWithUnit"; -import { BaseUnits } from "../../resources/baseUnits"; - -export class PortugueseTemperatureExtractorConfiguration extends PortugueseNumberWithUnitExtractorConfiguration { - readonly suffixList: ReadonlyMap; - readonly prefixList: ReadonlyMap; - readonly ambiguousUnitList: readonly string[]; - readonly extractType: string; - readonly ambiguousUnitNumberMultiplierRegex: RegExp; - - constructor(ci?: CultureInfo) { - if (!ci) { - ci = new CultureInfo(Culture.Portuguese); - } - - super(ci); - - this.extractType = Constants.SYS_UNIT_TEMPERATURE; - - this.suffixList = PortugueseNumericWithUnit.TemperatureSuffixList; - this.prefixList = new Map(); - this.ambiguousUnitList = new Array(); - - this.ambiguousUnitNumberMultiplierRegex = RegExpUtility.getSafeRegExp(BaseUnits.AmbiguousUnitNumberMultiplierRegex, "gs"); - } -} - -export class PortugueseTemperatureParserConfiguration extends PortugueseNumberWithUnitParserConfiguration { - constructor(ci?: CultureInfo) { - if (!ci) { - ci = new CultureInfo(Culture.Portuguese); - } - - super(ci); - - this.BindDictionary(PortugueseNumericWithUnit.TemperatureSuffixList); - } -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-number-with-unit/src/numberWithUnit/spanish/age.ts b/JavaScript/packages/recognizers-number-with-unit/src/numberWithUnit/spanish/age.ts deleted file mode 100644 index a5bf582cfd..0000000000 --- a/JavaScript/packages/recognizers-number-with-unit/src/numberWithUnit/spanish/age.ts +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { CultureInfo, Culture } from "@microsoft/recognizers-text-number"; -import { Constants } from "../constants"; -import { SpanishNumberWithUnitExtractorConfiguration, SpanishNumberWithUnitParserConfiguration } from "./base"; -import { SpanishNumericWithUnit } from "../../resources/spanishNumericWithUnit"; - -export class SpanishAgeExtractorConfiguration extends SpanishNumberWithUnitExtractorConfiguration { - readonly suffixList: ReadonlyMap; - readonly prefixList: ReadonlyMap; - readonly ambiguousUnitList: readonly string[]; - readonly extractType: string; - - constructor(ci?: CultureInfo) { - if (!ci) { - ci = new CultureInfo(Culture.Spanish); - } - - super(ci); - - this.extractType = Constants.SYS_UNIT_AGE; - - this.suffixList = SpanishNumericWithUnit.AgeSuffixList; - this.prefixList = new Map(); - this.ambiguousUnitList = SpanishNumericWithUnit.AmbiguousAgeUnitList; - } -} - -export class SpanishAgeParserConfiguration extends SpanishNumberWithUnitParserConfiguration { - constructor(ci?: CultureInfo) { - if (!ci) { - ci = new CultureInfo(Culture.Spanish); - } - - super(ci); - - this.BindDictionary(SpanishNumericWithUnit.AgeSuffixList); - } -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-number-with-unit/src/numberWithUnit/spanish/base.ts b/JavaScript/packages/recognizers-number-with-unit/src/numberWithUnit/spanish/base.ts deleted file mode 100644 index a0e0c3cea2..0000000000 --- a/JavaScript/packages/recognizers-number-with-unit/src/numberWithUnit/spanish/base.ts +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { ExtractResult, IExtractor, IParser, RegExpUtility } from "@microsoft/recognizers-text"; -import { Culture, CultureInfo, NumberMode, AgnosticNumberParserFactory, AgnosticNumberParserType, SpanishNumberExtractor, SpanishNumberParserConfiguration } from "@microsoft/recognizers-text-number"; -import { Constants } from "../constants"; -import { INumberWithUnitExtractorConfiguration } from "../extractors"; -import { BaseNumberWithUnitParserConfiguration } from "../parsers"; -import { SpanishNumericWithUnit } from "../../resources/spanishNumericWithUnit"; -import { BaseUnits } from "../../resources/baseUnits"; - -export abstract class SpanishNumberWithUnitExtractorConfiguration implements INumberWithUnitExtractorConfiguration { - abstract readonly suffixList: ReadonlyMap; - abstract readonly prefixList: ReadonlyMap; - abstract readonly ambiguousUnitList: readonly string[]; - readonly abstract extractType: string; - - readonly cultureInfo: CultureInfo; - readonly unitNumExtractor: IExtractor; - readonly buildPrefix: string; - readonly buildSuffix: string; - readonly connectorToken: string; - readonly compoundUnitConnectorRegex: RegExp; - readonly nonUnitRegex: RegExp; - readonly ambiguousUnitNumberMultiplierRegex: RegExp; - - constructor(ci: CultureInfo) { - this.cultureInfo = ci; - this.unitNumExtractor = new SpanishNumberExtractor(NumberMode.Unit); - - this.buildPrefix = SpanishNumericWithUnit.BuildPrefix; - this.buildSuffix = SpanishNumericWithUnit.BuildSuffix; - this.connectorToken = SpanishNumericWithUnit.ConnectorToken; - this.compoundUnitConnectorRegex = RegExpUtility.getSafeRegExp(SpanishNumericWithUnit.CompoundUnitConnectorRegex); - this.nonUnitRegex = RegExpUtility.getSafeRegExp(BaseUnits.PmNonUnitRegex); - } - - expandHalfSuffix(source: string, result: ExtractResult[], numbers: ExtractResult[]) { - } -} - -export class SpanishNumberWithUnitParserConfiguration extends BaseNumberWithUnitParserConfiguration { - readonly internalNumberParser: IParser; - readonly internalNumberExtractor: IExtractor; - readonly connectorToken: string; - readonly currencyNameToIsoCodeMap: ReadonlyMap; - readonly currencyFractionCodeList: ReadonlyMap; - - constructor(ci: CultureInfo) { - super(ci); - - this.internalNumberExtractor = new SpanishNumberExtractor(NumberMode.Default); - this.internalNumberParser = AgnosticNumberParserFactory.getParser(AgnosticNumberParserType.Number, new SpanishNumberParserConfiguration()); - this.connectorToken = SpanishNumericWithUnit.ConnectorToken; - } -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-number-with-unit/src/numberWithUnit/spanish/currency.ts b/JavaScript/packages/recognizers-number-with-unit/src/numberWithUnit/spanish/currency.ts deleted file mode 100644 index 02fea2904f..0000000000 --- a/JavaScript/packages/recognizers-number-with-unit/src/numberWithUnit/spanish/currency.ts +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { CultureInfo, Culture } from "@microsoft/recognizers-text-number"; -import { Constants } from "../constants"; -import { SpanishNumberWithUnitExtractorConfiguration, SpanishNumberWithUnitParserConfiguration } from "./base"; -import { SpanishNumericWithUnit } from "../../resources/spanishNumericWithUnit"; - -export class SpanishCurrencyExtractorConfiguration extends SpanishNumberWithUnitExtractorConfiguration { - readonly suffixList: ReadonlyMap; - readonly prefixList: ReadonlyMap; - readonly ambiguousUnitList: readonly string[]; - readonly extractType: string; - - constructor(ci?: CultureInfo) { - if (!ci) { - ci = new CultureInfo(Culture.Spanish); - } - - super(ci); - - this.extractType = Constants.SYS_UNIT_CURRENCY; - - // Reference Source: https:// en.wikipedia.org/wiki/List_of_circulating_currencies - this.suffixList = SpanishNumericWithUnit.CurrencySuffixList; - this.prefixList = SpanishNumericWithUnit.CurrencyPrefixList; - this.ambiguousUnitList = SpanishNumericWithUnit.AmbiguousCurrencyUnitList; - } -} - -export class SpanishCurrencyParserConfiguration extends SpanishNumberWithUnitParserConfiguration { - constructor(ci?: CultureInfo) { - if (!ci) { - ci = new CultureInfo(Culture.Spanish); - } - - super(ci); - - this.BindDictionary(SpanishNumericWithUnit.CurrencySuffixList); - this.BindDictionary(SpanishNumericWithUnit.CurrencyPrefixList); - } -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-number-with-unit/src/numberWithUnit/spanish/dimension.ts b/JavaScript/packages/recognizers-number-with-unit/src/numberWithUnit/spanish/dimension.ts deleted file mode 100644 index 073ec83c98..0000000000 --- a/JavaScript/packages/recognizers-number-with-unit/src/numberWithUnit/spanish/dimension.ts +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { CultureInfo, Culture } from "@microsoft/recognizers-text-number"; -import { Constants } from "../constants"; -import { SpanishNumberWithUnitExtractorConfiguration, SpanishNumberWithUnitParserConfiguration } from "./base"; -import { SpanishNumericWithUnit } from "../../resources/spanishNumericWithUnit"; - -const dimensionSuffixList = new Map([ - ...SpanishNumericWithUnit.InformationSuffixList, - ...SpanishNumericWithUnit.AreaSuffixList, - ...SpanishNumericWithUnit.LengthSuffixList, - ...SpanishNumericWithUnit.SpeedSuffixList, - ...SpanishNumericWithUnit.VolumeSuffixList, - ...SpanishNumericWithUnit.WeightSuffixList -]); - - -export class SpanishDimensionExtractorConfiguration extends SpanishNumberWithUnitExtractorConfiguration { - - readonly suffixList: ReadonlyMap; - readonly prefixList: ReadonlyMap; - readonly ambiguousUnitList: readonly string[]; - readonly extractType: string; - - constructor(ci?: CultureInfo) { - if (!ci) { - ci = new CultureInfo(Culture.Spanish); - } - - super(ci); - - this.extractType = Constants.SYS_UNIT_DIMENSION; - - this.suffixList = dimensionSuffixList; - this.prefixList = new Map(); - this.ambiguousUnitList = SpanishNumericWithUnit.AmbiguousDimensionUnitList.concat( - SpanishNumericWithUnit.AmbiguousAngleUnitList.concat( - SpanishNumericWithUnit.AmbiguousLengthUnitList.concat( - SpanishNumericWithUnit.AmbiguousSpeedUnitList.concat( - SpanishNumericWithUnit.AmbiguousWeightUnitList)))); - } -} - -export class SpanishDimensionParserConfiguration extends SpanishNumberWithUnitParserConfiguration { - constructor(ci?: CultureInfo) { - if (!ci) { - ci = new CultureInfo(Culture.Spanish); - } - - super(ci); - - this.BindDictionary(dimensionSuffixList); - } -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-number-with-unit/src/numberWithUnit/spanish/temperature.ts b/JavaScript/packages/recognizers-number-with-unit/src/numberWithUnit/spanish/temperature.ts deleted file mode 100644 index 335f7a898b..0000000000 --- a/JavaScript/packages/recognizers-number-with-unit/src/numberWithUnit/spanish/temperature.ts +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { CultureInfo, Culture, RegExpUtility } from "@microsoft/recognizers-text-number"; -import { Constants } from "../constants"; -import { SpanishNumberWithUnitExtractorConfiguration, SpanishNumberWithUnitParserConfiguration } from "./base"; -import { SpanishNumericWithUnit } from "../../resources/spanishNumericWithUnit"; -import { BaseUnits } from "../../resources/baseUnits"; - -export class SpanishTemperatureExtractorConfiguration extends SpanishNumberWithUnitExtractorConfiguration { - readonly suffixList: ReadonlyMap; - readonly prefixList: ReadonlyMap; - readonly ambiguousUnitList: readonly string[]; - readonly extractType: string; - readonly ambiguousUnitNumberMultiplierRegex: RegExp; - - constructor(ci?: CultureInfo) { - if (!ci) { - ci = new CultureInfo(Culture.Spanish); - } - - super(ci); - - this.extractType = Constants.SYS_UNIT_TEMPERATURE; - - this.suffixList = SpanishNumericWithUnit.TemperatureSuffixList; - this.prefixList = new Map(); - this.ambiguousUnitList = new Array(); - - this.ambiguousUnitNumberMultiplierRegex = RegExpUtility.getSafeRegExp(BaseUnits.AmbiguousUnitNumberMultiplierRegex, "gs"); - } -} - -export class SpanishTemperatureParserConfiguration extends SpanishNumberWithUnitParserConfiguration { - constructor(ci?: CultureInfo) { - if (!ci) { - ci = new CultureInfo(Culture.Spanish); - } - - super(ci); - - this.BindDictionary(SpanishNumericWithUnit.TemperatureSuffixList); - } -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-number-with-unit/src/numberWithUnit/utilities.ts b/JavaScript/packages/recognizers-number-with-unit/src/numberWithUnit/utilities.ts deleted file mode 100644 index fe896f6282..0000000000 --- a/JavaScript/packages/recognizers-number-with-unit/src/numberWithUnit/utilities.ts +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { StringUtility } from "@microsoft/recognizers-text"; - -export class DictionaryUtils { - static bindDictionary(dictionary: ReadonlyMap, source: Map) { - if (dictionary === null) { - return; - } - - dictionary.forEach((value, key) => { - if (StringUtility.isNullOrEmpty(key)) { - return; - } - - this.bindUnitsString(source, key, value); - }); - } - - static bindUnitsString(dictionary: Map, key: string, source: string) { - let values = source.trim().split('|'); - values.forEach(token => { - - if (StringUtility.isNullOrWhitespace(token) || dictionary.has(token)) { - return; - } - - dictionary.set(token, key); - }); - } -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-number-with-unit/src/recognizers-text-number-with-unit.ts b/JavaScript/packages/recognizers-number-with-unit/src/recognizers-text-number-with-unit.ts deleted file mode 100644 index f75c1a01c2..0000000000 --- a/JavaScript/packages/recognizers-number-with-unit/src/recognizers-text-number-with-unit.ts +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -export { default as NumberWithUnitRecognizer, NumberWithUnitOptions, recognizeTemperature, recognizeDimension, recognizeCurrency, recognizeAge } from "./numberWithUnit/numberWithUnitRecognizer"; -export { Culture, CultureInfo } from "@microsoft/recognizers-text-number"; -export { Constants } from "./numberWithUnit/constants"; -export { INumberWithUnitExtractorConfiguration, NumberWithUnitExtractor, PrefixUnitResult, BaseMergedUnitExtractor } from "./numberWithUnit/extractors"; -export { CompositeEntityType, AbstractNumberWithUnitModel, AgeModel, CurrencyModel, DimensionModel, TemperatureModel } from "./numberWithUnit/models"; -export { UnitValue, UnitValueIso, NumberWithUnitParser, INumberWithUnitParserConfiguration, BaseNumberWithUnitParserConfiguration, BaseCurrencyParser, BaseMergedUnitParser } from "./numberWithUnit/parsers"; -export { EnglishAgeExtractorConfiguration, EnglishAgeParserConfiguration } from "./numberWithUnit/english/age"; -export { EnglishNumberWithUnitExtractorConfiguration, EnglishNumberWithUnitParserConfiguration } from "./numberWithUnit/english/base"; -export { EnglishCurrencyExtractorConfiguration, EnglishCurrencyParserConfiguration } from "./numberWithUnit/english/currency"; -export { EnglishDimensionExtractorConfiguration, EnglishDimensionParserConfiguration } from "./numberWithUnit/english/dimension"; -export { EnglishTemperatureExtractorConfiguration, EnglishTemperatureParserConfiguration } from "./numberWithUnit/english/temperature"; -export { SpanishAgeExtractorConfiguration, SpanishAgeParserConfiguration } from "./numberWithUnit/spanish/age"; -export { SpanishNumberWithUnitExtractorConfiguration, SpanishNumberWithUnitParserConfiguration } from "./numberWithUnit/spanish/base"; -export { SpanishCurrencyExtractorConfiguration, SpanishCurrencyParserConfiguration } from "./numberWithUnit/spanish/currency"; -export { SpanishDimensionExtractorConfiguration, SpanishDimensionParserConfiguration } from "./numberWithUnit/spanish/dimension"; -export { SpanishTemperatureExtractorConfiguration, SpanishTemperatureParserConfiguration } from "./numberWithUnit/spanish/temperature"; -export { PortugueseAgeExtractorConfiguration, PortugueseAgeParserConfiguration } from "./numberWithUnit/portuguese/age"; -export { PortugueseNumberWithUnitExtractorConfiguration, PortugueseNumberWithUnitParserConfiguration } from "./numberWithUnit/portuguese/base"; -export { PortugueseCurrencyExtractorConfiguration, PortugueseCurrencyParserConfiguration } from "./numberWithUnit/portuguese/currency"; -export { PortugueseDimensionExtractorConfiguration, PortugueseDimensionParserConfiguration } from "./numberWithUnit/portuguese/dimension"; -export { PortugueseTemperatureExtractorConfiguration, PortugueseTemperatureParserConfiguration } from "./numberWithUnit/portuguese/temperature"; -export { ChineseAgeExtractorConfiguration, ChineseAgeParserConfiguration } from "./numberWithUnit/chinese/age"; -export { ChineseNumberWithUnitExtractorConfiguration, ChineseNumberWithUnitParserConfiguration } from "./numberWithUnit/chinese/base"; -export { ChineseCurrencyExtractorConfiguration, ChineseCurrencyParserConfiguration } from "./numberWithUnit/chinese/currency"; -export { ChineseDimensionExtractorConfiguration, ChineseDimensionParserConfiguration } from "./numberWithUnit/chinese/dimension"; -export { ChineseTemperatureExtractorConfiguration, ChineseTemperatureParserConfiguration } from "./numberWithUnit/chinese/temperature"; -export { JapaneseAgeExtractorConfiguration, JapaneseAgeParserConfiguration } from "./numberWithUnit/japanese/age"; -export { JapaneseNumberWithUnitExtractorConfiguration, JapaneseNumberWithUnitParserConfiguration } from "./numberWithUnit/japanese/base"; -export { JapaneseCurrencyExtractorConfiguration, JapaneseCurrencyParserConfiguration } from "./numberWithUnit/japanese/currency"; -export { EnglishNumericWithUnit } from "./resources/englishNumericWithUnit"; -export { SpanishNumericWithUnit } from "./resources/spanishNumericWithUnit"; -export { PortugueseNumericWithUnit } from "./resources/portugueseNumericWithUnit"; -export { ChineseNumericWithUnit } from "./resources/chineseNumericWithUnit"; -export { JapaneseNumericWithUnit } from "./resources/japaneseNumericWithUnit"; \ No newline at end of file diff --git a/JavaScript/packages/recognizers-number-with-unit/src/resources/baseCurrency.ts b/JavaScript/packages/recognizers-number-with-unit/src/resources/baseCurrency.ts deleted file mode 100644 index b0bb60cdac..0000000000 --- a/JavaScript/packages/recognizers-number-with-unit/src/resources/baseCurrency.ts +++ /dev/null @@ -1,16 +0,0 @@ -// ------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// ------------------------------------------------------------------------------ - -export namespace BaseCurrency { - export const CurrencyFractionMapping: ReadonlyMap = new Map([["CNY", "FEN|JIAO"],["__D", "CENT"],["RUB", "KOPEK"],["AFN", "PUL"],["EUR", "CENT|KWARTJE|DUBBELTJE|STUIVER"],["ALL", "QINDARKE"],["_ALP", "PENNY"],["GBP", "PENNY"],["_GGP", "PENNY"],["DZD", "SANTEEM"],["AOA", "CENTIMO"],["ARS", "CENTAVO"],["AMD", "LUMA"],["AWG", "CENT"],["_AP", "PENNY"],["SHP", "PENNY"],["AUD", "CENT"],["AZN", "QƏPIK"],["BSD", "CENT"],["BHD", "FILS"],["BDT", "POISHA"],["BBD", "CENT"],["BYN", "KAPYEYKA"],["BZD", "CENT"],["XOF", "CENTIME"],["BMD", "CENT"],["BTN", "CHETRUM"],["INR", "PAISA"],["BOB", "CENTAVO"],["USD", "CENT"],["BAM", "FENING"],["BWP", "THEBE"],["BRL", "CENTAVO"],["_BD", "CENT"],["BND", "SEN"],["SGD", "CENT"],["BGN", "STOTINKA"],["BIF", "CENTIME"],["KHR", "SEN"],["XAF", "CENTIME"],["CAD", "CENT"],["CVE", "CENTAVO"],["KYD", "CENT"],["CLP", "CENTAVO"],["COP", "CENTAVO"],["KMF", "CENTIME"],["CDF", "CENTIME"],["NZD", "CENT"],["_CKD", "CENT"],["CRC", "CENTIMO"],["HRK", "LIPA"],["CUC", "CENTAVO"],["CUP", "CENTAVO"],["CZK", "HALER"],["DKK", "ØRE"],["DJF", "CENTIME"],["DOP", "CENTAVO"],["EGP", "PIASTRE"],["ERN", "CENT"],["ETB", "SANTIM"],["FKP", "PENNY"],["_FOK", "OYRA"],["FJD", "CENT"],["XPF", "CENTIME"],["GMD", "BUTUT"],["GEL", "TETRI"],["GHS", "PESEWA"],["GIP", "PENNY"],["GTQ", "CENTAVO"],["GNF", "CENTIME"],["GYD", "CENT"],["HTG", "CENTIME"],["HNL", "CENTAVO"],["HKD", "CENT"],["HUF", "FILLER"],["ISK", "EYRIR"],["IDR", "SEN"],["IRR", "DINAR"],["IQD", "FILS"],["IMP", "PENNY"],["ILS", "AGORA"],["JMD", "CENT"],["JPY", "SEN"],["JEP", "PENNY"],["JOD", "PIASTRE"],["KZT", "TIIN"],["KES", "CENT"],["_KID", "CENT"],["KPW", "CHON"],["KRW", "JEON"],["KWD", "FILS"],["KGS", "TYIYN"],["LAK", "ATT"],["LBP", "PIASTRE"],["LSL", "SENTE"],["ZAR", "CENT"],["LRD", "CENT"],["LYD", "DIRHAM"],["CHF", "RAPPEN"],["MOP", "AVO"],["MKD", "DENI"],["MGA", "IRAIMBILANJA"],["MWK", "TAMBALA"],["MYR", "SEN"],["MVR", "LAARI"],["MRO", "KHOUMS"],["MUR", "CENT"],["MXN", "CENTAVO"],["_MD", "CENT"],["MDL", "BAN"],["MNT", "MONGO"],["MAD", "CENTIME"],["MZN", "CENTAVO"],["MMK", "PYA"],["NAD", "CENT"],["_ND", "CENT"],["NPR", "PAISA"],["NIO", "CENTAVO"],["NGN", "KOBO"],["_NID", "CENT"],["TRY", "KURUS"],["NOK", "ØRE"],["OMR", "BAISA"],["PKR", "PAISA"],["_PD", "CENT"],["PAB", "CENTESIMO"],["PGK", "TOEA"],["PYG", "CENTIMO"],["PEN", "CENTIMO"],["_PND", "CENT"],["PLN", "GROSZ"],["QAR", "DIRHAM"],["RON", "BAN"],["RWF", "CENTIME"],["WST", "SENE"],["STD", "CENTIMO"],["SAR", "HALALA"],["RSD", "PARA"],["SCR", "CENT"],["SLL", "CENT"],["SBD", "CENT"],["SOS", "CENT"],["_SS", "CENT"],["_SP", "PENNY"],["SSP", "PIASTRE"],["LKR", "CENT"],["SDG", "PIASTRE"],["SRD", "CENT"],["SZL", "CENT"],["SEK", "ORE"],["SYP", "PIASTRE"],["TWD", "CENT"],["TJS", "DIRAM"],["TZS", "CENT"],["THB", "SATANG"],["PRB", "KOPEK"],["TTD", "CENT"],["_TP", "PENNY"],["TND", "MILLIME"],["TMT", "TENNESI"],["TVD", "CENT"],["UGX", "CENT"],["UAH", "KOPIYKA"],["AED", "FILS"],["UYU", "CENTESIMO"],["VEF", "CENTIMO"],["YER", "FILS"],["ZMW", "NGWEE"],["_XBT", "MILLIBITCOIN|SATOSHI"]]); - export const CurrencyFractionalRatios: ReadonlyMap = new Map([["Kopek", 100],["Pul", 100],["Cent", 100],["Qindarkë", 100],["Penny", 100],["Santeem", 100],["Cêntimo", 100],["Centavo", 100],["Luma", 100],["Qəpik", 100],["Fils", 1000],["Poisha", 100],["Kapyeyka", 100],["Centime", 100],["Chetrum", 100],["Paisa", 100],["Fening", 100],["Thebe", 100],["Sen", 100],["Stotinka", 100],["Jiao", 10],["Fen", 100],["Céntimo", 100],["Lipa", 100],["Haléř", 100],["Øre", 100],["Piastre", 100],["Santim", 100],["Oyra", 100],["Butut", 100],["Tetri", 100],["Pesewa", 100],["Fillér", 100],["Eyrir", 100],["Dinar", 100],["Agora", 100],["Tïın", 100],["Chon", 100],["Jeon", 100],["Tyiyn", 100],["Att", 100],["Sente", 100],["Dirham", 1000],["Rappen", 100],["Avo", 100],["Deni", 100],["Iraimbilanja", 5],["Tambala", 100],["Laari", 100],["Khoums", 5],["Ban", 100],["Möngö", 100],["Pya", 100],["Kobo", 100],["Kuruş", 100],["Baisa", 1000],["Centésimo", 100],["Toea", 100],["Sentimo", 100],["Grosz", 100],["Sene", 100],["Halala", 100],["Para", 100],["Öre", 100],["Diram", 100],["Satang", 100],["Seniti", 100],["Millime", 1000],["Tennesi", 100],["Kopiyka", 100],["Tiyin", 100],["Hào", 10],["Ngwee", 100],["Kwartje", 4],["Dubbeltje", 10],["Stuiver", 20],["Millibitcoin", 1000],["Satoshi", 100000000]]); - export const NonStandardFractionalSubunits: ReadonlyMap = new Map([["JOD", 1000],["KWD", 1000],["BHD", 1000],["OMR", 1000],["YDD", 1000],["TND", 1000],["MRO", 5],["_XBT", 1000]]); -} diff --git a/JavaScript/packages/recognizers-number-with-unit/src/resources/baseNumbers.ts b/JavaScript/packages/recognizers-number-with-unit/src/resources/baseNumbers.ts deleted file mode 100644 index 543c2ab786..0000000000 --- a/JavaScript/packages/recognizers-number-with-unit/src/resources/baseNumbers.ts +++ /dev/null @@ -1,25 +0,0 @@ -// ------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// ------------------------------------------------------------------------------ - -export namespace BaseNumbers { - export const NumberReplaceToken = `@builtin.num`; - export const FractionNumberReplaceToken = `@builtin.num.fraction`; - export const IntegerRegexDefinition = (placeholder: string, thousandsmark: string) => { return `(((? { return `(((? -// This code was generated by a tool. -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// ------------------------------------------------------------------------------ - -export namespace BaseUnits { - export const HourRegex = `(?00|01|02|03|04|05|06|07|08|09|0|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|1|2|3|4|5|6|7|8|9)(h)?`; - export const MinuteRegex = `(?00|01|02|03|04|05|06|07|08|09|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|32|33|34|35|36|37|38|39|40|41|42|43|44|45|46|47|48|49|50|51|52|53|54|55|56|57|58|59|0|1|2|3|4|5|6|7|8|9)(?!\\d)`; - export const SecondRegex = `(?00|01|02|03|04|05|06|07|08|09|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|32|33|34|35|36|37|38|39|40|41|42|43|44|45|46|47|48|49|50|51|52|53|54|55|56|57|58|59|0|1|2|3|4|5|6|7|8|9)`; - export const PmNonUnitRegex = `(${HourRegex}\\s*:\\s*${MinuteRegex}(\\s*:\\s*${SecondRegex})?\\s*pm)`; - export const AmbiguousTimeTerm = `pm`; - export const AmbiguousUnitNumberMultiplierRegex = `(\\s([Kk]|mil))`; - export const SingleCharUnitRegex = `^\\b(c|f|g|k|l|m|s)(\\s*\\.|\\b)$`; -} diff --git a/JavaScript/packages/recognizers-number-with-unit/src/resources/chineseNumericWithUnit.ts b/JavaScript/packages/recognizers-number-with-unit/src/resources/chineseNumericWithUnit.ts deleted file mode 100644 index e45e8d6086..0000000000 --- a/JavaScript/packages/recognizers-number-with-unit/src/resources/chineseNumericWithUnit.ts +++ /dev/null @@ -1,32 +0,0 @@ -// ------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// ------------------------------------------------------------------------------ - -import { BaseNumbers } from "./baseNumbers"; -export namespace ChineseNumericWithUnit { - export const AgeAmbiguousValues = [ "岁" ]; - export const AgeSuffixList: ReadonlyMap = new Map([["Year", "岁|周岁"],["Month", "个月大|月大"],["Week", "周大"],["Day", "天大"]]); - export const BuildPrefix = ``; - export const BuildSuffix = ``; - export const ConnectorToken = ``; - export const CurrencySuffixList: ReadonlyMap = new Map([["Afghan afghani", "阿富汗尼"],["Pul", "普尔"],["Euro", "欧元"],["Cent", "美分"],["Albanian lek", "阿尔巴尼亚列克|列克"],["Angolan kwanza", "安哥拉宽扎|宽扎"],["Armenian dram", "亚美尼亚德拉姆"],["Aruban florin", "阿鲁巴弗罗林|阿鲁巴币"],["Bangladeshi taka", "塔卡|孟加拉塔卡"],["Paisa", "派萨|帕萨"],["Bhutanese ngultrum", "不丹努尔特鲁姆|不丹努扎姆|努扎姆"],["Chetrum", "切特鲁姆"],["Bolivian boliviano", "玻利维亚诺|玻利维亚币"],["Bosnia and Herzegovina convertible mark", "波斯尼亚和黑塞哥维那可兑换马克|波赫可兑换马克"],["Botswana pula", "博茨瓦纳普拉|普拉"],["Thebe", "thebe"],["Brazilian real", "巴西雷亚尔"],["Bulgarian lev", "保加利亚列弗|保加利亚列瓦"],["Stotinka", "斯托丁卡"],["Cambodian riel", "瑞尔"],["Cape Verdean escudo", "佛得角埃斯库多|维德角埃斯库多"],["Croatian kuna", "克罗地亚库纳|克罗地亚库那|克罗埃西亚库纳"],["Lipa", "利巴"],["Eritrean nakfa", "厄立特里亚纳克法"],["Ethiopian birr", "埃塞俄比亚比尔|埃塞俄比亚元"],["Gambian dalasi", "冈比亚达拉西|甘比亚达拉西"],["Butut", "布达|布图"],["Georgian lari", "格鲁吉亚拉里"],["Tetri", "特特里|泰特里"],["Ghanaian cedi", "塞地|加纳塞地"],["Pesewa", "比塞瓦"],["Guatemalan quetzal", "瓜地马拉格查尔"],["Haitian gourde", "海地古德"],["Honduran lempira", "洪都拉斯伦皮拉"],["Hungarian forint", "匈牙利福林|匈牙利货币|匈牙利福林币"],["Iranian rial", "伊朗里亚尔|伊朗莱尔"],["Yemeni rial", "叶门莱尔|叶门里亚尔"],["Israeli new shekel", "₪|ils|以色列币|以色列新克尔|谢克尔"],["Japanese yen", "日元|日本元|日币|日圆"],["Sen", "日本銭"],["Kazakhstani tenge", "哈萨克斯坦坚戈"],["Kenyan shilling", "肯尼亚先令"],["North Korean won", "朝鲜圆|朝鲜元"],["South Korean won", "韩元|韩圆"],["Korean won", "₩"],["Kyrgyzstani som", "吉尔吉斯斯坦索姆"],["Lao kip", "基普|老挝基普|老挝币"],["Att", "att"],["Lesotho loti", "莱索托洛提|莱索托马洛蒂"],["South African rand", "南非兰特"],["Macedonian denar", "马其顿代纳尔|马其顿币|代纳尔"],["Deni", "第尼"],["Malagasy ariary", "马达加斯加阿里亚里"],["Iraimbilanja", "伊莱姆比拉贾"],["Malawian kwacha", "马拉威克瓦查"],["Tambala", "坦巴拉"],["Malaysian ringgit", "马来西亚币|马币|马来西亚林吉特"],["Mauritanian ouguiya", "毛里塔尼亚乌吉亚"],["Khoums", "库姆斯"],["Mozambican metical", "莫桑比克梅蒂卡尔|梅蒂卡尔"],["Burmese kyat", "缅甸元|缅元"],["Pya", "缅分"],["Nigerian naira", "尼日利亚奈拉|尼日利亚币|奈拉"],["Kobo", "考包"],["Turkish lira", "土耳其里拉"],["Kuruş", "库鲁"],["Omani rial", "阿曼里亚尔|阿曼莱尔"],["Panamanian balboa", "巴拿马巴波亚"],["Centesimo", "意大利分|乌拉圭分|巴拿马分"],["Papua New Guinean kina", "基那"],["Toea", "托亚|托伊"],["Peruvian sol", "秘鲁索尔"],["Polish złoty", "波兰币|波兰兹罗提|兹罗提"],["Grosz", "格罗希"],["Qatari riyal", "卡达里亚尔"],["Saudi riyal", "沙特里亚尔"],["Riyal", "里亚尔"],["Dirham", "迪拉姆"],["Halala", "哈拉"],["Samoan tālā", "萨摩亚塔拉"],["Sierra Leonean leone", "塞拉利昂利昂|利昂"],["Peseta", "比塞塔|西班牙比塞塔|西班牙币"],["Swazi lilangeni", "斯威士兰里兰吉尼|兰吉尼"],["Tajikistani somoni", "塔吉克斯坦索莫尼"],["Thai baht", "泰铢|泰元"],["Satang", "萨当"],["Tongan paʻanga", "汤加潘加|潘加"],["Ukrainian hryvnia", "乌克兰格里夫纳|格里夫纳"],["Vanuatu vatu", "瓦努阿图瓦图"],["Vietnamese dong", "越南盾"],["Indonesian rupiah", "印度尼西亚盾"],["Netherlands guilder", "荷兰盾|荷属安的列斯盾|列斯盾"],["Surinam florin", "苏里南盾"],["Guilder", "盾"],["Zambian kwacha", "赞比亚克瓦查"],["Moroccan dirham", "摩洛哥迪拉姆"],["United Arab Emirates dirham", "阿联酋迪拉姆"],["Azerbaijani manat", "阿塞拜疆马纳特"],["Turkmenistan manat", "土库曼马纳特"],["Manat", "马纳特"],["Somali shilling", "索马里先令|索马利先令"],["Somaliland shilling", "索马里兰先令"],["Tanzanian shilling", "坦桑尼亚先令"],["Ugandan shilling", "乌干达先令"],["Romanian leu", "罗马尼亚列伊"],["Moldovan leu", "摩尔多瓦列伊"],["Leu", "列伊"],["Ban", "巴尼"],["Nepalese rupee", "尼泊尔卢比"],["Pakistani rupee", "巴基斯坦卢比"],["Indian rupee", "印度卢比"],["Seychellois rupee", "塞舌尔卢比"],["Mauritian rupee", "毛里求斯卢比"],["Maldivian rufiyaa", "马尔代夫卢比"],["Sri Lankan rupee", "斯里兰卡卢比"],["Rupee", "卢比"],["Czech koruna", "捷克克朗"],["Danish krone", "丹麦克朗|丹麦克郎"],["Norwegian krone", "挪威克朗"],["Faroese króna", "法罗克朗"],["Icelandic króna", "冰岛克朗"],["Swedish krona", "瑞典克朗"],["Krone", "克朗"],["Øre", "奥依拉|奥拉|埃利"],["West African CFA franc", "非共体法郎"],["Central African CFA franc", "中非法郎|中非金融合作法郎"],["Comorian franc", "科摩罗法郎"],["Congolese franc", "刚果法郎"],["Burundian franc", "布隆迪法郎"],["Djiboutian franc", "吉布提法郎"],["CFP franc", "太平洋法郎"],["Guinean franc", "几内亚法郎"],["Swiss franc", "瑞士法郎"],["Rwandan franc", "卢旺达法郎"],["Belgian franc", "比利时法郎"],["Rappen", "瑞士分|瑞士生丁"],["Franc", "法郎"],["Centime", "生丁|仙士"],["Russian ruble", "俄国卢布|俄罗斯卢布"],["Transnistrian ruble", "德涅斯特卢布"],["Belarusian ruble", "白俄罗斯卢布"],["Kopek", "戈比"],["Ruble", "卢布"],["Algerian dinar", "阿尔及利亚第纳尔"],["Bahraini dinar", "巴林第纳尔"],["Iraqi dinar", "伊拉克第纳尔"],["Jordanian dinar", "约旦第纳尔"],["Kuwaiti dinar", "科威特第纳尔|科威特币"],["Libyan dinar", "利比亚第纳尔"],["Serbian dinar", "塞尔维亚第纳尔|塞尔维亚币"],["Tunisian dinar", "突尼斯第纳尔"],["Dinar", "第纳尔"],["Fils", "费尔"],["Para", "帕拉"],["Millime", "米利姆"],["Argentine peso", "阿根廷比索"],["Chilean peso", "智利比索"],["Colombian peso", "哥伦比亚比索"],["Cuban peso", "古巴比索"],["Dominican peso", "多米尼加比索"],["Mexican peso", "墨西哥比索"],["Philippine peso", "菲律宾比索"],["Uruguayan peso", "乌拉圭比索"],["Peso", "比索"],["Centavo", "仙|菲辅币"],["Alderney pound", "奥尔德尼镑"],["British pound", "英镑"],["Guernsey pound", "根西镑"],["Saint Helena pound", "圣赫勒拿镑"],["Egyptian pound", "埃及镑"],["Falkland Islands pound", "福克兰镑"],["Gibraltar pound", "直布罗陀镑"],["Manx pound", "马恩岛镑"],["Jersey pound", "泽西岛镑"],["Lebanese pound", "黎巴嫩镑"],["South Sudanese pound", "南苏丹镑"],["Sudanese pound", "苏丹镑"],["Syrian pound", "叙利亚镑"],["Pence", "便士"],["Shilling", "先令"],["United States dollar", "美元|美金|美圆"],["East Caribbean dollar", "东加勒比元"],["Australian dollar", "澳大利亚元|澳元"],["Bahamian dollar", "巴哈马元"],["Barbadian dollar", "巴巴多斯元"],["Belize dollar", "伯利兹元"],["Bermudian dollar", "百慕大元"],["Brunei dollar", "文莱元"],["Singapore dollar", "新加坡元|新元"],["Canadian dollar", "加元|加拿大元"],["Cayman Islands dollar", "开曼岛元"],["New Zealand dollar", "新西兰元|纽元"],["Cook Islands dollar", "库克群岛元"],["Fijian dollar", "斐济元|斐币"],["Guyanese dollar", "圭亚那元"],["Hong Kong dollar", "蚊|港元|港圆|港币"],["Macau Pataca", "澳门币|澳门元"],["New Taiwan dollar", "箍|新台币|台币"],["Jamaican dollar", "牙买加元"],["Kiribati dollar", "吉里巴斯元"],["Liberian dollar", "利比里亚元"],["Namibian dollar", "纳米比亚元"],["Surinamese dollar", "苏里南元"],["Trinidad and Tobago dollar", "特立尼达多巴哥元"],["Tuvaluan dollar", "吐瓦鲁元"],["Chinese yuan", "人民币|人民币元|元人民币|块钱|块|元|圆"],["Fen", "分钱|分"],["Jiao", "毛钱|毛|角钱|角"],["Finnish markka", "芬兰马克"],["Penni", "盆尼"],["Bitcoin", "₿|btc|xbt|个比特币|比特币"]]); - export const CurrencyNameToIsoCodeMap: ReadonlyMap = new Map([["Afghan afghani", "AFN"],["Euro", "EUR"],["Albanian lek", "ALL"],["Angolan kwanza", "AOA"],["Armenian dram", "AMD"],["Aruban florin", "AWG"],["Bangladeshi taka", "BDT"],["Bhutanese ngultrum", "BTN"],["Bolivian boliviano", "BOB"],["Bosnia and Herzegovina convertible mark", "BAM"],["Botswana pula", "BWP"],["Brazilian real", "BRL"],["Bulgarian lev", "BGN"],["Cambodian riel", "KHR"],["Cape Verdean escudo", "CVE"],["Costa Rican colón", "CRC"],["Croatian kuna", "HRK"],["Czech koruna", "CZK"],["Eritrean nakfa", "ERN"],["Ethiopian birr", "ETB"],["Gambian dalasi", "GMD"],["Georgian lari", "GEL"],["Ghanaian cedi", "GHS"],["Guatemalan quetzal", "GTQ"],["Haitian gourde", "HTG"],["Honduran lempira", "HNL"],["Hungarian forint", "HUF"],["Iranian rial", "IRR"],["Yemeni rial", "YER"],["Israeli new shekel", "ILS"],["Japanese yen", "JPY"],["Kazakhstani tenge", "KZT"],["Kenyan shilling", "KES"],["North Korean won", "KPW"],["South Korean won", "KRW"],["Kyrgyzstani som", "KGS"],["Lao kip", "LAK"],["Lesotho loti", "LSL"],["South African rand", "ZAR"],["Macanese pataca", "MOP"],["Macedonian denar", "MKD"],["Malagasy ariary", "MGA"],["Malawian kwacha", "MWK"],["Malaysian ringgit", "MYR"],["Mauritanian ouguiya", "MRO"],["Mongolian tögrög", "MNT"],["Mozambican metical", "MZN"],["Burmese kyat", "MMK"],["Nicaraguan córdoba", "NIO"],["Nigerian naira", "NGN"],["Turkish lira", "TRY"],["Omani rial", "OMR"],["Panamanian balboa", "PAB"],["Papua New Guinean kina", "PGK"],["Paraguayan guaraní", "PYG"],["Peruvian sol", "PEN"],["Polish złoty", "PLN"],["Qatari riyal", "QAR"],["Saudi riyal", "SAR"],["Samoan tālā", "WST"],["São Tomé and Príncipe dobra", "STD"],["Sierra Leonean leone", "SLL"],["Swazi lilangeni", "SZL"],["Tajikistani somoni", "TJS"],["Thai baht", "THB"],["Ukrainian hryvnia", "UAH"],["Vanuatu vatu", "VUV"],["Venezuelan bolívar", "VEF"],["Zambian kwacha", "ZMW"],["Moroccan dirham", "MAD"],["United Arab Emirates dirham", "AED"],["Azerbaijani manat", "AZN"],["Turkmenistan manat", "TMT"],["Somali shilling", "SOS"],["Tanzanian shilling", "TZS"],["Ugandan shilling", "UGX"],["Romanian leu", "RON"],["Moldovan leu", "MDL"],["Nepalese rupee", "NPR"],["Pakistani rupee", "PKR"],["Indian rupee", "INR"],["Seychellois rupee", "SCR"],["Mauritian rupee", "MUR"],["Maldivian rufiyaa", "MVR"],["Sri Lankan rupee", "LKR"],["Indonesian rupiah", "IDR"],["Danish krone", "DKK"],["Norwegian krone", "NOK"],["Icelandic króna", "ISK"],["Swedish krona", "SEK"],["West African CFA franc", "XOF"],["Central African CFA franc", "XAF"],["Comorian franc", "KMF"],["Congolese franc", "CDF"],["Burundian franc", "BIF"],["Djiboutian franc", "DJF"],["CFP franc", "XPF"],["Guinean franc", "GNF"],["Swiss franc", "CHF"],["Rwandan franc", "RWF"],["Russian ruble", "RUB"],["Transnistrian ruble", "PRB"],["Belarusian ruble", "BYN"],["Algerian dinar", "DZD"],["Bahraini dinar", "BHD"],["Iraqi dinar", "IQD"],["Jordanian dinar", "JOD"],["Kuwaiti dinar", "KWD"],["Libyan dinar", "LYD"],["Serbian dinar", "RSD"],["Tunisian dinar", "TND"],["Argentine peso", "ARS"],["Chilean peso", "CLP"],["Colombian peso", "COP"],["Cuban convertible peso", "CUC"],["Cuban peso", "CUP"],["Dominican peso", "DOP"],["Mexican peso", "MXN"],["Uruguayan peso", "UYU"],["British pound", "GBP"],["Saint Helena pound", "SHP"],["Egyptian pound", "EGP"],["Falkland Islands pound", "FKP"],["Gibraltar pound", "GIP"],["Manx pound", "IMP"],["Jersey pound", "JEP"],["Lebanese pound", "LBP"],["South Sudanese pound", "SSP"],["Sudanese pound", "SDG"],["Syrian pound", "SYP"],["United States dollar", "USD"],["Australian dollar", "AUD"],["Bahamian dollar", "BSD"],["Barbadian dollar", "BBD"],["Belize dollar", "BZD"],["Bermudian dollar", "BMD"],["Brunei dollar", "BND"],["Singapore dollar", "SGD"],["Canadian dollar", "CAD"],["Cayman Islands dollar", "KYD"],["New Zealand dollar", "NZD"],["Fijian dollar", "FJD"],["Guyanese dollar", "GYD"],["Hong Kong dollar", "HKD"],["Jamaican dollar", "JMD"],["Liberian dollar", "LRD"],["Namibian dollar", "NAD"],["Solomon Islands dollar", "SBD"],["Surinamese dollar", "SRD"],["New Taiwan dollar", "TWD"],["Trinidad and Tobago dollar", "TTD"],["Tuvaluan dollar", "TVD"],["Chinese yuan", "CNY"],["Rial", "__RI"],["Shiling", "__S"],["Som", "__SO"],["Dirham", "__DR"],["Dinar", "_DN"],["Dollar", "__D"],["Manat", "__MA"],["Rupee", "__R"],["Krone", "__K"],["Krona", "__K"],["Crown", "__K"],["Frank", "__F"],["Mark", "__M"],["Ruble", "__RB"],["Peso", "__PE"],["Pound", "__P"],["Tristan da Cunha pound", "_TP"],["South Georgia and the South Sandwich Islands pound", "_SP"],["Somaliland shilling", "_SS"],["Pitcairn Islands dollar", "_PND"],["Palauan dollar", "_PD"],["Niue dollar", "_NID"],["Nauruan dollar", "_ND"],["Micronesian dollar", "_MD"],["Kiribati dollar", "_KID"],["Guernsey pound", "_GGP"],["Faroese króna", "_FOK"],["Cook Islands dollar", "_CKD"],["British Virgin Islands dollar", "_BD"],["Ascension pound", "_AP"],["Alderney pound", "_ALP"],["Abkhazian apsar", "_AA"]]); - export const FractionalUnitNameToCodeMap: ReadonlyMap = new Map([["Jiao", "JIAO"],["Kopek", "KOPEK"],["Pul", "PUL"],["Cent", "CENT"],["Qindarkë", "QINDARKE"],["Penny", "PENNY"],["Santeem", "SANTEEM"],["Cêntimo", "CENTIMO"],["Centavo", "CENTAVO"],["Luma", "LUMA"],["Qəpik", "QƏPIK"],["Fils", "FILS"],["Poisha", "POISHA"],["Kapyeyka", "KAPYEYKA"],["Centime", "CENTIME"],["Chetrum", "CHETRUM"],["Paisa", "PAISA"],["Fening", "FENING"],["Thebe", "THEBE"],["Sen", "SEN"],["Stotinka", "STOTINKA"],["Fen", "FEN"],["Céntimo", "CENTIMO"],["Lipa", "LIPA"],["Haléř", "HALER"],["Øre", "ØRE"],["Piastre", "PIASTRE"],["Santim", "SANTIM"],["Oyra", "OYRA"],["Butut", "BUTUT"],["Tetri", "TETRI"],["Pesewa", "PESEWA"],["Fillér", "FILLER"],["Eyrir", "EYRIR"],["Dinar", "DINAR"],["Agora", "AGORA"],["Tïın", "TIIN"],["Chon", "CHON"],["Jeon", "JEON"],["Tyiyn", "TYIYN"],["Att", "ATT"],["Sente", "SENTE"],["Dirham", "DIRHAM"],["Rappen", "RAPPEN"],["Avo", "AVO"],["Deni", "DENI"],["Iraimbilanja", "IRAIMBILANJA"],["Tambala", "TAMBALA"],["Laari", "LAARI"],["Khoums", "KHOUMS"],["Ban", "BAN"],["Möngö", "MONGO"],["Pya", "PYA"],["Kobo", "KOBO"],["Kuruş", "KURUS"],["Baisa", "BAISA"],["Centésimo", "CENTESIMO"],["Toea", "TOEA"],["Sentimo", "SENTIMO"],["Grosz", "GROSZ"],["Sene", "SENE"],["Halala", "HALALA"],["Para", "PARA"],["Öre", "ORE"],["Diram", "DIRAM"],["Satang", "SATANG"],["Seniti", "SENITI"],["Millime", "MILLIME"],["Tennesi", "TENNESI"],["Kopiyka", "KOPIYKA"],["Tiyin", "TIYIN"],["Hào", "HAO"],["Ngwee", "NGWEE"]]); - export const CompoundUnitConnectorRegex = `(?又|再)`; - export const CurrencyPrefixList: ReadonlyMap = new Map([["Dollar", "$"],["United States dollar", "us$"],["British Virgin Islands dollar", "bvi$"],["Brunei dollar", "b$"],["Sen", "sen"],["Singapore dollar", "s$"],["Canadian dollar", "can$|c$|c $"],["Cayman Islands dollar", "ci$"],["New Zealand dollar", "nz$|nz $"],["Guyanese dollar", "gy$|gy $|g$|g $"],["Hong Kong dollar", "hk$|hkd|hk $"],["Jamaican dollar", "j$"],["Namibian dollar", "nad|n$|n $"],["Solomon Islands dollar", "si$|si $"],["New Taiwan dollar", "nt$|nt $"],["Samoan tālā", "ws$"],["Chinese yuan", "¥"],["Japanese yen", "¥"],["Turkish lira", "₺"],["Euro", "€"],["Pound", "£"],["Costa Rican colón", "₡"],["Bitcoin", "₿|btc|xbt"]]); - export const CurrencyAmbiguousValues = [ "元","仙","分","圆","块","毛","盾","箍","蚊","角" ]; - export const DimensionSuffixList: ReadonlyMap = new Map([["Meter", "米|公尺|m"],["Kilometer", "千米|公里|km"],["Decimeter", "分米|公寸|dm"],["Centimeter", "釐米|厘米|公分|cm"],["Micrometer", "毫米|公釐|mm"],["Microns", "微米"],["Picometer", "皮米"],["Nanometer", "纳米"],["Li", "里|市里"],["Zhang", "丈"],["Chi", "市尺|尺"],["Cun", "市寸|寸"],["Fen", "市分|分"],["Hao", "毫"],["Mile", "英里"],["Inch", "英寸"],["Foot", "呎|英尺"],["Yard", "码"],["Knot", "海里"],["Light year", "光年"],["Meter per second", "米每秒|米/秒|m/s"],["Kilometer per hour", "公里每小时|千米每小时|公里/小时|千米/小时|km/h"],["Kilometer per minute", "公里每分钟|千米每分钟|公里/分钟|千米/分钟|km/min"],["Kilometer per second", "公里每秒|千米每秒|公里/秒|千米/秒|km/s"],["Mile per hour", "英里每小时|英里/小时"],["Foot per second", "英尺每小时|英尺/小时"],["Foot per minute", "英尺每分钟|英尺/分钟"],["Yard per minute", "码每分|码/分"],["Yard per second", "码每秒|码/秒"],["Square centimetre", "平方厘米"],["Square decimeter", "平方分米"],["Square meter", "平方米"],["Square kilometer", "平方公里"],["Acre", "英亩|公亩"],["Hectare", "公顷"],["Mu", "亩|市亩"],["Liter", "公升|升|l"],["Milliliter", "毫升|ml"],["Cubic meter", "立方米"],["Cubic decimeter", "立方分米"],["Cubic millimeter", "立方毫米"],["Cubic feet", "立方英尺"],["Gallon", "加仑"],["Pint", "品脱"],["Dou", "市斗|斗"],["Dan", "市石|石"],["Kilogram", "千克|公斤|kg"],["Gram", "克|g"],["Milligram", "毫克|mg"],["Microgram", "微克|μg"],["Ton", "公吨|吨|t"],["Pound", "磅"],["Ounce", "盎司"],["Jin", "市斤|斤"],["Liang", "两"],["Barrel", "桶"],["Pot", "罐"],["Bit", "比特|位|b|bit"],["Kilobit", "千比特|千位|kb|Kb"],["Megabit", "兆比特|兆位|mb|Mb"],["Gigabit", "十亿比特|千兆比特|十亿位|千兆位|gb|Gb"],["Terabit", "万亿比特|兆兆比特|万亿位|兆兆位|tb|Tb"],["Petabit", "千兆兆比特|千万亿比特|千兆兆位|千万亿位|pb|Pb"],["Byte", "字节|byte|Byte"],["Kilobyte", "千字节|kB|KB"],["Megabyte", "兆字节|mB|MB"],["Gigabyte", "十亿字节|千兆字节|gB|GB"],["Terabyte", "万亿字节|兆兆字节|tB|TB"],["Petabyte", "千兆兆字节|千万亿字节|pB|PB"]]); - export const DimensionAmbiguousValues = [ "丈","位","克","分","升","寸","尺","斗","斤","桶","毫","石","码","磅","米","罐","里","m","km","dm","cm","mm","l","ml","kg","mg","g","t","b","byte","kb","mb","gb","tb","pb" ]; - export const AmbiguityFiltersDict: ReadonlyMap = new Map([["五角", "五角大楼"],["普尔", "标准普尔"]]); - export const TemperatureSuffixList: ReadonlyMap = new Map([["F", "华氏温度|华氏度|°f"],["K", "开尔文温度|开氏度|凯氏度|K|k"],["R", "兰氏温度|°r"],["C", "摄氏温度|摄氏度|°c"],["Degree", "度"]]); - export const TemperaturePrefixList: ReadonlyMap = new Map([["F", "华氏温度|华氏"],["K", "开氏温度|开氏"],["R", "兰氏温度|兰氏"],["C", "摄氏温度|摄氏"]]); - export const TemperatureAmbiguousValues = [ "度","k" ]; - export const HalfUnitRegex = `半`; -} diff --git a/JavaScript/packages/recognizers-number-with-unit/src/resources/englishNumericWithUnit.ts b/JavaScript/packages/recognizers-number-with-unit/src/resources/englishNumericWithUnit.ts deleted file mode 100644 index 4d0a118b96..0000000000 --- a/JavaScript/packages/recognizers-number-with-unit/src/resources/englishNumericWithUnit.ts +++ /dev/null @@ -1,45 +0,0 @@ -// ------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// ------------------------------------------------------------------------------ - -import { BaseNumbers } from "./baseNumbers"; -export namespace EnglishNumericWithUnit { - export const AgePrefixList: ReadonlyMap = new Map([["Age", "Age|age"]]); - export const AgeSuffixList: ReadonlyMap = new Map([["Year", "years old|year old|year-old|years-old|-year-old|-years-old|years of age|year of age|yo"],["Month", "months old|month old|month-old|months-old|-month-old|-months-old|month of age|months of age|mo"],["Week", "weeks old|week old|week-old|weeks-old|-week-old|-weeks-old|week of age|weeks of age"],["Day", "days old|day old|day-old|days-old|-day-old|-days-old|day of age|days of age"]]); - export const AmbiguousAgeUnitList = [ "yo","mo" ]; - export const AreaSuffixList: ReadonlyMap = new Map([["Square kilometer", "sq km|sq kilometer|sq kilometre|sq kilometers|sq kilometres|square kilometer|square kilometre|square kilometers|square kilometres|km2|km^2|km²"],["Square hectometer", "sq hm|sq hectometer|sq hectometre|sq hectometers|sq hectometres|square hectometer|square hectometre|square hectometers|square hectometres|hm2|hm^2|hm²|hectare|hectares"],["Square decameter", "sq dam|sq decameter|sq decametre|sq decameters|sq decametres|square decameter|square decametre|square decameters|square decametres|sq dekameter|sq dekametre|sq dekameters|sq dekametres|square dekameter|square dekametre|square dekameters|square dekametres|dam2|dam^2|dam²"],["Square meter", "sq m|sq meter|sq metre|sq meters|sq metres|sq metre|square meter|square meters|square metre|square metres|m2|m^2|m²"],["Square decimeter", "sq dm|sq decimeter|sq decimetre|sq decimeters|sq decimetres|square decimeter|square decimetre|square decimeters|square decimetres|dm2|dm^2|dm²"],["Square centimeter", "sq cm|sq centimeter|sq centimetre|sq centimeters|sq centimetres|square centimeter|square centimetre|square centimeters|square centimetres|cm2|cm^2|cm²"],["Square millimeter", "sq mm|sq millimeter|sq millimetre|sq millimeters|sq millimetres|square millimeter|square millimetre|square millimeters|square millimetres|mm2|mm^2|mm²"],["Square inch", "sq in|sq inch|square inch|square inches|in2|in^2|in²"],["Square foot", "sqft|sq ft|sq foot|sq feet|square foot|square feet|feet2|feet^2|feet²|ft2|ft^2|ft²"],["Square mile", "sq mi|sq mile|sqmiles|square mile|square miles|mi2|mi^2|mi²"],["Square yard", "sq yd|sq yard|sq yards|square yard|square yards|yd2|yd^2|yd²"],["Acre", "-acre|acre|acres"]]); - export const AmbiguousAreaUnitList = [ "n/a" ]; - export const CurrencySuffixList: ReadonlyMap = new Map([["Abkhazian apsar", "abkhazian apsar|apsars"],["Afghan afghani", "afghan afghani|؋|afn|afghanis|afghani"],["Pul", "pul"],["Euro", "euros|euro|€|eur"],["Cent", "cents|cent|-cents|-cent"],["Albanian lek", "albanian lek|leks|lek"],["Qindarkë", "qindarkë|qindarkës|qindarke|qindarkes"],["Angolan kwanza", "angolan kwanza|kz|aoa|kwanza|kwanzas|angolan kwanzas"],["Armenian dram", "armenian drams|armenian dram"],["Aruban florin", "aruban florin|ƒ|awg|aruban florins"],["Bangladeshi taka", "bangladeshi taka|৳|bdt|taka|takas|bangladeshi takas"],["Paisa", "poisha|paisa"],["Bhutanese ngultrum", "bhutanese ngultrum|nu.|btn"],["Chetrum", "chetrums|chetrum"],["Bolivian boliviano", "bolivian boliviano|bob|bs.|bolivia boliviano|bolivia bolivianos|bolivian bolivianos"],["Bosnia and Herzegovina convertible mark", "bosnia and herzegovina convertible mark|bam"],["Fening", "fenings|fenings"],["Botswana pula", "botswana pula|bwp|pula|pulas|botswana pulas"],["Thebe", "thebe"],["Brazilian real", "brazilian real|r$|brl|brazil real|brazil reals|brazilian reals"],["Bulgarian lev", "bulgarian lev|bgn|лв|bulgaria lev|bulgaria levs|bulgarian levs"],["Stotinka", "stotinki|stotinka"],["Cambodian riel", "cambodian riel|khr|៛|cambodia riel|cambodia riels|cambodian riels"],["Cape Verdean escudo", "cape verdean escudo|cve"],["Costa Rican colón", "costa rican colón|costa rican colóns|crc|₡|costa rica colón|costa rica colóns|costa rican colon|costa rican colons|costa rica colon|costa rica colons"],["Salvadoran colón", "svc|salvadoran colón|salvadoran colóns|salvador colón|salvador colóns|salvadoran colon|salvadoran colons|salvador colon|salvador colons"],["Céntimo", "céntimo"],["Croatian kuna", "croatian kuna|kn|hrk|croatia kuna|croatian kunas|croatian kuna kunas"],["Lipa", "lipa"],["Czech koruna", "czech koruna|czk|kč|czech korunas"],["Haléř", "haléř"],["Eritrean nakfa", "eritrean nakfa|nfk|ern|eritrean nakfas"],["Ethiopian birr", "ethiopian birr|etb"],["Gambian dalasi", "gmd"],["Butut", "bututs|butut"],["Georgian lari", "georgian lari|lari|gel|₾"],["Tetri", "tetri"],["Ghanaian cedi", "ghanaian cedi|ghs|₵|gh₵"],["Pesewa", "pesewas|pesewa"],["Guatemalan quetzal", "guatemalan quetzal|gtq|guatemala quetzal"],["Haitian gourde", "haitian gourde|htg"],["Honduran lempira", "honduran lempira|hnl"],["Hungarian forint", "hungarian forint|huf|ft|hungary forint|hungary forints|hungarian forints"],["Fillér", "fillér"],["Iranian rial", "iranian rial|irr|iran rial|iran rials|iranian rials"],["Yemeni rial", "yemeni rial|yer|yemeni rials"],["Israeli new shekel", "₪|ils|agora"],["Lithuanian litas", "ltl|lithuanian litas|lithuan litas|lithuanian lit|lithuan lit"],["Japanese yen", "japanese yen|jpy|yen|-yen|¥|yens|japanese yens|japan yen|japan yens"],["Kazakhstani tenge", "kazakhstani tenge|kazakh tenge|kazak tenge|kzt"],["Kenyan shilling", "kenyan shilling|kes"],["North Korean won", "north korean won|kpw|north korean wons"],["South Korean won", "south korean won|krw|south korean wons"],["Korean won", "korean won|₩|korean wons"],["Kyrgyzstani som", "kyrgyzstani som|kgs"],["Uzbekitan som", "uzbekitan som|uzs"],["Lao kip", "lao kip|lak|₭n|₭"],["Att", "att"],["Lesotho loti", "lesotho loti|lsl|loti"],["Sente", "sente|lisente"],["South African rand", "south african rand|zar|south africa rand|south africa rands|south african rands"],["Macanese pataca", "macanese pataca|mop$|mop"],["Avo", "avos|avo"],["Macedonian denar", "macedonian denar|mkd|ден"],["Deni", "deni"],["Malagasy ariary", "malagasy ariary|mga"],["Iraimbilanja", "iraimbilanja"],["Malawian kwacha", "malawian kwacha|mk|mwk"],["Tambala", "tambala"],["Malaysian ringgit", "malaysian ringgit|rm|myr|malaysia ringgit|malaysia ringgits|malaysian ringgits"],["Mauritanian ouguiya", "mauritanian ouguiya|um|mro|mauritania ouguiya|mauritania ouguiyas|mauritanian ouguiyas"],["Khoums", "khoums"],["Mongolian tögrög", "mongolian tögrög|mnt|₮|mongolia tögrög|mongolia tögrögs|mongolian tögrögs|mongolian togrog|mongolian togrogs|mongolia togrog|mongolia togrogs"],["Mozambican metical", "mozambican metical|mt|mzn|mozambica metical|mozambica meticals|mozambican meticals"],["Burmese kyat", "burmese kyat|ks|mmk"],["Pya", "pya"],["Nicaraguan córdoba", "nicaraguan córdoba|nio"],["Nigerian naira", "nigerian naira|naira|ngn|₦|nigeria naira|nigeria nairas|nigerian nairas"],["Kobo", "kobo"],["Turkish lira", "turkish lira|try|tl|turkey lira|turkey liras|turkish liras"],["Kuruş", "kuruş"],["Omani rial", "omani rial|omr|ر.ع."],["Panamanian balboa", "panamanian balboa|b/.|pab"],["Centesimo", "centesimo"],["Papua New Guinean kina", "papua new guinean kina|kina|pgk"],["Toea", "toea"],["Paraguayan guaraní", "paraguayan guaraní|₲|pyg"],["Peruvian sol", "peruvian sol|soles|sol|peruvian nuevo sol"],["Polish złoty", "złoty|polish złoty|zł|pln|zloty|polish zloty|poland zloty|poland złoty"],["Grosz", "groszy|grosz|grosze"],["Qatari riyal", "qatari riyal|qar|qatari riyals|qatar riyal|qatar riyals"],["Saudi riyal", "saudi riyal|sar|saudi riyals"],["Riyal", "riyal|riyals|rial|﷼"],["Dirham", "dirham|dirhem|dirhm"],["Halala", "halalas|halala"],["Samoan tālā", "samoan tālā|tālā|tala|ws$|samoa|wst|samoan tala"],["Sene", "sene"],["São Tomé and Príncipe dobra", "são tomé and príncipe dobra|dobras|dobra"],["Sierra Leonean leone", "sierra leonean leone|sll|leone|le"],["Peseta", "pesetas|peseta"],["Netherlands guilder", "florin|netherlands antillean guilder|ang|nederlandse gulden|guilders|guilder|gulden|-guilders|-guilder|dutch guilders|dutch guilder|fl"],["Swazi lilangeni", "swazi lilangeni|lilangeni|szl|emalangeni"],["Tajikistani somoni", "tajikistani somoni|tjs|somoni"],["Diram", "dirams|diram"],["Thai baht", "thai baht|฿|thb|baht"],["Satang", "satang|satangs"],["Tongan paʻanga", "tongan paʻanga|paʻanga|tongan pa'anga|pa'anga"],["Seniti", "seniti"],["Ukrainian hryvnia", "ukrainian hryvnia|hyrvnia|uah|₴|ukrain hryvnia|ukrain hryvnias|ukrainian hryvnias"],["Vanuatu vatu", "vanuatu vatu|vatu|vuv"],["Venezuelan bolívar", "venezuelan bolívar|venezuelan bolívars|bs.f.|vef|bolívar fuerte|venezuelan bolivar|venezuelan bolivars|venezuela bolivar|venezuela bolivarsvenezuelan bolivar|venezuelan bolivars"],["Vietnamese dong", "vietnamese dong|vnd|đồng|vietnam dong|vietnamese dongs|vietnam dongs"],["Zambian kwacha", "zambian kwacha|zk|zmw|zambia kwacha|kwachas|zambian kwachas"],["Moroccan dirham", "moroccan dirham|mad|د.م."],["United Arab Emirates dirham", "united arab emirates dirham|د.إ|aed"],["Azerbaijani manat", "azerbaijani manat|azn"],["Turkmenistan manat", "turkmenistan manat|turkmenistan new manat|tmt"],["Manat", "manats|manat"],["Qəpik", "qəpik"],["Somali shilling", "somali shillings|somali shilling|shilin soomaali|-shilin soomaali|scellino|shilin|sh.so.|sos"],["Somaliland shilling", "somaliland shillings|somaliland shilling|soomaaliland shilin"],["Tanzanian shilling", "tanzanian shilling|tanzanian shillings|tsh|tzs|tanzania shilling|tanzania shillings"],["Ugandan shilling", "ugandan shilling|ugandan shillings|ugx|uganda shilling|uganda shillings"],["Romanian leu", "romanian leu|lei|ron|romania leu"],["Moldovan leu", "moldovan leu|mdl|moldova leu"],["Leu", "leu"],["Ban", "bani|-ban|ban"],["Nepalese rupee", "nepalese rupees|nepalese rupee|npr"],["Pakistani rupee", "pakistani rupees|pakistani rupee|pkr"],["Indian rupee", "indian rupees|indian rupee|inr|₹|india rupees|india rupee"],["Seychellois rupee", "seychellois rupees|seychellois rupee|scr|sr|sre"],["Mauritian rupee", "mauritian rupees|mauritian rupee|mur"],["Maldivian rufiyaa", "maldivian rufiyaas|maldivian rufiyaa|mvr|.ރ|maldive rufiyaas|maldive rufiyaa"],["Sri Lankan rupee", "sri lankan rupees|sri lankan rupee|lkr|රු|ரூ"],["Indonesian rupiah", "indonesian rupiah|rupiah|perak|rp|idr"],["Rupee", "rupee|rupees|rs"],["Danish krone", "danish krone|dkk|denmark krone|denmark krones|danish krones"],["Norwegian krone", "norwegian krone|nok|norway krone|norway krones|norwegian krones"],["Faroese króna", "faroese króna|faroese krona"],["Icelandic króna", "icelandic króna|isk|icelandic krona|iceland króna|iceland krona"],["Swedish krona", "swedish krona|sek|swedan krona"],["Krone", "kronor|krona|króna|krone|krones|kr|-kr"],["Øre", "Øre|oyra|eyrir"],["West African CFA franc", "west african cfa franc|xof|west africa cfa franc|west africa franc|west african franc"],["Central African CFA franc", "central african cfa franc|xaf|central africa cfa franc|central african franc|central africa franc"],["Comorian franc", "comorian franc|kmf"],["Congolese franc", "congolese franc|cdf"],["Burundian franc", "burundian franc|bif"],["Djiboutian franc", "djiboutian franc|djf"],["CFP franc", "cfp franc|xpf"],["Guinean franc", "guinean franc|gnf"],["Swiss franc", "swiss francs|swiss franc|chf|sfr."],["Rwandan franc", "Rwandan franc|rwf|rf|r₣|frw"],["Belgian franc", "belgian franc|bi.|b.fr.|bef|belgium franc"],["Rappen", "rappen|-rappen"],["Franc", "francs|franc|fr.|fs"],["Centime", "centimes|centime|santim"],["Russian ruble", "russian ruble|₽|rub|russia ruble|russia ₽|russian ₽|russian rubles|russia rubles"],["New Belarusian ruble", "new belarusian ruble|byn|new belarus ruble|new belarus rubles|new belarusian rubles"],["Old Belarusian ruble", "old belarusian ruble|byr|old belarus ruble|old belarus rubles|old belarusian rubles"],["Transnistrian ruble", "transnistrian ruble|prb|р."],["Belarusian ruble", "belarusian ruble|belarus ruble|belarus rubles|belarusian rubles"],["Kopek", "kopek|kopeks"],["Kapyeyka", "kapyeyka"],["Ruble", "rubles|ruble|br"],["Algerian dinar", "algerian dinar|د.ج|dzd|algerian dinars|algeria dinar|algeria dinars"],["Bahraini dinar", "bahraini dinars|bahraini dinar|bhd|.د.ب"],["Santeem", "santeem|santeems"],["Iraqi dinar", "iraqi dinars|iraqi dinar|iraq dinars|iraq dinar|iqd|ع.د"],["Jordanian dinar", "jordanian dinars|jordanian dinar|د.ا|jod|jordan dinar|jordan dinars"],["Kuwaiti dinar", "kuwaiti dinars|kuwaiti dinar|kwd|د.ك"],["Libyan dinar", "libyan dinars|libyan dinar|libya dinars|libya dinar|lyd"],["Serbian dinar", "serbian dinars|serbian dinar|din.|rsd|дин.|serbia dinars|serbia dinar"],["Tunisian dinar", "tunisian dinars|tunisian dinar|tnd|tunisia dinars|tunisia dinar"],["Yugoslav dinar", "yugoslav dinars|yugoslav dinar|yun"],["Dinar", "dinars|dinar|denar|-dinars|-dinar"],["Fils", "fils|fulūs|-fils|-fil"],["Para", "para|napa"],["Millime", "millimes|millime"],["Argentine peso", "argentine peso|ars|argetina peso|argetina pesos|argentine pesos"],["Chilean peso", "chilean pesos|chilean peso|clp|chile peso|chile peso"],["Colombian peso", "colombian pesos|colombian peso|cop|colombia peso|colombia pesos"],["Cuban convertible peso", "cuban convertible pesos|cuban convertible peso|cuc|cuba convertible pesos|cuba convertible peso"],["Cuban peso", "cuban pesos|cuban peso|cup|cuba pesos|cuba peso"],["Dominican peso", "dominican pesos|dominican peso|dop|dominica pesos|dominica peso"],["Mexican peso", "mexican pesos|mexican peso|mxn|mexico pesos|mexico peso|mxn$|mxn $|mex$"],["Philippine peso", "piso|philippine pesos|philippine peso|₱|php"],["Uruguayan peso", "uruguayan pesos|uruguayan peso|uyu"],["Peso", "pesos|peso"],["Centavo", "centavos|centavo"],["Alderney pound", "alderney pounds|alderney pound|alderney £"],["British pound", "british pounds|british pound|british £|gbp|pound sterling|pound sterlings|sterling|pound scot|pound scots"],["Guernsey pound", "guernsey pounds|guernsey £|ggp"],["Ascension pound", "ascension pounds|ascension pound|ascension £"],["Saint Helena pound", "saint helena pounds|saint helena pound|saint helena £|shp"],["Egyptian pound", "egyptian pounds|egyptian pound|egyptian £|egp|ج.م|egypt pounds|egypt pound"],["Falkland Islands pound", "falkland islands pounds|falkland islands pound|falkland islands £|fkp|falkland island pounds|falkland island pound|falkland island £"],["Gibraltar pound", "gibraltar pounds|gibraltar pound|gibraltar £|gip"],["Manx pound", "manx pounds|manx pound|manx £|imp"],["Jersey pound", "jersey pounds|jersey pound|jersey £|jep"],["Lebanese pound", "lebanese pounds|lebanese pound|lebanese £|lebanan pounds|lebanan pound|lebanan £|lbp|ل.ل"],["South Georgia and the South Sandwich Islands pound", "south georgia and the south sandwich islands pounds|south georgia and the south sandwich islands pound|south georgia and the south sandwich islands £"],["South Sudanese pound", "south sudanese pounds|south sudanese pound|south sudanese £|ssp|south sudan pounds|south sudan pound|south sudan £"],["Sudanese pound", "sudanese pounds|sudanese pound|sudanese £|ج.س.|sdg|sudan pounds|sudan pound|sudan £"],["Syrian pound", "syrian pounds|syrian pound|syrian £|ل.س|syp|syria pounds|syria pound|syria £"],["Tristan da Cunha pound", "tristan da cunha pounds|tristan da cunha pound|tristan da cunha £"],["Pound", "pounds|pound|-pounds|-pound|£"],["Pence", "pence"],["Shilling", "shillings|shilling|shilingi|sh"],["Penny", "pennies|penny"],["United States dollar", "united states dollars|united states dollar|united states $|u.s. dollars|u.s. dollar|u s dollar|u s dollars|usd|american dollars|american dollar|us$|us dollar|us dollars|u.s dollar|u.s dollars|usd$"],["East Caribbean dollar", "east caribbean dollars|east caribbean dollar|east Caribbean $|xcd"],["Australian dollar", "australian dollars|australian dollar|australian $|australian$|aud|australia dollars|australia dollar|australia $|australia$"],["Bahamian dollar", "bahamian dollars|bahamian dollar|bahamian $|bahamian$|bsd|bahamia dollars|bahamia dollar|bahamia $|bahamia$"],["Barbadian dollar", "barbadian dollars|barbadian dollar|barbadian $|bbd"],["Belize dollar", "belize dollars|belize dollar|belize $|bzd"],["Bermudian dollar", "bermudian dollars|bermudian dollar|bermudian $|bmd|bermudia dollars|bermudia dollar|bermudia $"],["British Virgin Islands dollar", "british virgin islands dollars|british virgin islands dollar|british virgin islands $|bvi$|virgin islands dollars|virgin islands dolalr|virgin islands $|virgin island dollars|virgin island dollar|virgin island $"],["Brunei dollar", "brunei dollar|brunei $|bnd"],["Sen", "sen"],["Singapore dollar", "singapore dollars|singapore dollar|singapore $|s$|sgd"],["Canadian dollar", "canadian dollars|canadian dollar|canadian $|cad|can$|c$|canada dollars|canada dolllar|canada $"],["Cayman Islands dollar", "cayman islands dollars|cayman islands dollar|cayman islands $|kyd|ci$|cayman island dollar|cayman island doolars|cayman island $"],["New Zealand dollar", "new zealand dollars|new zealand dollar|new zealand $|nz$|nzd|kiwi"],["Cook Islands dollar", "cook islands dollars|cook islands dollar|cook islands $|cook island dollars|cook island dollar|cook island $"],["Fijian dollar", "fijian dollars|fijian dollar|fijian $|fjd|fiji dollars|fiji dollar|fiji $"],["Guyanese dollar", "guyanese dollars|guyanese dollar|gyd|gy$"],["Hong Kong dollar", "hong kong dollars|hong kong dollar|hong kong $|hk$|hkd|hk dollars|hk dollar|hk $|hongkong$"],["Jamaican dollar", "jamaican dollars|jamaican dollar|jamaican $|j$|jamaica dollars|jamaica dollar|jamaica $|jmd"],["Kiribati dollar", "kiribati dollars|kiribati dollar|kiribati $"],["Liberian dollar", "liberian dollars|liberian dollar|liberian $|liberia dollars|liberia dollar|liberia $|lrd"],["Micronesian dollar", "micronesian dollars|micronesian dollar|micronesian $"],["Namibian dollar", "namibian dollars|namibian dollar|namibian $|nad|n$|namibia dollars|namibia dollar|namibia $"],["Nauruan dollar", "nauruan dollars|nauruan dollar|nauruan $"],["Niue dollar", "niue dollars|niue dollar|niue $"],["Palauan dollar", "palauan dollars|palauan dollar|palauan $"],["Pitcairn Islands dollar", "pitcairn islands dollars|pitcairn islands dollar|pitcairn islands $|pitcairn island dollars|pitcairn island dollar|pitcairn island $"],["Solomon Islands dollar", "solomon islands dollars|solomon islands dollar|solomon islands $|si$|sbd|solomon island dollars|solomon island dollar|solomon island $"],["Surinamese dollar", "surinamese dollars|surinamese dollar|surinamese $|srd"],["New Taiwan dollar", "new taiwan dollars|new taiwan dollar|nt$|twd|ntd"],["Trinidad and Tobago dollar", "trinidad and tobago dollars|trinidad and tobago dollar|trinidad and tobago $|trinidad $|trinidad dollar|trinidad dollars|trinidadian dollar|trinidadian dollars|trinidadian $|ttd"],["Tuvaluan dollar", "tuvaluan dollars|tuvaluan dollar|tuvaluan $"],["Dollar", "dollars|dollar|$"],["Chinese yuan", "yuan|kuai|chinese yuan|renminbi|cny|rmb|¥|元"],["Fen", "fen"],["Jiao", "jiao|mao"],["Finnish markka", "suomen markka|finnish markka|finsk mark|fim|markkaa|markka"],["Penni", "penniä|penni"],["Bitcoin", "bitcoin|bitcoins|btc|xbt|₿"],["Millibitcoin", "millibitcoin|millibitcoins|milibitcoin|milibitcoins"],["Satoshi", "satoshi|satoshis"]]); - export const CurrencyNameToIsoCodeMap: ReadonlyMap = new Map([["Afghan afghani", "AFN"],["Euro", "EUR"],["Albanian lek", "ALL"],["Angolan kwanza", "AOA"],["Armenian dram", "AMD"],["Aruban florin", "AWG"],["Bangladeshi taka", "BDT"],["Bhutanese ngultrum", "BTN"],["Bolivian boliviano", "BOB"],["Bosnia and Herzegovina convertible mark", "BAM"],["Botswana pula", "BWP"],["Brazilian real", "BRL"],["Bulgarian lev", "BGN"],["Cambodian riel", "KHR"],["Cape Verdean escudo", "CVE"],["Costa Rican colón", "CRC"],["Croatian kuna", "HRK"],["Czech koruna", "CZK"],["Eritrean nakfa", "ERN"],["Ethiopian birr", "ETB"],["Gambian dalasi", "GMD"],["Georgian lari", "GEL"],["Ghanaian cedi", "GHS"],["Guatemalan quetzal", "GTQ"],["Haitian gourde", "HTG"],["Honduran lempira", "HNL"],["Hungarian forint", "HUF"],["Iranian rial", "IRR"],["Yemeni rial", "YER"],["Israeli new shekel", "ILS"],["Japanese yen", "JPY"],["Kazakhstani tenge", "KZT"],["Kenyan shilling", "KES"],["North Korean won", "KPW"],["South Korean won", "KRW"],["Kyrgyzstani som", "KGS"],["Lao kip", "LAK"],["Lesotho loti", "LSL"],["South African rand", "ZAR"],["Macanese pataca", "MOP"],["Macedonian denar", "MKD"],["Malagasy ariary", "MGA"],["Malawian kwacha", "MWK"],["Malaysian ringgit", "MYR"],["Mauritanian ouguiya", "MRO"],["Mongolian tögrög", "MNT"],["Mozambican metical", "MZN"],["Burmese kyat", "MMK"],["Nicaraguan córdoba", "NIO"],["Nigerian naira", "NGN"],["Turkish lira", "TRY"],["Omani rial", "OMR"],["Panamanian balboa", "PAB"],["Papua New Guinean kina", "PGK"],["Paraguayan guaraní", "PYG"],["Peruvian sol", "PEN"],["Polish złoty", "PLN"],["Qatari riyal", "QAR"],["Saudi riyal", "SAR"],["Samoan tālā", "WST"],["São Tomé and Príncipe dobra", "STN"],["Sierra Leonean leone", "SLL"],["Swazi lilangeni", "SZL"],["Tajikistani somoni", "TJS"],["Thai baht", "THB"],["Ukrainian hryvnia", "UAH"],["Vanuatu vatu", "VUV"],["Venezuelan bolívar", "VEF"],["Zambian kwacha", "ZMW"],["Moroccan dirham", "MAD"],["United Arab Emirates dirham", "AED"],["Azerbaijani manat", "AZN"],["Turkmenistan manat", "TMT"],["Somali shilling", "SOS"],["Tanzanian shilling", "TZS"],["Ugandan shilling", "UGX"],["Romanian leu", "RON"],["Moldovan leu", "MDL"],["Nepalese rupee", "NPR"],["Pakistani rupee", "PKR"],["Indian rupee", "INR"],["Seychellois rupee", "SCR"],["Mauritian rupee", "MUR"],["Maldivian rufiyaa", "MVR"],["Sri Lankan rupee", "LKR"],["Indonesian rupiah", "IDR"],["Danish krone", "DKK"],["Norwegian krone", "NOK"],["Icelandic króna", "ISK"],["Swedish krona", "SEK"],["West African CFA franc", "XOF"],["Central African CFA franc", "XAF"],["Comorian franc", "KMF"],["Congolese franc", "CDF"],["Burundian franc", "BIF"],["Djiboutian franc", "DJF"],["CFP franc", "XPF"],["Guinean franc", "GNF"],["Swiss franc", "CHF"],["Rwandan franc", "RWF"],["Russian ruble", "RUB"],["Transnistrian ruble", "PRB"],["New Belarusian ruble", "BYN"],["Algerian dinar", "DZD"],["Bahraini dinar", "BHD"],["Iraqi dinar", "IQD"],["Jordanian dinar", "JOD"],["Kuwaiti dinar", "KWD"],["Libyan dinar", "LYD"],["Serbian dinar", "RSD"],["Tunisian dinar", "TND"],["Argentine peso", "ARS"],["Chilean peso", "CLP"],["Colombian peso", "COP"],["Cuban convertible peso", "CUC"],["Cuban peso", "CUP"],["Dominican peso", "DOP"],["Mexican peso", "MXN"],["Uruguayan peso", "UYU"],["British pound", "GBP"],["Saint Helena pound", "SHP"],["Egyptian pound", "EGP"],["Falkland Islands pound", "FKP"],["Gibraltar pound", "GIP"],["Manx pound", "IMP"],["Jersey pound", "JEP"],["Lebanese pound", "LBP"],["South Sudanese pound", "SSP"],["Sudanese pound", "SDG"],["Syrian pound", "SYP"],["United States dollar", "USD"],["Australian dollar", "AUD"],["Bahamian dollar", "BSD"],["Barbadian dollar", "BBD"],["Belize dollar", "BZD"],["Bermudian dollar", "BMD"],["Brunei dollar", "BND"],["Singapore dollar", "SGD"],["Canadian dollar", "CAD"],["Cayman Islands dollar", "KYD"],["New Zealand dollar", "NZD"],["Fijian dollar", "FJD"],["Guyanese dollar", "GYD"],["Hong Kong dollar", "HKD"],["Jamaican dollar", "JMD"],["Liberian dollar", "LRD"],["Namibian dollar", "NAD"],["Solomon Islands dollar", "SBD"],["Surinamese dollar", "SRD"],["New Taiwan dollar", "TWD"],["Trinidad and Tobago dollar", "TTD"],["Tuvaluan dollar", "TVD"],["Chinese yuan", "CNY"],["Rial", "__RI"],["Shiling", "__S"],["Som", "__SO"],["Dirham", "__DR"],["Dinar", "_DN"],["Dollar", "__D"],["Manat", "__MA"],["Rupee", "__R"],["Krone", "__K"],["Krona", "__K"],["Crown", "__K"],["Frank", "__F"],["Mark", "__M"],["Ruble", "__RB"],["Peso", "__PE"],["Pound", "__P"],["Tristan da Cunha pound", "_TP"],["South Georgia and the South Sandwich Islands pound", "_SP"],["Somaliland shilling", "_SS"],["Pitcairn Islands dollar", "_PND"],["Palauan dollar", "_PD"],["Niue dollar", "_NID"],["Nauruan dollar", "_ND"],["Micronesian dollar", "_MD"],["Kiribati dollar", "_KID"],["Guernsey pound", "_GGP"],["Faroese króna", "_FOK"],["Cook Islands dollar", "_CKD"],["British Virgin Islands dollar", "_BD"],["Ascension pound", "_AP"],["Alderney pound", "_ALP"],["Abkhazian apsar", "_AA"],["Bitcoin", "_XBT"]]); - export const FractionalUnitNameToCodeMap: ReadonlyMap = new Map([["Jiao", "JIAO"],["Kopek", "KOPEK"],["Pul", "PUL"],["Cent", "CENT"],["Qindarkë", "QINDARKE"],["Penny", "PENNY"],["Santeem", "SANTEEM"],["Cêntimo", "CENTIMO"],["Centavo", "CENTAVO"],["Luma", "LUMA"],["Qəpik", "QƏPIK"],["Fils", "FILS"],["Poisha", "POISHA"],["Kapyeyka", "KAPYEYKA"],["Centime", "CENTIME"],["Chetrum", "CHETRUM"],["Paisa", "PAISA"],["Fening", "FENING"],["Thebe", "THEBE"],["Sen", "SEN"],["Stotinka", "STOTINKA"],["Fen", "FEN"],["Céntimo", "CENTIMO"],["Lipa", "LIPA"],["Haléř", "HALER"],["Øre", "ØRE"],["Piastre", "PIASTRE"],["Santim", "SANTIM"],["Oyra", "OYRA"],["Butut", "BUTUT"],["Tetri", "TETRI"],["Pesewa", "PESEWA"],["Fillér", "FILLER"],["Eyrir", "EYRIR"],["Dinar", "DINAR"],["Agora", "AGORA"],["Tïın", "TIIN"],["Chon", "CHON"],["Jeon", "JEON"],["Tyiyn", "TYIYN"],["Att", "ATT"],["Sente", "SENTE"],["Dirham", "DIRHAM"],["Rappen", "RAPPEN"],["Avo", "AVO"],["Deni", "DENI"],["Iraimbilanja", "IRAIMBILANJA"],["Tambala", "TAMBALA"],["Laari", "LAARI"],["Khoums", "KHOUMS"],["Ban", "BAN"],["Möngö", "MONGO"],["Pya", "PYA"],["Kobo", "KOBO"],["Kuruş", "KURUS"],["Baisa", "BAISA"],["Centésimo", "CENTESIMO"],["Toea", "TOEA"],["Sentimo", "SENTIMO"],["Grosz", "GROSZ"],["Sene", "SENE"],["Halala", "HALALA"],["Para", "PARA"],["Öre", "ORE"],["Diram", "DIRAM"],["Satang", "SATANG"],["Seniti", "SENITI"],["Millime", "MILLIME"],["Tennesi", "TENNESI"],["Kopiyka", "KOPIYKA"],["Tiyin", "TIYIN"],["Hào", "HAO"],["Ngwee", "NGWEE"],["Millibitcoin", "MILLIBITCOIN"],["Satoshi", "SATOSHI"]]); - export const CompoundUnitConnectorRegex = `(?and)`; - export const MultiplierRegex = `\\s*\\b(thousand|million|billion|trillion)s?\\b`; - export const CurrencyPrefixList: ReadonlyMap = new Map([["Dobra", "db|std"],["Dollar", "$"],["Brazilian Real", "R$"],["United States dollar", "united states $|us$|us $|u.s. $|u.s $|usd$"],["East Caribbean dollar", "east caribbean $"],["Mexican peso", "mxn$|mxn $|mex$"],["Australian dollar", "australian $|australia $"],["Bahamian dollar", "bahamian $|bahamia $"],["Barbadian dollar", "barbadian $|barbadin $"],["Belize dollar", "belize $"],["Bermudian dollar", "bermudian $"],["British Virgin Islands dollar", "british virgin islands $|bvi$|virgin islands $|virgin island $|british virgin island $"],["Brunei dollar", "brunei $|b$"],["Sen", "sen"],["Singapore dollar", "singapore $|s$"],["Canadian dollar", "canadian $|can$|c$|c $|canada $"],["Cayman Islands dollar", "cayman islands $|ci$|cayman island $"],["New Zealand dollar", "new zealand $|nz$|nz $"],["Cook Islands dollar", "cook islands $|cook island $"],["Fijian dollar", "fijian $|fiji $"],["Guyanese dollar", "gy$|gy $|g$|g $"],["Hong Kong dollar", "hong kong $|hk$|hkd|hk $"],["Indian rupee", "₹"],["Jamaican dollar", "jamaican $|j$|jamaica $"],["Kiribati dollar", "kiribati $"],["Liberian dollar", "liberian $|liberia $"],["Micronesian dollar", "micronesian $"],["Namibian dollar", "namibian $|nad|n$|namibia $"],["Nauruan dollar", "nauruan $"],["Niue dollar", "niue $"],["Palauan dollar", "palauan $"],["Pitcairn Islands dollar", "pitcairn islands $|pitcairn island $"],["Solomon Islands dollar", "solomon islands $|si$|si $|solomon island $"],["Surinamese dollar", "surinamese $|surinam $"],["New Taiwan dollar", "nt$|nt $"],["Trinidad and Tobago dollar", "trinidad and tobago $|trinidad $|trinidadian $"],["Tuvaluan dollar", "tuvaluan $"],["Samoan tālā", "ws$"],["Chinese yuan", "¥"],["Japanese yen", "¥"],["Euro", "€"],["Pound", "£"],["Costa Rican colón", "₡"],["Turkish lira", "₺"],["Bitcoin", "₿|btc|xbt"]]); - export const AmbiguousCurrencyUnitList = [ "din.","kiwi","kina","kobo","lari","lipa","napa","para","sfr.","taka","tala","toea","vatu","yuan","all","ang","ban","bob","btn","byr","cad","cop","cup","dop","gip","jod","kgs","lak","lei","mga","mop","nad","omr","pul","sar","sbd","scr","sdg","sek","sen","sol","sos","std","try","yer","yen","db","pen","ron","mad","zar","gel","satoshi","satoshis" ]; - export const InformationSuffixList: ReadonlyMap = new Map([["Bit", "-bit|bit|bits"],["Kilobit", "kilobit|kilobits|kb|Kb|kbit"],["Megabit", "megabit|megabits|mb|Mb|mbit"],["Gigabit", "gigabit|gigabits|gb|Gb|gbit"],["Terabit", "terabit|terabits|tb|Tb|tbit"],["Petabit", "petabit|petabits|pb|Pb|pbit"],["Byte", "-byte|byte|bytes"],["Kilobyte", "-kilobyte|-kilobytes|kilobyte|kB|KB|kilobytes|kilo byte|kilo bytes|kbyte"],["Megabyte", "-megabyte|-megabytes|megabyte|mB|MB|megabytes|mega byte|mega bytes|mbyte"],["Gigabyte", "-gigabyte|-gigabytes|gigabyte|gB|GB|gigabytes|giga byte|giga bytes|gbyte"],["Terabyte", "-terabyte|-terabytes|terabyte|tB|TB|terabytes|tera byte|tera bytes|tbyte"],["Petabyte", "-petabyte|-petabytes|petabyte|pB|PB|petabytes|peta byte|peta bytes|pbyte"]]); - export const AmbiguousDimensionUnitList = [ "barrel","barrels","grain","grains","pound","stone","stones","yards","yard","cord","cords","dram","drachm","drachma","feet","foot","gill","knot","knots","peck","pecks","cup","cups","fps","pts","in","dm","\"","pinch","pinches" ]; - export const BuildPrefix = `(?<=(\\s|^))`; - export const BuildSuffix = `(?=(\\s|\\W|$))`; - export const LengthSuffixList: ReadonlyMap = new Map([["Kilometer", "km|kilometer|kilometre|kilometers|kilometres|kilo meter|kilo meters|kilo metres|kilo metre"],["Hectometer", "hm|hectometer|hectometre|hectometers|hectometres|hecto meter|hecto meters|hecto metres|hecto metre"],["Decameter", "dam|decameter|decametre|decameters|decametres|deca meter|deca meters|deca metres|deca metre"],["Meter", "m|meter|metre|meters|metres"],["Decimeter", "dm|decimeter|decimeters|decimetre|decimetres|deci meter|deci meters|deci metres|deci metre"],["Centimeter", "cm|centimeter|centimeters|centimetre|centimetres|centi meter|centi meters|centi metres|centi metre"],["Millimeter", "mm|millimeter|millimeters|millimetre|millimetres|milli meter|milli meters|milli metres|milli metre"],["Micrometer", "μm|micrometer|micrometre|micrometers|micrometres|micro meter|micro meters|micro metres|micro metre"],["Nanometer", "nm|nanometer|nanometre|nanometers|nanometres|nano meter|nano meters|nano metres|nano metre"],["Picometer", "pm|picometer|picometre|picometers|picometres|pico meter|pico meters|pico metres|pico metre"],["Mile", "-mile|mile|miles"],["Yard", "yard|yards"],["Inch", "-inch|inch|inches|in|\""],["Foot", "-foot|foot|feet|ft"],["Light year", "light year|light-year|light years|light-years"],["Pt", "pt|pts"]]); - export const AmbiguousLengthUnitList = [ "m","yard","yards","pm","pt","pts" ]; - export const SpeedSuffixList: ReadonlyMap = new Map([["Meter per second", "meter/second|meters/second|meters / second|m/s|meters per second|metres per second|meter per second|metre per second"],["Kilometer per hour", "km/h|kilometres per hour|kilometers per hour|kilometer per hour|kilometre per hour|kph|kmph|km/hr"],["Kilometer per minute", "km/min|kilometers per minute|kilometres per minute|kilometer per minute|kilometre per minute"],["Kilometer per second", "km/s|kilometers per second|kilometres per second|kilometer per second|kilometre per second"],["Mile per hour", "mph|mile per hour|miles per hour|mi/h|mile / hour|miles / hour|miles an hour|mi/hr"],["Knot", "kt|knot|knots|kn"],["Foot per second", "ft/s|foot/s|feet/s|foot per second|feet per second|fps"],["Foot per minute", "ft/min|foot/min|feet/min|foot per minute|feet per minute"],["Yard per minute", "yards per minute|yard per minute|yards / minute|yards/min|yard/min"],["Yard per second", "yards per second|yard per second|yards / second|yards/s|yard/s"],["Meter per millisecond", "meter/millisecond|meters/millisecond|meter / millisecond|meters / millisecond|meter per millisecond|meters per millisecond|m/ms"],["Centimeter per millisecond", "centimeter/millisecond|centimeters/millisecond|centimeter / millisecond|centimeters / millisecond|centimeter per millisecond|centimeters per millisecond|cm/ms"],["Kilometer per millisecond", "kilometer/millisecond|kilometers/millisecond|kilometer / millisecond|kilometers / millisecond|kilometer per millisecond|kilometers per millisecond|km/ms"]]); - export const AmbiguousSpeedUnitList = [ "knot","knots","fps" ]; - export const TemperatureSuffixList: ReadonlyMap = new Map([["F", "degrees fahrenheit|degree fahrenheit|deg fahrenheit|degs fahrenheit|fahrenheit|°f|° f|degrees farenheit|degree farenheit|deg farenheit|degs farenheit|degrees f|degree f|deg f|degs f|farenheit|f"],["K", "k|K|kelvin"],["R", "rankine|°r"],["D", "delisle|°de"],["C", "degrees celsius|degree celsius|deg celsius|degs celsius|celsius|degrees celcius|degree celcius|celcius|deg celcius|degs celcius|degrees centigrade|degree centigrade|centigrade|degrees centigrate|degree centigrate|degs centigrate|deg centigrate|centigrate|degrees c|degree c|deg c|degs c|°c|° c|c"],["Degree", "degree|degrees|deg.|deg|°"]]); - export const AmbiguousTemperatureUnitList = [ "c","f","k" ]; - export const VolumeSuffixList: ReadonlyMap = new Map([["Cubic meter", "m3|cubic meter|cubic meters|cubic metre|cubic metres"],["Cubic centimeter", "cubic centimeter|cubic centimetre|cubic centimeters|cubic centimetres"],["Cubic millimiter", "cubic millimiter|cubic millimitre|cubic millimiters|cubic millimitres"],["Hectoliter", "hectoliter|hectolitre|hectoliters|hectolitres"],["Decaliter", "decaliter|decalitre|dekaliter|dekalitre|decaliters|decalitres|dekaliters|dekalitres"],["Liter", "l|litre|liter|liters|litres"],["Deciliter", "dl|deciliter|decilitre|deciliters|decilitres"],["Centiliter", "cl|centiliter|centilitre|centiliters|centilitres"],["Milliliter", "ml|mls|millilitre|milliliter|millilitres|milliliters|cc"],["Cubic yard", "cubic yard|cubic yards"],["Cubic inch", "cubic inch|cubic inches"],["Cubic foot", "cubic foot|cubic feet"],["Cubic mile", "cubic mile|cubic miles"],["Fluid ounce", "fl oz|fluid ounce|fluid ounces"],["Teaspoon", "teaspoon|teaspoons|teaspoonful|teaspoonfuls|tsp|tsp.|tspn|tspn.|tea spoon|tea spoons|t.|ts."],["Tablespoon", "tablespoon|tablespoons|tablespoonful|tablespoonfuls|tbl|tbl.|tbs|tbs.|tbsp|tbsp.|table spoon|table spoons|T.|Tb.|tbls.|tbls"],["Pint", "pint|pints|fl pt| fluid pint"],["Quart", "quart|quarts|fl qt"],["Cup", "cup|cups"],["Gill", "gill|gills"],["Pinch", "pinch|pinches"],["Fluid Dram", "fluid dram|fluid drachm|fluid drachma|fluidram|fluidrams"],["Barrel", "barrel|bbl|barrels"],["Minim", "minim"],["Cord", "cord|cords"],["Peck", "peck|pecks"],["Bushel", "bushel"],["Hogshead", "hogshead"]]); - export const AmbiguousVolumeUnitList = [ "l","ounce","oz","cup","cups","peck","pecks","cord","cords","gill","gills","barrel","barrels","tbl","quart","quarts","pinch","t.","T.","Tb.","ts." ]; - export const WeightSuffixList: ReadonlyMap = new Map([["Kilogram", "kg|kilogram|kilograms|kilo|kilos|kilogramme|kilogrammes"],["Gram", "g|gram|grams|gm|gramme|grammes"],["Milligram", "mg|milligram|milligrams|milligramme|milligrammes"],["Microgram", "μg|microgram|micrograms|micro gram|micro grams|microgramme|microgrammes|mcg"],["Gallon", "-gallon|gallons|gallon|gal"],["Metric ton", "metric tons|metric ton"],["Ton", "-ton|ton|tons|tonne|tonnes|t"],["Pound", "pound|pounds|lb|lbs"],["Ounce", "-ounce|ounce|oz|ounces"],["Grain", "grain|grains|gr"],["Pennyweight", "pennyweight"],["Long ton (British)", "british long ton|long ton (british)"],["Short ton (US)", "us short ton|short ton (us)"],["Short hundredweight (US)", "us short hundredweight|short hundredweight (us)"],["Stone", "stone"],["Dram", "dram|drachm|drachma|roman drachma|greek drachma"]]); - export const AmbiguousWeightUnitList = [ "g","t","gr","oz","stone","dram","lbs","gal","grain","grains" ]; - export const AngleSuffixList: ReadonlyMap = new Map([["Degree", "degree|degrees|deg.|deg|°"],["Radian", "radian|radians|rad"],["Turn", "turn|turns"]]); - export const AmbiguousAngleUnitList = [ "turn","turns" ]; - export const AmbiguityFiltersDict: ReadonlyMap = new Map([["\\bm\\b", "((('|’)\\s*m)|(m\\s*('|’)))"],["^\\d{5} [cf]$", "\\b([a-z]{2} \\d{5} [cf])\\b"],["\\b\\d+\\s*\\p{L}+$", "((\\d+(\\s*\\p{L}+[-—–-]|\\p{L}+)\\d+)|(((\\p{L}|\\d)[-—–-]\\d+\\s*|\\p{L}\\d+)\\p{L}+))"],["^(all|bob|pen|cad|cup|cop|sos|ron|mad|mop|zar|gel)", "(all|bob|pen|cad|cup|cop|sos|ron|mad|mop|zar|gel)\\s*(\\d|\\p{L})"],["\\d\\s*pm\\b", "\\b(at|until|since|before|after)\\s\\d(\\d)?\\s*pm\\b"],["\\bin\\b", "\\bin\\s*(\\d{4}|(jan|febr)uary|march|april|may|ju(ne|ly)|august|october|(sept|nov|dec)ember)"],["\\b(13)?f\\b", "(\\bf-series\\b|\\b13f\\s(filings?|be fill?ed))"],["\\d\\d\\df", "boeing\\s777f"],["\\bc\\b", "\\bc\\.p\\.i(\\.)?"],["\\d\\s*c\\b", "(dividend (of|by) (\\d\\.)?\\d(\\d)?\\s*c|(\\d\\.)?\\d(\\d)?\\s*c/? (a share|per security))"]]); - export const TemperatureAmbiguityFiltersDict: ReadonlyMap = new Map([["\\b(deg(rees?)?|°)$", "\\b((deg(rees?)?|°)\\s*(angle|rotation)|(rotat(ion|e[ds]?|ing)|angle)(\\s+(\\p{L}+|\\d+)){0,4}\\s*(deg(rees?)?\\b|°))"]]); - export const DimensionAmbiguityFiltersDict: ReadonlyMap = new Map([["\\b(deg(rees?)?|°)$", "\\b((deg(rees?)?|°)\\s*(c(elsius|entigrate)?|f(ah?renheit)?)|(temperature)(\\s+(\\p{L}+|\\d+)){0,4}\\s*(deg(rees?)?\\b|°))"],["\\b\\d+\\s*\\p{L}+$", "((\\d+\\s*\\p{L}+\\d+)|(\\p{L}\\d+\\s*\\p{L}+))"]]); -} diff --git a/JavaScript/packages/recognizers-number-with-unit/src/resources/frenchNumericWithUnit.ts b/JavaScript/packages/recognizers-number-with-unit/src/resources/frenchNumericWithUnit.ts deleted file mode 100644 index d1cf17a551..0000000000 --- a/JavaScript/packages/recognizers-number-with-unit/src/resources/frenchNumericWithUnit.ts +++ /dev/null @@ -1,41 +0,0 @@ -// ------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// ------------------------------------------------------------------------------ - -import { BaseNumbers } from "./baseNumbers"; -export namespace FrenchNumericWithUnit { - export const AgeSuffixList: ReadonlyMap = new Map([["Ans", "ans"],["Mois", "mois d'âge|mois d'age|mois"],["Semaines", "semaine|semaines|semaines d'âge|semaines d'age"],["Jour", "jours|jour"]]); - export const AreaSuffixList: ReadonlyMap = new Map([["Kilomètre carré", "km2|km^2|km²|kilomètres carrés|kilomètre carré"],["Hectomètre carré", "hm2|hm^2|hm²|hectomètre carré|hectomètres carrés"],["Décamètre carré", "dam2|dam^2|dam²|décamètre carré|décamètres carrés"],["Mètre carré", "m2|m^2|m²|mètre carré|mètres carrés"],["Décimètre carré", "dm2|dm^2|dm²|décimètre carré|décimètres carrés"],["Centimètre carré", "cm2|cm^2|cm²|centimètre carré|centimètres carrés"],["Millimètre carré", "mm2|mm^2|mm²|millimètre carré|millimètres carrés"],["Pouce carré", "pouces2|po2|pouce carré|pouces carrés|in^2|in²|in2"],["Pied carré", "pied carré|pieds carrés|pi2|pi^2|pi²"],["Mile carré", "mile carré|miles carrés|mi2|mi^2|mi²"],["Acre", "acre|acres"]]); - export const CurrencySuffixList: ReadonlyMap = new Map([["Abkhazie apsar", "abkhazie apsar|apsars"],["Afghan afghani", "afghan afghani|؋|afn|afghanis|afghani"],["Pul", "pul"],["Euro", "euros|euro|€|eur|d'euros"],["Cent", "cents|cent|-cents|-cent"],["lek Albanais", "lek albanais|leks|lek"],["Qindarkë", "qindarkë|qindarkës|qindarke|qindarkes"],["Kwanza angolais", "kwanza angolais|kz|aoa|kwanza|kwanzas"],["Dram arménien", "dram arménien|drams arméniens"],["Florins d'Aruba", "florins aruba|ƒ|awg"],["Bangladeshi taka", "bangladeshi taka|৳|bdt|taka|takas|bangladeshi takas"],["Paisa", "poisha|paisa"],["Ngultrum bhoutanais", "ngultrum bhoutanais|nu.|btn"],["Chetrum", "chetrums|chetrum"],["Boliviano bolivien", "boliviano bolivien|bolivianos bolivien|bolivianos bolivie|boliviano bolivie|bob|bs."],["Bosnie-Herzégovine mark convertible", "bosnie-herzégovine mark convertible|bosnie-et-herzégovine mark convertible|bam"],["Fening", "fening|fenings"],["Pula", "pula|bwp"],["Thebe", "thebe"],["Réal brésilien", "réal brésilien|réals brésilien|r$|brl|real bresil|reals bresilien"],["Lev bulgare", "lev bulgare|levs bulgare|lv|bgn"],["Stotinki búlgaro", "stotinki bulgare"],["Riel cambodgien", "riel cambodgien|khr|៛"],["Escudo du cap-vert", "escudo cap-verdien|cve"],["Colon du costa rica", "colon du costa rica|colons du costa rica|crc|₡"],["Colon du salvador", "colon du salvador|colons du salvador|svc"],["Kuna croate", "kuna croate|kunas croate|kn|hrk"],["Lipa", "lipa"],["Couronne tchèque", "couronne tchèque|couronnes tchèque|czk|Kč"],["Haléř", "haléř"],["Nakfas érythréens", "nakfas érythréens|nfk|ern|nakfa érythréens"],["Birr éthiopien", "birr éthiopien|birrs éthiopien|etb"],["Dalasi gambienne", "gmd"],["Butut", "bututs|butut"],["Lari géorgien", "lari géorgie|lari géorgiens|gel|₾"],["Tetri géorgien", "tetri géorgie|tetris géorgiens"],["Cedi", "cedi|ghs|cedi ghanéen|gh₵"],["Pesewa", "pesewa|pesewas"],["Quetzal guatémaltèque", "quetzal guatémaltèque|gtq|quetzal|quetzales"],["Gourdes haïtiennes", "gourdes haïtiennes|gourdes|htg|gourde haïtienne"],["Lempira hondurien", "lempira hondurien|hnl"],["Forint hongrois", "forint hongrois|huf|fg|forints hongrois"],["Fillér", "fillér"],["Rial iranien", "rial iranien|irr|rials iranien|rials iraniens"],["Litas lituanien", "litas lituanien|ltl|lit lithuanien|litas lithuanie"],["Yen Japonais", "yen japonais|yen japon|yens|jpy|yen|¥|-yen"],["Tenge kazakh", "tenge kazakh|kzt"],["Shilling kényan", "shilling kényan|kes|shillings kényans"],["Won coréen", "won coréen|won coréens|₩"],["Won sud-coréen", "won sud-coréen|won sud coréen|won sud-coréens|krw"],["Corée du nord won", "corée du nord won|corée nord won|kpw"],["Som Kirghizie", "som kirghizie|kgs"],["Sum Ouzbékistan", "sum ouzbékistan|sum ouzbeks|sum ouzbéks|uzs"],["Kip laotien", "kip laotien|lak|₭n|₭"],["Att", "att"],["Loti", "loti|maloti|lsl"],["Sente", "sente|lisente"],["Rand sud-africain", "rand sud-africain|zar"],["Pataca macanais", "pataca macanais|mop$|mop"],["Avo", "avos|avo"],["Dinar macédonien", "dinar macédonien|mkd|ден"],["Deni", "deni"],["Ariary malagache", "ariary malagache|mga"],["Iraimbilanja", "Iraimbilanja"],["Kwacha malawien", "kwacha malawien|mk|mwk"],["Tambala", "Tambala"],["Ringitt malaisien", "ringitt malaisien|rm|myr|ringitts malaisien"],["Ouguiya mauritanienne", "ouguiya|um|mro|ouguiya mauritanien|ouguiya mauritanienne"],["Khoums", "khoums"],["Togrogs mongoles", "togrogs mongoles|togrogs|tugriks|tögrög|mnt|₮|tögrög mongoles|tögrög mongolie|togrogs mongolie"],["Metical mozambique", "metical du mozambique|metical mozambique|mt|mzn|meticals mozambique"],["Kyat birmanie", "kyat birmanie|ks|mmk"],["Pya", "pya"],["Cordoba nicaraguayen", "cordoba nicaraguayen|córdoba nicaraguayen|nio|córdoba oro|cordoba oro nicaraguayen"],["Naira nigérians", "naira nigérians|naira|ngm|₦|nairas nigérians"],["Livre turque", "livre turque|try|tl|livre turques"],["Kuruş", "kuruş"],["Rials omanais", "rials omanais|omr|ر.ع.|rial omanais"],["Balboa panaméennes", "balboa panaméennes|balboa|pab"],["Kina", "kina|pkg|pgk"],["Toea", "toea"],["Guaraní paraguayen", "guaraní paraguayen|₲|pyg"],["Sol péruvien", "nuevo sol péruvien|soles|sol|sol péruvien"],["Złoty polonais", "złoty polonais|złoty|zł|pln|zloty|zloty polonais"],["Groxz", "groszy|grosz|grosze"],["Riyal qatari", "riyal qatari|qar|riyals qatari"],["Riyal saudi", "riyal saudi|sar|riyals saudi"],["Riyal", "riyal|riyals|rial|﷼"],["Dirham", "dirham|dirhem|dirhm"],["Halala", "halalas|halala"],["Tala", "tala|tālā|ws$|sat|wst"],["Sene", "sene"],["Dobra", "dobra|db|std"],["Leone", "leone|sll"],["Florins Néerlandais", "florins hollandais|florins néerlandais|florins|ang|florin|fl"],["Lilangeni", "lilangeni|szl"],["Somoni tadjikistan", "somoni tadjikistan|tjs|somoni"],["Diram", "dirams|diram"],["Baht thaïlandais", "baht thaïlandais|baht thailandais|baht thaï|baht thai|baht|฿|thb"],["Satang", "satang|satangs"],["Paʻanga", "paʻanga|pa'anga|top"],["Hryvnia ukrainien", "hryvnia ukrainien|hyrvnia|uah|₴|hryvnias ukrainien|hryvnia ukrainienne"],["Vanuatu vatu", "vanuatu vatu|vatu|vuv"],["Bolívar vénézuélien", "bolívar vénézuélien|bolivar venezuelien|bs.f.|vef|bolívars vénézuélien|bolivars venezuelien"],["Dong vietnamien", "dong vietnamien|dongs vietnamiens|dong|đồng|vnd|dông|dông vietnamiens"],["Kwacha de Zambie", "kwacha de zambie|zk|zmw|kwachas"],["Dirham marocain", "dirham marocain|mad|د.م."],["Dirham des Émirats arabes unis", "dirham des Émirats arabes unis|د.إ|aed"],["Manat azerbaïdjanais", "manat azerbaïdjanais|manat azerbaidjanais|azn"],["Manat turkmène", "manat turkmène|tmt|manat turkmene"],["Manat", "manats|manat"],["Qəpik", "qəpik"],["Shilling somalien", "shilling somalien|shillings somalien|sos"],["Shilling tanzanien", "shilling tanzanien|shillings tanzanien|tzs|tsh|shilling tanzanienne|shillings tanzanienne"],["Shilling ougandais", "shilling ougandais|shillings ougandais|ugx"],["Leu roumain", "leu roumain|lei|leu roumaine|ron"],["Leu moldave", "leu meoldave|mdl"],["Leu", "leu"],["Ban", "bani|-ban|ban"],["Roupie népalaise", "roupie népalaise|roupie nepalaise|npr"],["Roupie pakistanaise", "roupie pakistanaise|pkr"],["Roupie indienne", "roupie indienne|roupies indiennes|inr|roupie indien|inr|₹"],["Roupie seychelloise", "roupie seychelloise|scr|sr|sre"],["Roupie mauricienne", "roupie mauricienne|mur"],["Rufiyaa maldives", "rufiyaa maldives|mvr|.ރ|rf"],["Roupie srilankaise", "roupie srilankaise|lrk|රු|ரூ"],["Rupiah Indonésie", "rupia indonésie|rupia indonesie|rupiah|rp|idr"],["Roupie", "roupie|roupies"],["Couronne danoise", "couronne danoise|dkk|couronnes danoise|couronne danemark|couronnes danemark"],["Couronne norvégienne", "couronne norvégienne|couronne norvegienne|couronnes norvégienne|couronnes norvegienne|nok"],["Couronne féroïenne", "couronne féroïenne|couronne feroienne"],["Couronne suédoise", "couronne suédoise|couronne suéde|sek|couronnes suédoise|couronne suedoise"],["Couronne", "couronne|couronnes"],["Øre", "Øre|oyra|eyrir"],["Franc CFA de l'Afrique de l'Ouest", "franc cfa de l''afrique de l''ouest|franc cfa ouest africain|franc cfa|francs cfa|fcfa|frs cfa|cfa francs|xof"],["Franc CFA d'Afrique centrale", "franc cfa d''afrique centrale|franc cfa centrale|frs cfa centrale|xaf"],["Franc comorien", "franc comorien|kmf"],["Franc congolais", "franc congolais|cdf"],["Franc burundais", "franc burundais|bif"],["Franc djiboutienne", "franc djiboutienne|djf"],["Franc CFP", "franc cfp|xpf"],["Franc guinéen", "franc guinéen|gnf"],["Franc Suisse", "franc suisse|chf|sfr.|francs suisses"],["Franc rwandais", "franc rwandais|rwf|rw|r₣|frw"],["Franc belge", "franc belge|bi.|b.fr.|bef"],["Rappen", "rappen|-rappen"],["Franc", "francs|franc|fr.|fs"],["Centimes", "centimes|centime|santim"],["Rouble russe", "rouble russe|rub|₽|₽ russe|roubles russe|roubles russes|₽ russes"],["Nouveau rouble biélorusse", "nouveau rouble biélorusse|byn|nouveau roubles biélorusse|nouveau rouble bielorusse|nouveau roubles biélorusse"],["Rouble transnistriens", "rouble transnistriens|prb"],["Rouble biélorusses", "rouble biélorusses|roubles biélorusses|rouble bielorusses|roubles bielorusses"],["Kopek", "kopek|kopeks"],["Kapyeyka", "kapyeyka"],["Rouble", "roubles|rouble|br"],["Dinar algérien", "dinar algérien|د.ج|dzd|dinars algérien|dinar algerien|dinars algerien"],["Dinar de bahreïn", "dinar de bahreïn|bhd|.د.ب|dinar de bahrein"],["Santeem", "santeem|santeems"],["Dinar iraquien", "dinar iraquien|dinars iraquien|iqd|ع.د|dinar iraquienne|dinars iraquienne"],["Dinar jordanien", "dinar jordanien|dinars jordanien|د.ا|jod"],["Dinar koweïtien", "dinar koweïtien|dinar koweitien|dinars koweïtien|kwd|د.ك"],["Dinar libyen", "dinar libyen|dinars libyen|lyd"],["Dinar serbe", "dinar serbe|dinars serbe|rsd|дин."],["Dinar tunisien", "dinar tunisien|dinars tunisien|tnd"],["Dinar yougoslave", "dinar yougoslave|dinars yougoslave|yun"],["Dinar", "dinars|dinar|denar|-dinars|-dinar"],["Fils", "fils|fulūs|-fils|-fil"],["Para", "para|napa"],["Millime", "millimes|millime"],["Peso argentin", "peso argentin|ars|pesos argentin|peso argentine|pesos argentine"],["Peso chilien", "peso chilien|pesos chilien|clp"],["Peso colombien", "peso colombien|pesos colombien|cop|peso colombie|pesos colombien"],["Peso cubains convertibles", "peso cubains convertibles|pesos cubains convertibles|cuc"],["Peso cubains", "peso cubaines|pesos cubaines|peso cubaine|pesos cubaines|cup"],["Peso dominicain", "peso dominicain|pesos dominicain|dop|peso dominicaine|pesos dominicaine"],["Peso philippin", "peso philippin|pesos philippin|piso|₱|php"],["Peso uruguayen", "peso uruguayen|pesos uruguayen|uyu"],["Peso", "pesos|Peso"],["Centavo", "centavos|Centavo"],["Livre britannique", "livre britannique|livres britannique|gbp|£ britannique"],["Livre guernesey", "livre guernesey|£ guernesey|ggp"],["Livre ascension", "livre ascension|livres ascension|£ ascension"],["Livre sainte-hélène", "livre de sainte-hélène|livre sainte-hélène|livre sainte-helene|livre de sainte hélène|shp"],["Livre égyptienne", "livre égyptienne|livre egyptienne|egp|ج.م"],["Livre des îles falkland", "livre des îles falkland|livre des iles falkland|fkp|£ iles falkland"],["Livre gibraltar", "livre gibraltar|livre de gibraltar|£ gibraltar|gip"],["Livre manx", "imp|livre manx|£ manx"],["Livre jersey", "livre de jersey|livre jersey|jep|£ jersey"],["Livre libanaise", "livre libanaise|£ libanaise|livres libanaise|lbp|ل.ل"],["Livre des îles malouines", "livre des îles malouines|livre des iles malouines|£ iles malouines"],["Livre sud-soudanaise", "livre sud-soudanaise|livre sud soudanaise|livre du soudan du sud|livres sud-soudanaises|livre sud soudan|livre soudan sud"],["Livre soudanaise", "livre soudanaise|livres soudanaise|sdg|£ soudan|ج.س.|livre soudan|livres soudan"],["Livre syrienne", "livre syrienne|ل.س|syp|livre syrie|livres syrie|£ syrie"],["Livre", "livre|livres|-livre|-livres|£"],["Pence", "pence"],["Shilling", "shilling|shillings|sh"],["Penny", "penny|sou"],["Dollar États-Unis", "dollar américain|$ américain|$ americain|usd|$usd|$ usd|dollar americain|dollar États-Unis|dollar des États-Unis|dollar États Unis|dollar etats unis|dollar etats-unis|$ etats-unis|$ États-Unis"],["Dollar des Caraïbes orientales", "dollar des caraïbes orientales|dollar des caraibes orientales|xcd|$ caraibes orientales|$ caraïbes orientales"],["Dollar Australien", "dollar australien|dollars australiens|$ australien|aud|$australien|australien $|$ australie|dollar australie"],["Dollar des bahamas", "dollar des bahamas|dollar bahamas|$ bahamas|bsd|bahama $|dollar bahama|$ bahamas"],["Dollar des bermudes", "dollar des bermudes|dollar bermude|dollar bermudes|$ bermudes|bmd"],["Dollar de belize", "dollar de Belize|dollar belizien|bzd|$ belize"],["Dollar îles Vierges britanniques", "dollar îles vierges britanniques|dollar iles vierges britanniques|$ iles vierges britanniques"],["Dollar de brunei", "dollar de brunei|$ brunei|bnd|dollar brunei"],["Sen", "sen"],["Dollar de Singapour", "dollar de singapour|dollar singapour|$ sinapour|sgd|$s"],["Dollar Canadien", "dollar canadien|dollars canadien|$ canadien|cad|$can|$c|$ c|dollar canada|dollar canadienne|$ canada|$cad|cad$"],["Dollar des îles Caïmans", "dollars des îles caïmanes|dollar des îles caïmanes|dollars des iles caimanes|dollar iles caimanes|kyd|$ci"],["Dollar néo-zélandais", "dollar néo-zélandais|dollar néo zélandais|dollar neo-zelandais|dollar neo zelandais|$nz|$ néo-zélandais|$ neo zelandais"],["Dollar îles cook", "dollar îles cook|dollar iles cook|$ iles cook"],["Dollar des fidji", "dollar des fidji|$ fidji|dollar fidji|dollar de fidji|dollars des fidji|dollars de fidji"],["Dollar guyanien", "dollar guyanien|dollar du guyana|dollar dre guyana|$ guayana|gyd|$gy"],["Dollar de Hong Kong", "dollar hong kong|dollar hongkong|dollar de hong kong|dollar de hongkong|$hk|$ hk|hkd|hk $|hk$|dollar hk|$hongkong|dollars hongkong|dollars hong kong"],["Dollar jamaïcain", "dollar jamaïcain|dollars jamaïcain|dollar jamaicain|dollars jamaicain|$j|$ jamaïque|dollar jamaïque|jmd"],["Dollar libérien", "dollar libérien|dollars libérien|dollar liberien|dollars liberien|lrd|$ libérien|$ liberia|$ liberien"],["Dollar namibien", "dollar namibien|dollars namibien|$ namibien|nad|$n|dollar namibie|dollars namibie|$ namibie"],["Dollar des îles Salomon", "dollar des îles Salomon|dollar des iles salomon|$si|sbd|$ iles salomon|$ îles salomon"],["Dollar du suriname", "dollar du suriname|srd|$ du suriname|$ suriname|dollar suriname|dollars suriname|dollars du suriname"],["Nouveau dollar de Taïwan", "nouveau dollar de taïwan|nouveau dollar de taiwan|twd|ntd|$nt"],["Dollar trinidadien", "dollar trinidadien|dollars trinidadien|ttd|$ trinidadien"],["Dollar", "dollar|$|dollars"],["Yuan Chinois", "yuan|yuans|yuan chinois|renminbi|cny|rmb|¥"],["Fen", "fen"],["Jiao", "jiao"],["Mark Finlandais", "marks finlandais|mark finlandais|fim|mark"],["Bitcoin", "bitcoin|bitcoins|btc|xbt|₿"],["Millibitcoin", "millibitcoin|millibitcoins|milibitcoin|milibitcoins"],["Satoshi", "satoshi|satoshis"]]); - export const CurrencyNameToIsoCodeMap: ReadonlyMap = new Map([["Afghan afghani", "AFN"],["Euro", "EUR"],["Albanian lek", "ALL"],["Kwanza angolais", "AOA"],["Armenian dram", "AMD"],["Florins d'Aruba", "AWG"],["Bangladeshi taka", "BDT"],["Ngultrum bhoutanais", "BTN"],["Boliviano bolivien", "BOB"],["Bosnie-Herzégovine mark convertible", "BAM"],["Pula", "BWP"],["Réal brésilien", "BRL"],["Lev bulgare", "BGN"],["Riel cambodgien", "KHR"],["Escudo du cap-vert", "CVE"],["Colon du costa rica", "CRC"],["Kuna croate", "HRK"],["Couronne tchèque", "CZK"],["Nakfas érythréens", "ERN"],["Birr éthiopien", "ETB"],["Dalasi gambienne", "GMD"],["Lari géorgien", "GEL"],["Cedi", "GHS"],["Quetzal guatémaltèque", "GTQ"],["Gourdes haïtiennes", "HTG"],["Lempira hondurien", "HNL"],["Forint hongrois", "HUF"],["Rial iranien", "IRR"],["Yemeni rial", "YER"],["Israeli new shekel", "ILS"],["Yen Japonais", "JPY"],["Tenge kazakh", "KZT"],["Shilling kényan", "KES"],["Corée du nord won", "KPW"],["Won sud-coréen", "KRW"],["Som Kirghizie", "KGS"],["Kip laotien", "LAK"],["Loti", "LSL"],["Rand sud-africain", "ZAR"],["Pataca macanais", "MOP"],["Dinar macédonien", "MKD"],["Ariary malagache", "MGA"],["Kwacha malawien", "MWK"],["Ringitt malaisien", "MYR"],["Ouguiya mauritanienne", "MRO"],["Togrogs mongoles", "MNT"],["Metical mozambique", "MZN"],["Kyat birmanie", "MMK"],["Cordoba nicaraguayen", "NIO"],["Nigerian naira", "NGN"],["Livre turque", "TRY"],["Rials omanais", "OMR"],["Balboa panaméennes", "PAB"],["Kina", "PGK"],["Guaraní paraguayen", "PYG"],["Peruvian sol", "PEN"],["Złoty polonais", "PLN"],["Riyal qatari", "QAR"],["Riyal saudi", "SAR"],["Tala", "WST"],["São Tomé and Príncipe dobra", "STN"],["Leone", "SLL"],["Lilangeni", "SZL"],["Somoni tadjikistan", "TJS"],["Baht thaïlandais", "THB"],["Hryvnia ukrainien", "UAH"],["Vanuatu vatu", "VUV"],["Bolívar vénézuélien", "VEF"],["Kwacha de Zambie", "ZMW"],["Dirham marocain", "MAD"],["Dirham des Émirats arabes unis", "AED"],["Manat azerbaïdjanais", "AZN"],["Manat turkmène", "TMT"],["Shilling somalien", "SOS"],["Shilling tanzanien", "TZS"],["Shilling ougandais", "UGX"],["Leu roumain", "RON"],["Leu moldave", "MDL"],["Roupie népalaise", "NPR"],["Roupie pakistanaise", "PKR"],["Roupie indienne", "INR"],["Roupie seychelloise", "SCR"],["Roupie mauricienne", "MUR"],["Rufiyaa maldives", "MVR"],["Sri Lankan rupee", "LKR"],["Rupiah Indonésie", "IDR"],["Couronne danoise", "DKK"],["Couronne norvégienne", "NOK"],["Icelandic króna", "ISK"],["Couronne suédoise", "SEK"],["Franc CFA de l'Afrique de l'Ouest", "XOF"],["Franc CFA d'Afrique centrale", "XAF"],["Franc comorien", "KMF"],["Franc congolais", "CDF"],["Franc burundais", "BIF"],["Franc djiboutienne", "DJF"],["Franc CFP", "XPF"],["Franc guinéen", "GNF"],["Franc Suisse", "CHF"],["Franc rwandais", "RWF"],["Rouble russe", "RUB"],["Rouble transnistriens", "PRB"],["Nouveau rouble biélorusse", "BYN"],["Dinar algérien", "DZD"],["Dinar de bahreïn", "BHD"],["Dinar iraquien", "IQD"],["Dinar jordanien", "JOD"],["Dinar koweïtien", "KWD"],["Dinar libyen", "LYD"],["Dinar serbe", "RSD"],["Dinar tunisien", "TND"],["Peso argentin", "ARS"],["Peso chilien", "CLP"],["Peso colombien", "COP"],["Peso cubains convertibles", "CUC"],["Peso cubains", "CUP"],["Peso dominicain", "DOP"],["Mexican peso", "MXN"],["Peso uruguayen", "UYU"],["Livre britannique", "GBP"],["Livre sainte-hélène", "SHP"],["Livre égyptienne", "EGP"],["Livre des îles falkland", "FKP"],["Livre gibraltar", "GIP"],["Livre manx", "IMP"],["Livre jersey", "JEP"],["Livre libanaise", "LBP"],["South Sudanese pound", "SSP"],["Livre soudanaise", "SDG"],["Livre syrienne", "SYP"],["Dollar États-Unis", "USD"],["Dollar Australien", "AUD"],["Dollar des bahamas", "BSD"],["Dollar barbadien", "BBD"],["Dollar de belize", "BZD"],["Dollar des bermudes", "BMD"],["Dollar de brunei", "BND"],["Dollar de Singapour", "SGD"],["Dollar Canadien", "CAD"],["Dollar des îles Caïmans", "KYD"],["Dollar néo-zélandais", "NZD"],["Dollar de Fidji", "FJD"],["Dollar guyanien", "GYD"],["Dollar de Hong Kong", "HKD"],["Dollar jamaïcain", "JMD"],["Dollar libérien", "LRD"],["Dollar namibien", "NAD"],["Dollar des îles Salomon", "SBD"],["Dollar du suriname", "SRD"],["Nouveau dollar de Taïwan", "TWD"],["Dollar trinidadien", "TTD"],["Tuvaluan dollar", "TVD"],["Yuan Chinois", "CNY"],["Rial", "__RI"],["Shiling", "__S"],["Som", "__SO"],["Dirham", "__DR"],["Dinar", "_DN"],["Dollar", "__D"],["Manat", "__MA"],["Rupee", "__R"],["Krone", "__K"],["Krona", "__K"],["Crown", "__K"],["Frank", "__F"],["Mark", "__M"],["Ruble", "__RB"],["Peso", "__PE"],["Pound", "__P"],["Tristan da Cunha pound", "_TP"],["South Georgia and the South Sandwich Islands pound", "_SP"],["Somaliland shilling", "_SS"],["Pitcairn Islands dollar", "_PND"],["Palauan dollar", "_PD"],["Niue dollar", "_NID"],["Nauruan dollar", "_ND"],["Micronesian dollar", "_MD"],["Kiribati dollar", "_KID"],["Guernsey pound", "_GGP"],["Faroese króna", "_FOK"],["Cook Islands dollar", "_CKD"],["British Virgin Islands dollar", "_BD"],["Ascension pound", "_AP"],["Alderney pound", "_ALP"],["Abkhazian apsar", "_AA"],["Bitcoin", "_XBT"]]); - export const FractionalUnitNameToCodeMap: ReadonlyMap = new Map([["Jiao", "JIAO"],["Kopek", "KOPEK"],["Pul", "PUL"],["Cent", "CENT"],["Qindarkë", "QINDARKE"],["Penny", "PENNY"],["Santeem", "SANTEEM"],["Cêntimo", "CENTIMO"],["Centavo", "CENTAVO"],["Luma", "LUMA"],["Qəpik", "QƏPIK"],["Fils", "FILS"],["Poisha", "POISHA"],["Kapyeyka", "KAPYEYKA"],["Centime", "CENTIME"],["Chetrum", "CHETRUM"],["Paisa", "PAISA"],["Fening", "FENING"],["Thebe", "THEBE"],["Sen", "SEN"],["Stotinka", "STOTINKA"],["Fen", "FEN"],["Céntimo", "CENTIMO"],["Lipa", "LIPA"],["Haléř", "HALER"],["Øre", "ØRE"],["Piastre", "PIASTRE"],["Santim", "SANTIM"],["Oyra", "OYRA"],["Butut", "BUTUT"],["Tetri", "TETRI"],["Pesewa", "PESEWA"],["Fillér", "FILLER"],["Eyrir", "EYRIR"],["Dinar", "DINAR"],["Agora", "AGORA"],["Tïın", "TIIN"],["Chon", "CHON"],["Jeon", "JEON"],["Tyiyn", "TYIYN"],["Att", "ATT"],["Sente", "SENTE"],["Dirham", "DIRHAM"],["Rappen", "RAPPEN"],["Avo", "AVO"],["Deni", "DENI"],["Iraimbilanja", "IRAIMBILANJA"],["Tambala", "TAMBALA"],["Laari", "LAARI"],["Khoums", "KHOUMS"],["Ban", "BAN"],["Möngö", "MONGO"],["Pya", "PYA"],["Kobo", "KOBO"],["Kuruş", "KURUS"],["Baisa", "BAISA"],["Centésimo", "CENTESIMO"],["Toea", "TOEA"],["Sentimo", "SENTIMO"],["Grosz", "GROSZ"],["Sene", "SENE"],["Halala", "HALALA"],["Para", "PARA"],["Öre", "ORE"],["Diram", "DIRAM"],["Satang", "SATANG"],["Seniti", "SENITI"],["Millime", "MILLIME"],["Tennesi", "TENNESI"],["Kopiyka", "KOPIYKA"],["Tiyin", "TIYIN"],["Hào", "HAO"],["Ngwee", "NGWEE"],["Millibitcoin", "MILLIBITCOIN"],["Satoshi", "SATOSHI"]]); - export const CompoundUnitConnectorRegex = `(?et)`; - export const CurrencyPrefixList: ReadonlyMap = new Map([["Dollar", "$"],["Dollar États-Unis", "$us|usd|us$"],["Dollar des Caraïbes orientales", "xcd|$ec"],["Dollar Australien", "a$|$a|aud"],["Dollar des bahamas", "bsd|b$"],["Dollar barbadien", "bbd|bds$"],["Dollar de belize", "bz$|bzd"],["Dollar des bermudes", "bd$|bmd"],["Dollar de brunei", "brunei $|bnd"],["Dollar de Singapour", "s$|sgd"],["Dollar Canadien", "cad|$ ca|$ca|$ c"],["Dollar des îles Caïmans", "ci$|kyd"],["Dollar néo-zélandais", "nz$|nzd"],["Dollar de Fidji", "$fj|fjd"],["Dollar guyanien", "g$|gyd"],["Dollar de Hong Kong", "hkd|hk$"],["Dollar jamaïcain", "j$|jmd"],["Dollar libérien", "lrd|l$"],["Dollar namibien", "nad|n$"],["Dollar des îles Salomon", "$ si|$si|sbd"],["Nouveau dollar de Taïwan", "nt$|twd"],["Réal brésilien", "r$|brl|reais"],["Guaraní paraguayen", "₲|gs.|pyg"],["Dollar trinidadien", "ttd|titis"],["Yuan Chinois", "cny|rmb|¥|元"],["Yen Japonais", "¥|jpy"],["Euro", "€|eur"],["Livre", "£"],["Bitcoin", "₿|btc|xbt"]]); - export const AmbiguousCurrencyUnitList = [ "din.","kina","lari","taka","tala","vatu","yuan","bob","btn","cop","cup","dop","gip","jod","kgs","lak","mga","mop","nad","omr","sar","sbd","scr","sdg","sek","sos","std","try","yer","livre","ils" ]; - export const InformationSuffixList: ReadonlyMap = new Map([["Bit", "-bit|bit|bits"],["Kilobit", "kilobit|kilobits|kb|kbit|kbits"],["Megabit", "megabit|megabits|Mb|Mbit|mégabit|mégabits"],["Gigabit", "gigabit|gigabits|Gb|Gbit"],["Terabit", "terabit|terabits|Tb|Tbit|térabit|térabits"],["Petabit", "petabit|petabits|Pb|Pbit|pétabit|pétabits"],["octet", "octet|octets|-octet"],["Kilooctet", "kilo-octet|kilo-octets|kilooctet|kilooctets|ko|kio|kB|KiB|kilobyte|kilobytes"],["Mégaoctet", "mégaoctet|mégaoctets|méga-octet|méga-octets|Mo|Mio|MB|mégabyte|mégabytes"],["Gigaoctet", "gigaoctet|gigaoctets|Go|Gio|GB|GiB|gigabyte|gigabytes"],["Téraoctet", "téraoctet|téraoctets|To|Tio|TB|TiB|térabyte|térabytes"],["Pétaoctet", "pétaoctet|pétaoctets|Po|Pio|PB|PiB|pétabyte|pétabytes"]]); - export const AmbiguousDimensionUnitList = [ "mi","barils","grain","pierre","fps","pts" ]; - export const BuildPrefix = `(?<=(\\s|^|\\P{L}))`; - export const BuildSuffix = `(?=(\\s|\\P{L}|$))`; - export const ConnectorToken = `de`; - export const LengthSuffixList: ReadonlyMap = new Map([["Kilomètres", "km|kilomètres|kilomètre|kilometres|kilometre|-km"],["Hectomètre", "hm|hectomètre|hectomètres|hectometre|hectometres|-hm"],["Décamètre", "dam|décamètre|décamètres|decametre|decametres|-dm"],["Mètres", "m|mètres|mètre|metres|metre|m.|-m"],["Décimètres", "dm|décimètres|décimètre|decimetres|decimetre"],["Centimètres", "cm|centimètres|centimètre|centimetres|centimetre"],["Millimètres", "mm|millimètres|millimètre|millimetre|millimetres"],["Micromètres", "µm|um|micromètres|micromètre|micrometres|micrometre"],["Nanomètres", "nm|nanometre|nanometres|nanomètres|nanomètre"],["Picomètres", "pm|picomètre|picomètres|picometres|picometre"],["Mile", "mi|mile|miles"],["Pied", "pied|pieds"],["Yard", "yards|yard|yd"],["Pouce", "pouce|pouces"]]); - export const AmbiguousLengthUnitList = [ "m.","yard","yards","pm","pouce","pt","pts" ]; - export const SpeedSuffixList: ReadonlyMap = new Map([["Mètre par seconde", "m/s|metres/seconde|metres par seconde|metre par seconde|metres par secondes|mètre par seconde|mètres par seconde|mètres par secondes"],["Kilomètre par heure", "km/h|kilomètre par heure|kilomètres par heure|kilomètres par heures|kilometres par heure|kilometre par heure"],["Kilomètre par minute", "km/m|kilomètre par minute|kilomètres par minute|kilomètres par minutes|kilometre par minute|kilometre par minutes"],["Kilomètre par seconde", "km/s|km à la seconde|km a la seconde|kilomètre par seconde|kilomètres par seconde|kilometre par seconde|kilometres par seconde"],["Miles par heure", "mph|miles par heure|miles à l'heure|miles a l'heure|miles un heure"],["Noeuds", "noeud|noeuds|nuds"],["Pied par seconde", "ft/s|pied par seconde|pieds par seconde|pied/s|pieds/s"],["Pied par minute", "pieds/minute|pied/minute|ft/minute|ft/min|pied/min"]]); - export const AmbiguousSpeedUnitList = [ "noeud","noeuds","nuds" ]; - export const TemperatureSuffixList: ReadonlyMap = new Map([["Kelvin", "k|K|kelvin"],["F", "°f|° f|degres f|degrés f|deg f|degrés fahrenheit|degres fahrenheit|fahrenheit|deg fahrenheit|degs fahrenheit"],["R", "rankine|°r|° r"],["C", "°c|° c|degres c|degrés c|deg c|degrés celsius|degres celsius|celsius|deg celsius|degs celsius|centigrade|deg centigrade|degs centigrade|degrés centigrade|degres centigrade|degré centigrade|degre centigrade"],["Degré", "degrés|degres|deg.|°|degré|degre|deg|degs"]]); - export const VolumeSuffixList: ReadonlyMap = new Map([["Mètre cube", "m3|m^3|m³|mètre cube|mètres cube|metre cube|metres cube"],["Centimètre cube", "cm3|cm^3|cm³|centimètre cube|centimètres cube|centimetre cube|centimetres cube"],["Millimètre cube", "mm3|mm^3|mm³|millimètre cube|millimètres cube|millimetre cube|millimetres cube"],["Kilomètre cube", "km3|km^3|km³|kilomètre cube|kilomètres cube|kilometre cube|kilometres cube"],["Pieds cube", "pieds cubes|pieds cube|pied cube|pied cubes"],["Litre", "litre|litres|lts|l"],["Millilitre", "ml|millilitre|millilitres"],["Gallon", "gallon|gallons"],["Pintes", "pintes"],["Onces", "onces|once|oz"],["Décilitre", "dl|décilitre|decilitre|décilitres|decilitres"],["Centilitre", "cl|centilitres|centilitre"],["Onces liquides", "onces liquides|once liquide|once liquides"],["Baril", "baril|barils|bbl"]]); - export const AmbiguousVolumeUnitList = [ "oz","l" ]; - export const WeightSuffixList: ReadonlyMap = new Map([["Kilogramme", "kg|kilogramme|kilogrammes|kilo|kilos"],["Gram", "g|gramme|grammes"],["Milligramme", "mg|milligramme|milligrammes"],["Microgramme", "µg|ug|microgramme|microgrammes"],["Tonne métrique", "tonne métrique|tonnes métrique|tonnes métriques|tonne metrique|tonnes metrique"],["Tonne", "tonne|tonnes|-tonnes|-tonne"],["Livre", "livre|livres"]]); - export const AmbiguousWeightUnitList = [ "g","oz" ]; - export const AngleSuffixList: ReadonlyMap = new Map([["Degree", "degré|degrés|degre|degres|deg|°"],["Radian", "radian|radians|rad"],["Turn", "tour|tours"]]); - export const AmbiguousAngleUnitList = [ "tour","tours" ]; - export const AmbiguityFiltersDict: ReadonlyMap = new Map([["\\bcent\\b", "\\bpour\\s+cent\\b"]]); - export const TemperatureAmbiguityFiltersDict: ReadonlyMap = new Map([["\\b(deg(r[eé]s?)?|°)$", "\\b((deg(r[eé]s?)?|°)\\s*(angle|rotation)|(tourn([eé]|er|ant)|rotation|angle)(\\s+(\\p{L}+|\\d+)){0,4}\\s*(deg(r[eé]s?)?\\b|°))"]]); - export const DimensionAmbiguityFiltersDict: ReadonlyMap = new Map([["\\b(deg(r[eé]s?)?|°)$", "\\b((deg(r[eé]s?)?|°)\\s*(c(elsius|entigrade)?|f(ah?renheit)?)|(temp[eé]rature)(\\s+(\\p{L}+|\\d+)){0,4}\\s*(deg(r[eé]s?)?\\b|°))"]]); -} diff --git a/JavaScript/packages/recognizers-number-with-unit/src/resources/japaneseNumericWithUnit.ts b/JavaScript/packages/recognizers-number-with-unit/src/resources/japaneseNumericWithUnit.ts deleted file mode 100644 index 9b96c6f437..0000000000 --- a/JavaScript/packages/recognizers-number-with-unit/src/resources/japaneseNumericWithUnit.ts +++ /dev/null @@ -1,34 +0,0 @@ -// ------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// ------------------------------------------------------------------------------ - -import { BaseNumbers } from "./baseNumbers"; -export namespace JapaneseNumericWithUnit { - export const AgeAmbiguousValues = [ "歳" ]; - export const AgeSuffixList: ReadonlyMap = new Map([["Year", "歳"],["Month", "ヶ月"],["Week", "週間|週"],["Day", "日間|日齢|日大"]]); - export const BuildPrefix = ``; - export const BuildSuffix = ``; - export const ConnectorToken = ``; - export const CheckFirstSuffix = true; - export const CurrencySuffixList: ReadonlyMap = new Map([["Afghan afghani", "アフガニ"],["Pul", "プル"],["Euro", "ユーロ"],["Cent", "セント"],["Albanian lek", "アルバニアレク|アルバニア・レク|レク"],["Angolan kwanza", "アンゴラクワンザ|アンゴラ・クワンザ|クワンザ"],["Armenian dram", "アルメニアドラム|アルメニア・ドラム|ドラム"],["Aruban florin", "アルバ・フロリン|フロリン"],["Bangladeshi taka", "タカ|バングラデシュ・タカ"],["Paisa", "パイサ"],["Bhutanese ngultrum", "ニュルタム|ブータン・ニュルタム|ブータンニュルタム"],["Chetrum", "チェルタム"],["Bolivian boliviano", "ボリビアーノ"],["Bosnia and Herzegovina convertible mark", "兌換マルク"],["Botswana pula", "ボツワナ・プラ|ボツワナプラ|プラ"],["Thebe", "テベ"],["Brazilian real", "ブラジル・レアル|ブラジルレアル|レアル"],["Bulgarian lev", "ブルガリア・レフ|ブルガリアレフ|レフ"],["Stotinka", "ストティンカ"],["Cambodian riel", "カンボジア・リエル|カンボジアリエル|リエル"],["Cape Verdean escudo", "カーボベルデ・エスクード"],["Croatian kuna", "クロアチアクーナ|クロアチア・クーナ|クーナ"],["Lipa", "リパ"],["Eritrean nakfa", "エリトリア・ナクファ|エリトリアナクファ|ナクファ"],["Ethiopian birr", "エチオピア・ブル|エチオピアブル|ブル"],["Gambian dalasi", "ガンビア・ダラシ|ガンビアダラシ|ダラシ"],["Butut", "ブトゥツ"],["Georgian lari", "ジョージア・ラリ|ジョージアラリ|ラリ"],["Tetri", "テトリ"],["Ghanaian cedi", "ガーナ・セディ|ガーナセディ|セディ"],["Pesewa", "ペセワ"],["Guatemalan quetzal", "グアテマラ・ケツァル|グアテマラケツァル|ケツァル"],["Haitian gourde", "ハイチ・グールド|ハイチグールド|グールド"],["Honduran lempira", "ホンジュラス・レンピラ|ホンジュラスレンピラ|レンピラ"],["Hungarian forint", "ハンガリー・フォリント|ハンガリーフォリント|フォリント"],["Iranian rial", "イラン・リアル"],["Yemeni rial", "イエメン・リアル"],["Israeli new shekel", "₪|ils|イスラエル・新シェケル|イスラエル新シェケル"],["Japanese yen", "円"],["Sen", "銭"],["Kazakhstani tenge", "テンゲ|カザフスタン・テンゲ|カザフスタンテンゲ"],["Kenyan shilling", "ケニア・シリング"],["North Korean won", "北朝鮮ウォン"],["South Korean won", "韓国ウォン"],["Korean won", "₩"],["Kyrgyzstani som", "キルギス・ソム|ソム"],["Lao kip", "キップ|ラオス・キップ|ラオスキップ"],["Att", "att"],["Lesotho loti", "ロチ|レソト・ロチ|レソトロチ"],["South African rand", "ランド|南アフリカ・ランド|南アフリカランド"],["Macedonian denar", "マケドニア・デナール"],["Deni", "デニ"],["Malagasy ariary", "アリアリ|マダガスカル・アリアリ|マダガスカルアリアリ"],["Iraimbilanja", "イライムビランジャ"],["Malawian kwacha", "マラウイ・クワチャ"],["Tambala", "タンバラ"],["Malaysian ringgit", "リンギット|マレーシア・リンギット"],["Mauritanian ouguiya", "ウギア|モーリタニア・ウギア|モーリタニアウギア"],["Khoums", "コウム"],["Mozambican metical", "メティカル|モザンビーク・メティカル|モザンビークメティカル"],["Burmese kyat", "チャット|ミャンマー・チャット|ミャンマーチャット"],["Pya", "ピャー"],["Nigerian naira", "ナイラ|ナイジェリア・ナイラ|ナイジェリアナイラ"],["Kobo", "コボ"],["Turkish lira", "トルコリラ"],["Kuruş", "クルシュ"],["Omani rial", "オマーン・リアル"],["Panamanian balboa", "バルボア|パナマ・バルボア|パナマバルボア"],["Centesimo", "センテシモ"],["Papua New Guinean kina", "キナ|パプア・ニューギニア・キナ"],["Toea", "トエア"],["Peruvian sol", "ヌエボ・ソル"],["Polish złoty", "ズウォティ|ポーランド・ズウォティ|ポーランドズウォティ"],["Grosz", "グロシュ"],["Qatari riyal", "カタール・リヤル"],["Saudi riyal", "サウジアラビア・リヤル"],["Riyal", "リヤル"],["Dirham", "ディルハム"],["Halala", "ハララ"],["Samoan tālā", "タラ|サモア・タラ|サモアタラ"],["Sierra Leonean leone", "レオン|シエラレオネ・レオン|シエラレオネレオン"],["Peseta", "ペセタ"],["Swazi lilangeni", "リランゲニ|スワジランド・リランゲニ|スワジランドリランゲニ"],["Tajikistani somoni", "ソモニ|タジキスタン・ソモニ|タジキスタンソモニ"],["Thai baht", "バーツ|タイ・バーツ|タイバーツ"],["Satang", "サタン"],["Tongan paʻanga", "パアンガ|トンガ・パアンガ|トンガパアンガ"],["Ukrainian hryvnia", "フリヴニャ|ウクライナ・フリヴニャ|ウクライナフリヴニャ"],["Vanuatu vatu", "バツ|バヌアツ・バツ|バヌアツバツ"],["Vietnamese dong", "ドン|ベトナム・ドン|ベトナムドン"],["Indonesian rupiah", "ルピア|インドネシア・ルピア|インドネシアルピア"],["Netherlands guilder", "オランダ・ユーロ"],["Surinam florin", "スリナムフロリン"],["Zambian kwacha", "ザンビア・クワチャ"],["Moroccan dirham", "モロッコ・ディルハム"],["United Arab Emirates dirham", "UAEディルハム"],["Azerbaijani manat", "アゼルバイジャン・マナト"],["Turkmenistan manat", "トルクメニスタン・マナト"],["Manat", "マナト"],["Somali shilling", "ソマリア・シリング"],["Somaliland shilling", "ソマリランド・シリング"],["Tanzanian shilling", "タンザニア・シリング"],["Ugandan shilling", "ウガンダ・シリング"],["Romanian leu", "ルーマニア・レウ"],["Moldovan leu", "モルドバ・レウ"],["Leu", "レウ"],["Ban", "バン"],["Nepalese rupee", "ネパール・ルピー"],["Pakistani rupee", "パキスタン・ルピー"],["Indian rupee", "インド・ルピー"],["Seychellois rupee", "セーシェル・ルピー"],["Mauritian rupee", "モーリシャス・ルピー"],["Maldivian rufiyaa", "ルフィヤ|モルディブ・ルフィヤ|モルディブルフィヤ"],["Sri Lankan rupee", "スリランカ・ルピー"],["Rupee", "ルピー"],["Czech koruna", "チェコ・コルナ"],["Danish krone", "デンマーク・クローネ"],["Norwegian krone", "ノルウェー・クローネ"],["Faroese króna", "フェロー・クローネ"],["Icelandic króna", "アイスランド・クローナ"],["Swedish krona", "スウェーデン・クローナ"],["Krone", "クローナ"],["Øre", "オーレ"],["West African CFA franc", "西アフリカCFAフラン"],["Central African CFA franc", "中央アフリカCFAフラン"],["Comorian franc", "コモロ・フラン"],["Congolese franc", "コンゴ・フラン"],["Burundian franc", "ブルンジ・フラン"],["Djiboutian franc", "ジブチ・フラン"],["CFP franc", "CFPフラン"],["Guinean franc", "ギニア・フラン"],["Swiss franc", "スイス・フラン|スイスフラン"],["Rwandan franc", "ルワンダ・フラン"],["Belgian franc", "ベルギー・フラン"],["Rappen", "Rappen"],["Franc", "フラン"],["Centime", "サンチーム"],["Russian ruble", "ロシア・ルーブル"],["Transnistrian ruble", "沿ドニエストル・ルーブル"],["Belarusian ruble", "ベラルーシ・ルーブル"],["Kopek", "カペイカ"],["Ruble", "ルーブル"],["Algerian dinar", "アルジェリア・ディナール"],["Bahraini dinar", "バーレーン・ディナール"],["Iraqi dinar", "イラク・ディナール"],["Jordanian dinar", "ヨルダン・ディナール"],["Kuwaiti dinar", "クウェート・ディナール"],["Libyan dinar", "リビア・ディナール"],["Serbian dinar", "セルビア・ディナール"],["Tunisian dinar", "チュニジア・ディナール"],["Dinar", "ディナール"],["Fils", "フィルス"],["Para", "パラ"],["Millime", "ミリム"],["Argentine peso", "アルゼンチン・ペソ"],["Chilean peso", "チリ・ペソ"],["Colombian peso", "コロンビア・ペソ"],["Cuban peso", "兌換ペソ"],["Dominican peso", "ドミニカ・ペソ"],["Mexican peso", "メキシコ・ペソ"],["Philippine peso", "フィリピン・ペソ"],["Uruguayan peso", "ウルグアイ・ペソ"],["Peso", "ペソ"],["Centavo", "センターボ"],["Alderney pound", "オルダニーポンド"],["British pound", "UKポンド"],["Guernsey pound", "ガーンジー・ポンド"],["Saint Helena pound", "セントヘレナ・ポンド"],["Egyptian pound", "エジプト・ポンド"],["Falkland Islands pound", "フォークランド諸島ポンド"],["Gibraltar pound", "ジブラルタル・ポンド"],["Manx pound", "マン島ポンド"],["Jersey pound", "ジャージー・ポンド"],["Lebanese pound", "レバノン・ポンド"],["South Sudanese pound", "南スーダン・ポンド"],["Sudanese pound", "スーダン・ポンド"],["Syrian pound", "シリア・ポンド"],["Pound", "ポンド"],["Pence", "ペンス"],["Shilling", "シリング"],["United States dollar", "米ドル|USドル|ドル"],["East Caribbean dollar", "東カリブ・ドル"],["Australian dollar", "オーストラリア・ドル|オーストラリアドル"],["Bahamian dollar", "バハマ・ドル"],["Barbadian dollar", "バルバドス・ドル"],["Belize dollar", "ベリーズ・ドル"],["Bermudian dollar", "バミューダ・ドル"],["Brunei dollar", "ブルネイ・ドル"],["Singapore dollar", "シンガポール・ドル"],["Canadian dollar", "カナダ・ドル"],["Cayman Islands dollar", "ケイマン諸島・ドル"],["New Zealand dollar", "ニュージーランド・ドル"],["Cook Islands dollar", "クックアイランド・ドル"],["Fijian dollar", "フィジー・ドル|フィジー・ドル"],["Guyanese dollar", "ガイアナ・ドル|ガイアナ・ドル"],["Hong Kong dollar", "香港ドル"],["Macau Pataca", "マカオ・パタカ|マカオ・パタカ"],["New Taiwan dollar", "ニュー台湾ドル|ニュー台湾ドル|台湾ドル"],["Jamaican dollar", "ジャマイカ・ドル|ジャマイカドル"],["Kiribati dollar", "キリバス・ドル"],["Liberian dollar", "リベリア・ドル|リベリアドル"],["Namibian dollar", "ナミビア・ドル|ナミビアドル"],["Surinamese dollar", "スリナム・ドル|スリナムドル"],["Trinidad and Tobago dollar", "トリニダード・トバゴ・ドル|トリニダードトバゴ・ドル"],["Tuvaluan dollar", "ツバル・ドル|ツバルドル"],["Dollar", "どる|$"],["Chinese yuan", "人民元|元"],["Fen", "分"],["Jiao", "角"],["Finnish markka", "フィンランド・マルカ"],["Penni", "ペニー"]]); - export const CurrencyNameToIsoCodeMap: ReadonlyMap = new Map([["Afghan afghani", "AFN"],["Euro", "EUR"],["Albanian lek", "ALL"],["Angolan kwanza", "AOA"],["Armenian dram", "AMD"],["Aruban florin", "AWG"],["Bangladeshi taka", "BDT"],["Bhutanese ngultrum", "BTN"],["Bolivian boliviano", "BOB"],["Bosnia and Herzegovina convertible mark", "BAM"],["Botswana pula", "BWP"],["Brazilian real", "BRL"],["Bulgarian lev", "BGN"],["Cambodian riel", "KHR"],["Cape Verdean escudo", "CVE"],["Costa Rican colón", "CRC"],["Croatian kuna", "HRK"],["Czech koruna", "CZK"],["Eritrean nakfa", "ERN"],["Ethiopian birr", "ETB"],["Gambian dalasi", "GMD"],["Georgian lari", "GEL"],["Ghanaian cedi", "GHS"],["Guatemalan quetzal", "GTQ"],["Haitian gourde", "HTG"],["Honduran lempira", "HNL"],["Hungarian forint", "HUF"],["Iranian rial", "IRR"],["Yemeni rial", "YER"],["Israeli new shekel", "ILS"],["Japanese yen", "JPY"],["Kazakhstani tenge", "KZT"],["Kenyan shilling", "KES"],["North Korean won", "KPW"],["South Korean won", "KRW"],["Kyrgyzstani som", "KGS"],["Lao kip", "LAK"],["Lesotho loti", "LSL"],["South African rand", "ZAR"],["Macanese pataca", "MOP"],["Macedonian denar", "MKD"],["Malagasy ariary", "MGA"],["Malawian kwacha", "MWK"],["Malaysian ringgit", "MYR"],["Mauritanian ouguiya", "MRO"],["Mongolian tögrög", "MNT"],["Mozambican metical", "MZN"],["Burmese kyat", "MMK"],["Nicaraguan córdoba", "NIO"],["Nigerian naira", "NGN"],["Turkish lira", "TRY"],["Omani rial", "OMR"],["Panamanian balboa", "PAB"],["Papua New Guinean kina", "PGK"],["Paraguayan guaraní", "PYG"],["Peruvian sol", "PEN"],["Polish złoty", "PLN"],["Qatari riyal", "QAR"],["Saudi riyal", "SAR"],["Samoan tālā", "WST"],["São Tomé and Príncipe dobra", "STD"],["Sierra Leonean leone", "SLL"],["Swazi lilangeni", "SZL"],["Tajikistani somoni", "TJS"],["Thai baht", "THB"],["Ukrainian hryvnia", "UAH"],["Vanuatu vatu", "VUV"],["Venezuelan bolívar", "VEF"],["Zambian kwacha", "ZMW"],["Moroccan dirham", "MAD"],["United Arab Emirates dirham", "AED"],["Azerbaijani manat", "AZN"],["Turkmenistan manat", "TMT"],["Somali shilling", "SOS"],["Tanzanian shilling", "TZS"],["Ugandan shilling", "UGX"],["Romanian leu", "RON"],["Moldovan leu", "MDL"],["Nepalese rupee", "NPR"],["Pakistani rupee", "PKR"],["Indian rupee", "INR"],["Seychellois rupee", "SCR"],["Mauritian rupee", "MUR"],["Maldivian rufiyaa", "MVR"],["Sri Lankan rupee", "LKR"],["Indonesian rupiah", "IDR"],["Danish krone", "DKK"],["Norwegian krone", "NOK"],["Icelandic króna", "ISK"],["Swedish krona", "SEK"],["West African CFA franc", "XOF"],["Central African CFA franc", "XAF"],["Comorian franc", "KMF"],["Congolese franc", "CDF"],["Burundian franc", "BIF"],["Djiboutian franc", "DJF"],["CFP franc", "XPF"],["Guinean franc", "GNF"],["Swiss franc", "CHF"],["Rwandan franc", "RWF"],["Russian ruble", "RUB"],["Transnistrian ruble", "PRB"],["Belarusian ruble", "BYN"],["Algerian dinar", "DZD"],["Bahraini dinar", "BHD"],["Iraqi dinar", "IQD"],["Jordanian dinar", "JOD"],["Kuwaiti dinar", "KWD"],["Libyan dinar", "LYD"],["Serbian dinar", "RSD"],["Tunisian dinar", "TND"],["Argentine peso", "ARS"],["Chilean peso", "CLP"],["Colombian peso", "COP"],["Cuban convertible peso", "CUC"],["Cuban peso", "CUP"],["Dominican peso", "DOP"],["Mexican peso", "MXN"],["Uruguayan peso", "UYU"],["British pound", "GBP"],["Saint Helena pound", "SHP"],["Egyptian pound", "EGP"],["Falkland Islands pound", "FKP"],["Gibraltar pound", "GIP"],["Manx pound", "IMP"],["Jersey pound", "JEP"],["Lebanese pound", "LBP"],["South Sudanese pound", "SSP"],["Sudanese pound", "SDG"],["Syrian pound", "SYP"],["United States dollar", "USD"],["Australian dollar", "AUD"],["Bahamian dollar", "BSD"],["Barbadian dollar", "BBD"],["Belize dollar", "BZD"],["Bermudian dollar", "BMD"],["Brunei dollar", "BND"],["Singapore dollar", "SGD"],["Canadian dollar", "CAD"],["Cayman Islands dollar", "KYD"],["New Zealand dollar", "NZD"],["Fijian dollar", "FJD"],["Guyanese dollar", "GYD"],["Hong Kong dollar", "HKD"],["Jamaican dollar", "JMD"],["Liberian dollar", "LRD"],["Namibian dollar", "NAD"],["Solomon Islands dollar", "SBD"],["Surinamese dollar", "SRD"],["New Taiwan dollar", "TWD"],["Trinidad and Tobago dollar", "TTD"],["Tuvaluan dollar", "TVD"],["Chinese yuan", "CNY"],["Rial", "__RI"],["Shiling", "__S"],["Som", "__SO"],["Dirham", "__DR"],["Dinar", "_DN"],["Dollar", "__D"],["Manat", "__MA"],["Rupee", "__R"],["Krone", "__K"],["Krona", "__K"],["Crown", "__K"],["Frank", "__F"],["Mark", "__M"],["Ruble", "__RB"],["Peso", "__PE"],["Pound", "__P"],["Tristan da Cunha pound", "_TP"],["South Georgia and the South Sandwich Islands pound", "_SP"],["Somaliland shilling", "_SS"],["Pitcairn Islands dollar", "_PND"],["Palauan dollar", "_PD"],["Niue dollar", "_NID"],["Nauruan dollar", "_ND"],["Micronesian dollar", "_MD"],["Kiribati dollar", "_KID"],["Guernsey pound", "_GGP"],["Faroese króna", "_FOK"],["Cook Islands dollar", "_CKD"],["British Virgin Islands dollar", "_BD"],["Ascension pound", "_AP"],["Alderney pound", "_ALP"],["Abkhazian apsar", "_AA"]]); - export const FractionalUnitNameToCodeMap: ReadonlyMap = new Map([["Jiao", "JIAO"],["Kopek", "KOPEK"],["Pul", "PUL"],["Cent", "CENT"],["Qindarkë", "QINDARKE"],["Penny", "PENNY"],["Santeem", "SANTEEM"],["Cêntimo", "CENTIMO"],["Centavo", "CENTAVO"],["Luma", "LUMA"],["Qəpik", "QƏPIK"],["Fils", "FILS"],["Poisha", "POISHA"],["Kapyeyka", "KAPYEYKA"],["Centime", "CENTIME"],["Chetrum", "CHETRUM"],["Paisa", "PAISA"],["Fening", "FENING"],["Thebe", "THEBE"],["Sen", "SEN"],["Stotinka", "STOTINKA"],["Fen", "FEN"],["Céntimo", "CENTIMO"],["Lipa", "LIPA"],["Haléř", "HALER"],["Øre", "ØRE"],["Piastre", "PIASTRE"],["Santim", "SANTIM"],["Oyra", "OYRA"],["Butut", "BUTUT"],["Tetri", "TETRI"],["Pesewa", "PESEWA"],["Fillér", "FILLER"],["Eyrir", "EYRIR"],["Dinar", "DINAR"],["Agora", "AGORA"],["Tïın", "TIIN"],["Chon", "CHON"],["Jeon", "JEON"],["Tyiyn", "TYIYN"],["Att", "ATT"],["Sente", "SENTE"],["Dirham", "DIRHAM"],["Rappen", "RAPPEN"],["Avo", "AVO"],["Deni", "DENI"],["Iraimbilanja", "IRAIMBILANJA"],["Tambala", "TAMBALA"],["Laari", "LAARI"],["Khoums", "KHOUMS"],["Ban", "BAN"],["Möngö", "MONGO"],["Pya", "PYA"],["Kobo", "KOBO"],["Kuruş", "KURUS"],["Baisa", "BAISA"],["Centésimo", "CENTESIMO"],["Toea", "TOEA"],["Sentimo", "SENTIMO"],["Grosz", "GROSZ"],["Sene", "SENE"],["Halala", "HALALA"],["Para", "PARA"],["Öre", "ORE"],["Diram", "DIRAM"],["Satang", "SATANG"],["Seniti", "SENITI"],["Millime", "MILLIME"],["Tennesi", "TENNESI"],["Kopiyka", "KOPIYKA"],["Tiyin", "TIYIN"],["Hào", "HAO"],["Ngwee", "NGWEE"]]); - export const CompoundUnitConnectorRegex = `(?と)`; - export const CurrencyPrefixList: ReadonlyMap = new Map([["Dollar", "$"],["United States dollar", "us$"],["British Virgin Islands dollar", "bvi$"],["Brunei dollar", "b$"],["Sen", "sen"],["Singapore dollar", "s$"],["Canadian dollar", "can$|c$|c $"],["Cayman Islands dollar", "ci$"],["New Zealand dollar", "nz$|nz $"],["Guyanese dollar", "gy$|gy $|g$|g $"],["Hong Kong dollar", "hk$|hkd|hk $"],["Jamaican dollar", "j$"],["Namibian dollar", "nad|n$|n $"],["Solomon Islands dollar", "si$|si $"],["New Taiwan dollar", "nt$|nt $"],["Samoan tālā", "ws$"],["Chinese yuan", "¥|人民元"],["Japanese yen", "¥|\\"],["Turkish lira", "₺"],["Euro", "€"],["Pound", "£"],["Costa Rican colón", "₡"]]); - export const CurrencyAmbiguousValues = [ "円","銭","分","レク","プル","ブル","\\","元" ]; - export const DimensionSuffixList: ReadonlyMap = new Map([["Meter", "米|公尺|m|メートル"],["Kilometer", "千米|公里|km|キロメートル"],["Decimeter", "分米|公寸|dm|デシメートル"],["Millimeter", "ミリ"],["Centimeter", "釐米|厘米|公分|cm|センチ"],["Micrometer", "毫米|公釐|mm"],["Microns", "微米"],["Picometer", "皮米|ピクトメーター|pm"],["Nanometer", "纳米"],["Mile", "英里|マイル"],["Inch", "英寸|インチ"],["Foot", "呎|英尺|フィート"],["Yard", "码"],["Knot", "海里"],["Light year", "光年"],["Meter per second", "米每秒|米/秒|m/s|秒速メートル|毎秒メートル"],["Kilometer per hour", "公里每小时|千米每小时|公里/小时|千米/小时|km/h|時速キロメートル"],["Kilometer per minute", "公里每分钟|千米每分钟|公里/分钟|千米/分钟|km/min|分速キロメートル"],["Kilometer per second", "公里每秒|千米每秒|公里/秒|千米/秒|km/s|秒速キロメートル|毎秒キロメートル"],["Mile per hour", "英里每小时|英里/小时|時速マイル"],["Foot per second", "英尺每小时|英尺/小时"],["Foot per minute", "英尺每分钟|英尺/分钟"],["Yard per minute", "码每分|码/分"],["Yard per second", "码每秒|码/秒"],["Square centimetre", "平方厘米"],["Square decimeter", "平方分米"],["Square meter", "平方米|平方メートル"],["Square kilometer", "平方公里|平方キロメートル"],["Acre", "英亩|公亩|エーカー"],["Hectare", "公顷"],["Mu", "亩|市亩|ムー"],["Liter", "公升|升|l"],["Milliliter", "毫升|ml|ミリリットル"],["Cubic meter", "立方米"],["Cubic decimeter", "立方分米"],["Cubic millimeter", "立方毫米"],["Cubic foot", "立方英尺|立方フィート"],["Gallon", "加仑|ガロン"],["Pint", "品脱"],["Dou", "市斗|斗"],["Dan", "市石|石"],["Kilogram", "千克|公斤|kg|キログラム"],["Gram", "克|g"],["Milligram", "毫克|mg"],["Microgram", "微克|μg"],["Ton", "公吨|吨|t|トン"],["Metric ton", "メートルトン"],["Pound", "磅|ポンド"],["Ounce", "盎司|オンス"],["Jin", "市斤|斤"],["Liang", "两"],["Barrel", "桶"],["Pot", "罐"],["Bit", "比特|位|b|bit|ビット"],["Kilobit", "千比特|千位|kb|Kb"],["Megabit", "兆比特|兆位|mb|Mb|メガバイト"],["Gigabit", "十亿比特|千兆比特|十亿位|千兆位|gb|Gb"],["Terabit", "万亿比特|兆兆比特|万亿位|兆兆位|tb|Tb"],["Petabit", "千兆兆比特|千万亿比特|千兆兆位|千万亿位|pb|Pb"],["Byte", "字节|byte|Byte"],["Kilobyte", "千字节|kB|KB"],["Megabyte", "兆字节|mB|MB"],["Gigabyte", "十亿字节|千兆字节|gB|GB"],["Terabyte", "万亿字节|兆兆字节|tB|TB"],["Petabyte", "千兆兆字节|千万亿字节|pB|PB"]]); - export const DimensionPrefixList: ReadonlyMap = new Map([["split_unit", "時速|分速|秒速|毎秒"]]); - export const DimensionAmbiguousValues = [ "丈","位","克","分","升","寸","尺","斗","斤","桶","毫","石","码","磅","米","罐","里","m","km","dm","cm","mm","l","ml","kg","mg","g","t","b","byte","kb","mb","gb","tb","pb","時速","トン" ]; - export const AmbiguityFiltersDict: ReadonlyMap = new Map([["五角", "五角大楼"],["普尔", "标准普尔"]]); - export const TemperatureSuffixList: ReadonlyMap = new Map([["F", "華氏|華氏温度|華氏温度の|°f"],["K", "开尔文温度|开氏度|凯氏度|K|k"],["R", "兰氏温度|°r"],["C", "摂氏|摂氏温度|°c|℃"],["Degree", "度"]]); - export const TemperaturePrefixList: ReadonlyMap = new Map([["F", "華氏|華氏温度|華氏温度の|华氏"],["K", "开氏温度|开氏"],["R", "兰氏温度|兰氏"],["C", "摂氏温度|摂氏"]]); - export const TemperatureAmbiguousValues = [ "度","k" ]; - export const HalfUnitRegex = `半`; -} diff --git a/JavaScript/packages/recognizers-number-with-unit/src/resources/portugueseNumericWithUnit.ts b/JavaScript/packages/recognizers-number-with-unit/src/resources/portugueseNumericWithUnit.ts deleted file mode 100644 index ba743d7f11..0000000000 --- a/JavaScript/packages/recognizers-number-with-unit/src/resources/portugueseNumericWithUnit.ts +++ /dev/null @@ -1,42 +0,0 @@ -// ------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// ------------------------------------------------------------------------------ - -import { BaseNumbers } from "./baseNumbers"; -export namespace PortugueseNumericWithUnit { - export const AgeSuffixList: ReadonlyMap = new Map([["Ano", "anos|ano"],["Mês", "meses|mes|mês"],["Semana", "semanas|semana"],["Dia", "dias|dia"]]); - export const AmbiguousAgeUnitList = [ "anos","ano","meses","mes","mês","semanas","semana","dias","dia" ]; - export const AreaSuffixList: ReadonlyMap = new Map([["Quilômetro quadrado", "quilômetro quadrado|quilómetro quadrado|quilometro quadrado|quilômetros quadrados|quilómetros quadrados|quilomeros quadrados|km2|km^2|km²"],["Hectare", "hectômetro quadrado|hectómetro quadrado|hectômetros quadrados|hectómetros cuadrados|hm2|hm^2|hm²|hectare|hectares"],["Decâmetro quadrado", "decâmetro quadrado|decametro quadrado|decâmetros quadrados|decametro quadrado|dam2|dam^2|dam²|are|ares"],["Metro quadrado", "metro quadrado|metros quadrados|m2|m^2|m²"],["Decímetro quadrado", "decímetro quadrado|decimentro quadrado|decímetros quadrados|decimentros quadrados|dm2|dm^2|dm²"],["Centímetro quadrado", "centímetro quadrado|centimetro quadrado|centímetros quadrados|centrimetros quadrados|cm2|cm^2|cm²"],["Milímetro quadrado", "milímetro quadrado|milimetro quadrado|milímetros quadrados|militmetros quadrados|mm2|mm^2|mm²"],["Polegada quadrada", "polegada quadrada|polegadas quadradas|in2|in^2|in²"],["Pé quadrado", "pé quadrado|pe quadrado|pés quadrados|pes quadrados|pé2|pé^2|pé²|sqft|sq ft|ft2|ft^2|ft²"],["Jarda quadrada", "jarda quadrada|jardas quadradas|yd2|yd^2|yd²"],["Milha quadrada", "milha quadrada|milhas quadradas|mi2|mi^2|mi²"],["Acre", "acre|acres"]]); - export const CurrencySuffixList: ReadonlyMap = new Map([["Dólar", "dólar|dolar|dólares|dolares"],["Peso", "peso|pesos"],["Coroa", "coroa|coroas"],["Rublo", "rublo|rublos"],["Libra", "libra|libras"],["Florim", "florim|florins|ƒ"],["Dinar", "dinar|dinares"],["Franco", "franco|francos"],["Rupia", "rúpia|rupia|rúpias|rupias"],["Escudo", "escudo|escudos"],["Xelim", "xelim|xelins|xelims"],["Lira", "lira|liras"],["Centavo", "centavo|cêntimo|centimo|centavos|cêntimos|centimo"],["Centésimo", "centésimo|centésimos"],["Pêni", "pêni|péni|peni|penies|pennies"],["Manat", "manat|manate|mánate|man|manats|manates|mánates"],["Euro", "euro|euros|€|eur"],["Centavo de Euro", "centavo de euro|cêntimo de euro|centimo de euro|centavos de euro|cêntimos de euro|centimos de euro"],["Dólar do Caribe Oriental", "dólar do Caribe Oriental|dolar do Caribe Oriental|dólares do Caribe Oriental|dolares do Caribe Oriental|dólar das Caraíbas Orientais|dolar das Caraibas Orientais|dólares das Caraíbas Orientais|dolares das Caraibas Orientais|ec$|xcd"],["Centavo do Caribe Oriental", "centavo do Caribe Oriental|centavo das Caraíbas Orientais|cêntimo do Caribe Oriental|cêntimo das Caraíbas Orientais|centavos do Caribe Oriental|centavos das Caraíbas Orientais|cêntimos do Caribe Oriental|cêntimos das Caraíbas Orientais"],["Franco CFA da África Ocidental", "franco CFA da África Ocidental|franco CFA da Africa Ocidental|francos CFA da África Occidental|francos CFA da Africa Occidental|franco CFA Ocidental|xof"],["Centavo de CFA da África Ocidental", "centavo de CFA da Africa Occidental|centavos de CFA da África Ocidental|cêntimo de CFA da Africa Occidental|cêntimos de CFA da África Ocidental"],["Franco CFA da África Central", "franco CFA da África Central|franco CFA da Africa Central|francos CFA da África Central|francos CFA da Africa Central|franco CFA central|xaf"],["Centavo de CFA da África Central", "centavo de CFA de África Central|centavos de CFA da África Central|cêntimo de CFA de África Central|cêntimos de CFA da África Central"],["Apsar abcásio", "apsar abcásio|apsar abecásio|apsar abcasio|apsar|apsares"],["Afegani afegão", "afegani afegão|afegane afegão|؋|afn|afegane|afgane|afegâni|afeganis|afeganes|afganes|afegânis"],["Pul", "pul|pules|puls"],["Lek albanês", "lek|lekë|lekes|lek albanês|leque|leques|all"],["Qindarke", "qindarka|qindarkë|qindarke|qindarkas"],["Kwanza angolano", "kwanza angolano|kwanzas angolanos|kwanza|kwanzas|aoa|kz"],["Cêntimo angolano", "cêntimo angolano"],["Florim das Antilhas Holandesas", "florim das antilhas holandesas|florim das antilhas neerlandesas|ang"],["Rial saudita", "rial saudita|riais sauditas|riyal saudita|riyals sauditas|riyal|riyals|sar"],["Halala saudita", "halala saudita|halala|hallalah"],["Dinar argelino", "dinar argelino|dinares argelinos|dzd"],["Cêntimo argelino", "centimo argelino|centimos argelinos|cêntimo argelino|cêntimos argelinos|centavo argelino|centavos argelinos"],["Peso argentino", "peso argentino|pesos argentinos|ar$|ars"],["Centavo argentino", "centavo argentino|centavos argentinos|ctvo.|ctvos."],["Dram armênio", "dram armênio|dram armênios|dram arménio|dram arménios|dram armenio|dram armenios|dram|drame|drames|դր."],["Luma armênio", "luma armênio|lumas armênios|luma arménio|lumas arménios|luma armenio|lumas armenios|luma|lumas"],["Florim arubano", "florín arubeño|florines arubeños|ƒ arubeños|aƒ|awg"],["Dólar australiano", "dólar australiano|dólares australianos|dolar australiano|dolares australianos|a$|aud"],["Centavo australiano", "centavo australiano|centavos australianos"],["Manat azeri", "manat azeri|manats azeris|azn|manat azerbaijanês|manat azerbaijano|manats azerbaijaneses|manats azerbaijanos"],["Qəpik azeri", "qəpik azeri|qəpik|qəpiks"],["Dólar bahamense", "dólar bahamense|dólares bahamense|dolar bahamense|dolares bahamense|dólar baamiano|dólares baamiano|dolar baamiano|dolares baamiano|b$|bsd"],["Centavo bahamense", "centavo bahamense|centavos bahamense"],["Dinar bareinita", "dinar bareinita|dinar baremita|dinares bareinitas|dinares baremitas|bhd"],["Fil bareinita", "fil bareinita|fil baremita|fils bareinitas|fils baremitas"],["Taka bengali", "taka bengali|takas bengalis|taca|tacas|taka|takas|bdt"],["Poisha bengali", "poisha bengali|poishas bengalis"],["Dólar de Barbados", "dólar de barbados|dólares de barbados|dolar de barbados|dolares de barbados|dólar dos barbados|dólares dos barbados|bbd"],["Centavo de Barbados", "centavo de barbados|centavos de barbados|centavo dos barbados|centavos dos barbados"],["Dólar de Belize", "dólar de belize|dólares de belize|dolar de belize|dolares de belize|dólar do belize|dólares do belize|dolar do belize|dolares do belize|bz$|bzd"],["Centavo de Belize", "centavo de belize|centavos de belize|cêntimo do belize|cêntimos do belize"],["Dólar bermudense", "dólar bermudense|dólares bermudenses|bd$|bmd"],["Centavo bermudense", "centavo bermudense|centavos bermudenses|cêntimo bermudense| cêntimos bermudenses"],["Rublo bielorrusso", "rublo bielorrusso|rublos bielorrussos|byr"],["Copeque bielorusso", "copeque bielorrusso|copeques bielorrussos|kopek bielorrusso|kopeks bielorrussos|kap"],["Quiate mianmarense", "quiate mianmarense|quiates mianmarenses|kyat mianmarense|kyates mianmarenses|quiate myanmarense|quiates myanmarenses|kyat myanmarense|kyates myanmarenses|quiate birmanês|quite birmanes|quiates birmaneses|kyat birmanês|kyat birmanes|kyates birmaneses|mmk"],["Pya mianmarense", "pya mianmarense|pyas mianmarenses|pya myanmarense|pyas myanmarenses|pya birmanês|pya birmanes|pyas birmaneses"],["Boliviano", "boliviano|bolivianos|bob|bs"],["Centavo Boliviano", "centavo boliviano|centavos bolivianos"],["Marco da Bósnia e Herzegovina", "marco conversível|marco conversivel|marco convertível|marco convertivel|marcos conversíveis|marcos conversiveis|marcos convertíveis|marcos convertivies|bam"],["Fening da Bósnia e Herzegovina", "fening conversível|fening conversivel|fening convertível|fening convertivel|fenings conversíveis|fenings conversiveis|fenings convertíveis|fenings convertiveis"],["Pula", "pula|pulas|bwp"],["Thebe", "thebe|thebes"],["Real brasileiro", "real brasileiro|real do brasil|real|reais brasileiros|reais do brasil|reais|r$|brl"],["Centavo brasileiro", "centavo de real|centavo brasileiro|centavos de real|centavos brasileiros"],["Dólar de Brunei", "dólar de brunei|dolar de brunei|dólar do brunei|dolar do brunei|dólares de brunéi|dolares de brunei|dólares do brunei|dolares do brunei|bnd"],["Sen de Brunei", "sen de brunei|sen do brunei|sens de brunei|sens do brunei"],["Lev búlgaro", "lev búlgaro|leve búlgaro|leves búlgaros|lev bulgaro|leve bulgaro|leves bulgaros|lv|bgn"],["Stotinka búlgaro", "stotinka búlgaro|stotinki búlgaros|stotinka bulgaro|stotinki bulgaros"],["Franco do Burundi", "franco do burundi|francos do burundi|fbu|fib"],["Centavo Burundi", "centavo burundi|cêntimo burundi|centimo burundi|centavos burundi|cêntimo burundi|centimo burundi"],["Ngultrum butanês", "ngultrum butanês|ngultrum butanes|ngúltrume butanês|ngultrume butanes|ngultrum butaneses|ngúltrumes butaneses|ngultrumes butaneses|btn"],["Chetrum butanês", "chetrum butanês|chetrum butanes|chetrum butaneses"],["Escudo cabo-verdiano", "escudo cabo-verdiano|escudos cabo-verdianos|cve"],["Riel cambojano", "riel cambojano|riéis cambojanos|rieis cambojanos|khr"],["Dólar canadense", "dólar canadense|dolar canadense|dólares canadenses|dolares canadenses|c$|cad"],["Centavo canadense", "centavo canadense|centavos canadenses"],["Peso chileno", "peso chileno|pesos chilenos|cpl"],["Yuan chinês", "yuan chinês|yuan chines|yuans chineses|yuan|yuans|renminbi|rmb|cny|¥"],["Peso colombiano", "peso colombiano|pesos colombianos|cop|col$"],["Centavo colombiano", "centavo colombiano|centavos colombianos"],["Franco comorense", "franco comorense|francos comorenses|kmf|₣"],["Franco congolês", "franco congolês|franco congoles|francos congoleses|cdf"],["Centavo congolês", "centavo congolês|centavo congoles|centavos congoleses|cêntimo congolês|centimo congoles|cêntimos congoleses|cêntimos congoleses"],["Won norte-coreano", "won norte-coreano|wŏn norte-coreano|won norte-coreanos|wŏn norte-coreanos|kpw"],["Chon norte-coreano", "chon norte-coreano|chŏn norte-coreano|chŏn norte-coreanos|chon norte-coreanos"],["Won sul-coreano", "wŏn sul-coreano|won sul-coreano|wŏnes sul-coreanos|wones sul-coreanos|krw"],["Jeon sul-coreano", "jeons sul-coreano|jeons sul-coreanos"],["Colón costarriquenho", "colón costarriquenho|colon costarriquenho|colons costarriquenho|colones costarriquenhos|crc"],["Kuna croata", "kuna croata|kunas croatas|hrk"],["Lipa croata", "lipa croata|lipas croatas"],["Peso cubano", "peso cubano|pesos cubanos|cup"],["Peso cubano convertível", "peso cubano conversível|pesos cubanos conversíveis|peso cubano conversivel|pesos cubanos conversiveis|peso cubano convertível|pesos cubanos convertíveis|peso cubano convertivel|pesos cubanos convertiveis|cuc"],["Coroa dinamarquesa", "coroa dinamarquesa|coroas dinamarquesas|dkk"],["Libra egípcia", "libra egípcia|libra egipcia|libras egípcias|libras egipcias|egp|l.e."],["Piastra egípcia", "piastra egípcia|piastra egipcia|pisastras egípcias|piastras egipcias"],["Dirham dos Emirados Árabes Unidos", "dirham|dirhams|dirham dos emirados arabes unidos|aed|dhs"],["Nakfa", "nakfa|nfk|ern"],["Centavo de Nakfa", "cêntimo de nakfa|cêntimos de nakfa|centavo de nafka|centavos de nafka"],["Peseta", "peseta|pesetas|pts.|ptas.|esp"],["Dólar estadunidense", "dólar dos estados unidos|dolar dos estados unidos|dólar estadunidense|dólar americano|dólares dos estados unidos|dolares dos estados unidos|dólares estadunidenses|dólares americanos|dolar estadunidense|dolar americano|dolares estadunidenses|dolares americanos|usd|u$d|us$|usd$"],["Coroa estoniana", "coroa estoniana|coroas estonianas|eek"],["Senti estoniano", "senti estoniano|senti estonianos"],["Birr etíope", "birr etíope|birr etiope|birr etíopes|birr etiopes|br|etb"],["Santim etíope", "santim etíope|santim etiope|santim etíopes|santim etiopes"],["Peso filipino", "peso filipino|pesos filipinos|php"],["Marco finlandês", "marco finlandês|marco finlandes|marcos finlandeses"],["Dólar fijiano", "dólar fijiano|dolar fijiano|dólares fijianos|dolares fijianos|fj$|fjd"],["Centavo fijiano", "centavo fijiano|centavos fijianos"],["Dalasi gambiano", "dalasi|gmd"],["Bututs", "butut|bututs"],["Lari georgiano", "lari georgiano|lari georgianos|gel"],["Tetri georgiano", "tetri georgiano|tetri georgianos"],["Cedi", "cedi|ghs|gh₵"],["Pesewa", "pesewa"],["Libra de Gibraltar", "libra de gibraltar|libras de gibraltar|gip"],["Peni de Gibraltar", "peni de gibraltar|penies de gibraltar"],["Quetzal guatemalteco", "quetzal guatemalteco|quetzales guatemaltecos|quetzal|quetzales|gtq"],["Centavo guatemalteco", "centavo guatemalteco|centavos guatemaltecos"],["Libra de Guernsey", "libra de Guernsey|libras de Guernsey|ggp"],["Peni de Guernsey", "peni de Guernsey|penies de Guernsey"],["Franco da Guiné", "franco da guiné|franco da guine| franco guineense|francos da guiné|francos da guine|francos guineense|gnf|fg"],["Centavo da Guiné", "cêntimo guineense|centimo guineense|centavo guineense|cêntimos guineenses|centimos guineenses|centavos guineenses"],["Dólar guianense", "dólar guianense|dólares guianense|dolar guianense|dolares guianense|gyd|gy"],["Gurde haitiano", "gurde haitiano|gourde|gurdes haitianos|htg"],["Centavo haitiano", "cêntimo haitiano|cêntimos haitianos|centavo haitiano|centavos haitianos"],["Lempira hondurenha", "lempira hondurenha|lempiras hondurenhas|lempira|lempiras|hnl"],["Centavo hondurenho", "centavo hondurenho|centavos hondurehos|cêntimo hondurenho|cêntimos hondurenhos"],["Dólar de Hong Kong", "dólar de hong kong|dolar de hong kong|dólares de hong kong|dolares de hong kong|hk$|hkd"],["Florim húngaro", "florim húngaro|florim hungaro|florins húngaros|florins hungaros|forinte|forintes|huf"],["Filér húngaro", "fillér|filér|filler|filer"],["Rupia indiana", "rúpia indiana|rupia indiana|rupias indianas|inr"],["Paisa indiana", "paisa indiana|paisas indianas"],["Rupia indonésia", "rupia indonesia|rupia indonésia|rupias indonesias|rupias indonésias|idr"],["Sen indonésio", "send indonésio|sen indonesio|sen indonésios|sen indonesios"],["Rial iraniano", "rial iraniano|riais iranianos|irr"],["Dinar iraquiano", "dinar iraquiano|dinares iraquianos|iqd"],["Fil iraquiano", "fil iraquiano|fils iraquianos|files iraquianos"],["Libra manesa", "libra manesa|libras manesas|imp"],["Peni manês", "peni manes|peni manês|penies maneses"],["Coroa islandesa", "coroa islandesa|coroas islandesas|isk|íkr"],["Aurar islandês", "aurar islandês|aurar islandes|aurar islandeses|eyrir"],["Dólar das Ilhas Cayman", "dólar das ilhas cayman|dolar das ilhas cayman|dólar das ilhas caimão|dólares das ilhas cayman|dolares das ilhas cayman|dólares das ilhas caimão|ci$|kyd"],["Dólar das Ilhas Cook", "dólar das ilhas cook|dolar das ilhas cook|dólares das ilhas cook|dolares das ilhas cook"],["Coroa feroesa", "coroa feroesa|coroas feroesas|fkr"],["Libra das Malvinas", "libra das malvinas|libras das malvinas|fk£|fkp"],["Dólar das Ilhas Salomão", "dólar das ilhas salomão|dolar das ilhas salomao|dólares das ilhas salomão|dolares das ilhas salomao|sbd"],["Novo shekel israelense", "novo shekel|novos shekeles|novo shequel|novo siclo|novo xéquel|shekeles novos|novos sheqalim|sheqalim novos|ils|₪"],["Agora", "agora|agorot"],["Dólar jamaicano", "dólar jamaicano|dolar jamaicano|dólares jamaicanos|dolares jamaicanos|j$|ja$|jmd"],["Yen", "yen|iene|yenes|ienes|jpy"],["Libra de Jersey", "libra de Jersey|libras de Jersey|jep"],["Dinar jordaniano", "dinar jordaniano|dinar jordano|dinares jordanianos|dinares jordanos|jd|jod"],["Piastra jordaniana", "piastra jordaniana|piastra jordano|piastras jordanianas|piastra jordaniano|piastras jordanianos|piastras jordanos"],["Tengue cazaque", "tenge|tengue|tengué|tengue cazaque|kzt"],["Tiyin", "tiyin|tiyins"],["Xelim queniano", "xelim queniano|xelins quenianos|ksh|kes"],["Som quirguiz", "som quirguiz|som quirguizes|soms quirguizes|kgs"],["Tyiyn", "tyiyn|tyiyns"],["Dólar de Kiribati", "dólar de kiribati|dolar de kiribati|dólares de kiribati|dolares de kiribati"],["Dinar kuwaitiano", "dinar kuwaitiano|dinar cuaitiano|dinares kuwaitiano|dinares cuaitianos|kwd"],["Quipe laosiano", "quipe|quipes|kipe|kipes|kip|kip laosiano|kip laociano|kips laosianos|kips laocianos|lak"],["Att laosiano", "at|att|att laosiano|att laosianos"],["Loti do Lesoto", "loti|lóti|maloti|lotis|lótis|lsl"],["Sente", "sente|lisente"],["Libra libanesa", "libra libanesa|libras libanesas|lbp"],["Dólar liberiano", "dólar liberiano|dolar liberiano|dólares liberianos|dolares liberianos|l$|lrd"],["Dinar libio", "dinar libio|dinar líbio|dinares libios|dinares líbios|ld|lyd"],["Dirham libio", "dirham libio|dirhams libios|dirham líbio|dirhams líbios"],["Litas lituana", "litas lituana|litai lituanas|ltl"],["Pataca macaense", "pataca macaense|patacas macaenses|mop$|mop"],["Avo macaense", "avo macaense|avos macaenses"],["Ho macaense", "ho macaense|ho macaenses"],["Dinar macedônio", "denar macedonio|denare macedonios|denar macedônio|denar macedónio|denare macedônio|denare macedónio|dinar macedonio|dinar macedônio|dinar macedónio|dinares macedonios|dinares macedônios|dinares macedónios|den|mkd"],["Deni macedônio", "deni macedonio|deni macedônio|deni macedónio|denis macedonios|denis macedônios|denis macedónios"],["Ariary malgaxe", "ariai malgaxe|ariary malgaxe|ariary malgaxes|ariaris|mga"],["Iraimbilanja", "iraimbilanja|iraimbilanjas"],["Ringuite malaio", "ringgit malaio|ringgit malaios|ringgits malaios|ringuite malaio|ringuites malaios|rm|myr"],["Sen malaio", "sen malaio|sen malaios|centavo malaio|centavos malaios|cêntimo malaio|cêntimos malaios"],["Kwacha do Malawi", "kwacha|cuacha|quacha|mk|mwk"],["Tambala", "tambala|tambalas|tambala malawi"],["Rupia maldiva", "rupia maldiva|rupias maldivas|rupia das maldivas| rupias das maldivas|mvr"],["Dirame marroquino", "dirame marroquino|dirham marroquinho|dirhams marroquinos|dirames marroquinos|mad"],["Rupia maurícia", "rupia maurícia|rupia de Maurício|rupia mauricia|rupia de mauricio|rupias de mauricio|rupias de maurício|rupias mauricias|rupias maurícias|mur"],["Uguia", "uguia|uguias|oguia|ouguiya|oguias|mro"],["Kume", "kumes|kume|khoums"],["Peso mexicano", "peso mexicano|pesos mexicanos|mxn"],["Centavo mexicano", "centavo mexicano|centavos mexicanos"],["Leu moldávio", "leu moldavo|lei moldavos|leu moldávio|leu moldavio|lei moldávios|lei moldavios|leus moldavos|leus moldavios|leus moldávios|mdl"],["Ban moldávio", "ban moldavo|bani moldavos"],["Tugrik mongol", "tugrik mongol|tugrik|tugriks mongóis|tugriks mongois|tug|mnt"],["Metical moçambicao", "metical|metical moçambicano|metical mocambicano|meticais|meticais moçambicanos|meticais mocambicanos|mtn|mzn"],["Dólar namibiano", "dólar namibiano|dólares namibianos|dolar namibio|dolares namibios|n$|nad"],["Centavo namibiano", "centavo namibiano|centavos namibianos|centavo namibio|centavos namibianos"],["Rupia nepalesa", "rupia nepalesa|rupias nepalesas|npr"],["Paisa nepalesa", "paisa nepalesa|paisas nepalesas"],["Córdova nicaraguense", "córdova nicaraguense|cordova nicaraguense|cordova nicaraguana|córdoba nicaragüense|córdobas nicaragüenses|cordobas nicaraguenses|córdovas nicaraguenses|cordovas nicaraguenses|córdovas nicaraguanasc$|nio"],["Centavo nicaraguense", "centavo nicaragüense|centavos nicaraguenses|centavo nicaraguano|centavos nicaraguenses|centavo nicaraguano|centavos nicaraguanos"],["Naira", "naira|ngn"],["Kobo", "kobo"],["Coroa norueguesa", "coroa norueguesa|coroas norueguesas|nok"],["Franco CFP", "franco cfp|francos cfp|xpf"],["Dólar neozelandês", "dólar neozelandês|dolar neozelandes|dólares neozelandeses|dolares neozelandeses|dólar da nova zelândia|dolar da nova zelandia|dólares da nova zelândia|dolares da nova zelandia|nz$|nzd"],["Centavo neozelandês", "centavo neozelandês|centavo neozelandes|centavo da nova zelandia|centavo da nova zelândia|centavos da nova zelandia|centavos neozelandeses|centavos da nova zelândia"],["Rial omanense", "rial omani|riais omanis|rial omanense|riais omanenses|omr"],["Baisa omanense", "baisa omani|baisas omanis|baisa omanense|baisas omanenses"],["Florim holandês", "florim holandês|florim holandes|florins holandeses|nlg"],["Rupia paquistanesa", "rupia paquistanesa|rupias paquistanesas|pkr"],["Paisa paquistanesa", "paisa paquistanesa|paisas paquistanesasas"],["Balboa panamenho", "balboa panamenho|balboas panamenhos|balboa|pab|balboa panamense|balboas panamenses"],["Centavo panamenho", "centavo panamenho|cêntimo panamenho|centavos panamenhos|cêntimos panamenhos|cêntimo panamense|cêntimos panamenses"],["Kina", "kina|kina papuásia|kinas|kinas papuásias|pkg|pgk"],["Toea", "toea"],["Guarani", "guarani|guaranis|gs|pyg"],["Novo Sol", "novo sol peruano|novos sóis peruanos|sol|soles|sóis|nuevo sol|pen|s#."],["Centavo de sol", "cêntimo de sol|cêntimos de sol|centavo de sol|centavos de sol"],["Złoty", "złoty|złotys|zloty|zlotys|zloti|zlotis|zlóti|zlótis|zlote|zł|pln"],["Groszy", "groszy|grosz"],["Rial catariano", "rial qatari|riais qataris|rial catarense|riais catarenses|rial catariano|riais catarianos|qr|qar"],["Dirame catariano", "dirame catariano|dirames catarianos|dirame qatari|dirames qataris|dirame catarense|dirames catarenses|dirham qatari|dirhams qataris|dirham catarense|dirhams catarenses|dirham catariano|dirhams catariano"],["Libra esterlina", "libra esterlina|libras esterlinas|gbp"],["Coroa checa", "coroa checa|coroas checas|kc|czk"],["Peso dominicano", "peso dominicano|pesos dominicanos|rd$|dop"],["Centavo dominicano", "centavo dominicano|centavos dominicanos"],["Franco ruandês", "franco ruandês|franco ruandes|francos ruandeses|rf|rwf"],["Céntimo ruandês", "cêntimo ruandês|centimo ruandes|centavo ruandês|centavo ruandes|cêntimos ruandeses|centimos ruandeses|centavos ruandeses"],["Leu romeno", "leu romeno|lei romenos|leus romenos|ron"],["Ban romeno", "ban romeno|bani romeno|bans romenos"],["Rublo russo", "rublo russo|rublos russos|rub|р."],["Copeque ruso", "copeque russo|copeques russos|kopek ruso|kopeks rusos|copeque|copeques|kopek|kopeks"],["Tala samoano", "tala|tālā|talas|tala samonano|talas samoanos|ws$|sat|wst"],["Sene samoano", "sene"],["Libra de Santa Helena", "libra de santa helena|libras de santa helena|shp"],["Pêni de Santa Helena", "peni de santa helena|penies de santa helena"],["Dobra", "dobra|dobras|db|std"],["Dinar sérvio", "dinar sérvio|dinar servio|dinar serbio|dinares sérvios|dinares servios|dinares serbios|rsd"],["Para sérvio", "para sérvio|para servio|para serbio|paras sérvios|paras servios|paras serbios"],["Rupia seichelense", "rupia de seicheles|rupias de seicheles|rupia seichelense|rupias seichelenses|scr"],["Centavo seichelense", "centavo de seicheles|centavos de seicheles|centavo seichelense|centavos seichelenses"],["Leone serra-leonino", "leone|leones|leone serra-leonino|leones serra-leoninos|le|sll"],["Dólar de Cingapura", "dólar de singapura|dolar de singapura|dórar de cingapura|dolar de cingapura|dólares de singapura|dolares de singapura|dólares de cingapura|dolares de cingapura|sgb"],["Centavo de Cingapura", "centavo de singapura|centavos de singapura|centavo de cingapura|centavos de cingapura"],["Libra síria", "libra síria|libra siria|libras sírias|libras sirias|s£|syp"],["Piastra síria", "piastra siria|piastras sirias|piastra síria|piastras sírias"],["Xelim somali", "xelim somali|xelins somalis|xelim somaliano|xelins somalianos|sos"],["Centavo somali", "centavo somapli|centavos somalis|centavo somaliano|centavos somalianos"],["Xelim da Somalilândia", "xelim da somalilândia|xelins da somalilândia|xelim da somalilandia|xelins da somalilandia"],["Centavo da Somalilândia", "centavo da somalilândia|centavos da somalilândia|centavo da somalilandia|centavos da somalilandia"],["Rupia do Sri Lanka", "rupia do sri lanka|rupia do sri lanca|rupias do sri lanka|rupias do sri lanca|rupia cingalesa|rupias cingalesas|lkr"],["Lilangeni", "lilangeni|lilangenis|emalangeni|szl"],["Rand sul-africano", "rand|rand sul-africano|rands|rands sul-africanos|zar"],["Libra sudanesa", "libra sudanesa|libras sudanesas|sdg"],["Piastra sudanesa", "piastra sudanesa|piastras sudanesas"],["Libra sul-sudanesa", "libra sul-sudanesa|libras sul-sudanesas|ssp"],["Piastra sul-sudanesa", "piastra sul-sudanesa|piastras sul-sudanesas"],["Coroa sueca", "coroa sueca|coroas suecas|sek"],["Franco suíço", "franco suíço|franco suico|francos suíços|francos suicos|sfr|chf"],["Rappen suíço", "rappen suíço|rappen suico|rappens suíços|rappens suicos"],["Dólar surinamês", "dólar surinamês|dolar surinames|dólar do Suriname|dolar do Suriname|dólares surinameses|dolares surinameses|dólares do Suriname|dolares do Suriname|srd"],["Centavo surinamês", "centavo surinamês|centavo surinames|centavos surinameses"],["Baht tailandês", "baht tailandês|bath tailandes|baht tailandeses|thb"],["Satang tailandês", "satang tailandês|satang tailandes|satang tailandeses"],["Novo dólar taiwanês", "novo dólar taiwanês|novo dolar taiwanes|dólar taiwanês|dolar taiwanes|dólares taiwaneses|dolares taiwaneses|twd"],["Centavo taiwanês", "centavo taiwanês|centavo taiwanes|centavos taiwaneses"],["Xelim tanzaniano", "xelim tanzaniano|xelins tanzanianos|tzs"],["Centavo tanzaniano", "centavo tanzaniano|centavos tanzanianos"],["Somoni tajique", "somoni tajique|somoni|somonis tajiques|somonis|tjs"],["Diram tajique", "diram tajique|dirams tajiques|dirames tajiques"],["Paʻanga", "paanga|paangas|paʻanga|pa'anga|top"],["Seniti", "seniti"],["Rublo transdniestriano", "rublo transdniestriano|rublos transdniestriano"],["Copeque transdniestriano", "copeque transdniestriano|copeques transdniestriano"],["Dólar de Trinidade e Tobago", "dólar de trinidade e tobago|dólares trinidade e tobago|dolar de trinidade e tobago|dolares trinidade e tobago|dólar de trinidad e tobago|dólares trinidad e tobago|ttd"],["Centavo de Trinidade e Tobago", "centavo de trinidade e tobago|centavos de trinidade e tobago|centavo de trinidad e tobago|centavos de trinidad e tobago"],["Dinar tunisiano", "dinar tunisiano|dinares tunisianos|dinar tunisino|dinares tunisinos|tnd"],["Milim tunisiano", "milim tunisiano|milim tunesianos|millime tunisianos|millimes tunisianos|milim tunisino|milim tunisinos|millime tunisinos|millimes tunisinos"],["Lira turca", "lira turca|liras turcas|try"],["Kuruş turco", "kuruş turco|kuruş turcos"],["Manat turcomeno", "manat turcomeno|manats turcomenos|tmt"],["Tennesi turcomeno", "tennesi turcomeno|tennesis turcomenos|tenge turcomenos|tenges turcomenos"],["Dólar tuvaluano", "dólar tuvaluano|dolar tuvaluano|dólares tuvaluanos|dolares tuvaluanos"],["Centavo tuvaluano", "centavo tuvaluano|centavos tuvaluanos"],["Grívnia", "grívnia|grivnia|grívnias|grivnias|grivna|grivnas|uah"],["Copeque ucraniano", "kopiyka|copeque ucraniano|copeques ucranianos"],["Xelim ugandês", "xelim ugandês|xelim ugandes|xelins ugandeses|ugx"],["Centavo ugandês", "centavo ugandês|centavo ugandes|centavos ugandeses"],["Peso uruguaio", "peso uruguaio|pesos uruguayis|uyu"],["Centésimo uruguayo", "centésimo uruguaio|centesimo uruguaio|centésimos uruguaios|centesimos uruguaios"],["Som uzbeque", "som uzbeque|som uzbeques|soms uzbeques|somes uzbeques|som usbeque|som usbeques|soms usbeques|somes usbeques|uzs"],["Tiyin uzbeque", "tiyin uzbeque|tiyin uzbeques|tiyins uzbeques|tiyin usbeque|tiyin usbeques|tiyins usbeques"],["Vatu", "vatu|vatus|vuv"],["Bolívar forte venezuelano", "bolívar forte|bolivar forte|bolívar|bolivar|bolívares|bolivares|vef"],["Centavo de bolívar", "cêntimo de bolívar|cêntimos de bolívar|centavo de bolívar|centavo de bolivar|centavos de bolívar|centavos de bolivar"],["Dongue vietnamita", "dongue vietnamita|Đồng vietnamita|dong vietnamita|dongues vietnamitas|dongs vietnamitas|vnd"],["Hào vietnamita", "hào vietnamita|hao vietnamita|hào vietnamitas|hàos vietnamitas|haos vietnamitas"],["Rial iemenita", "rial iemenita|riais iemenitas|yer"],["Fils iemenita", "fils iemenita|fils iemenitas"],["Franco djibutiano", "franco djibutiano|francos djibutianos|franco jibutiano|francos jibutianos|djf"],["Dinar iugoslavo", "dinar iugoslavo|dinares iugoslavos|dinar jugoslavo|dinares jugoslavos|yud"],["Kwacha zambiano", "kwacha zambiano|kwacha zambianos|kwachas zambianos|zmw"],["Ngwee zambiano", "ngwee zambiano|ngwee zambianos|ngwees zambianos"],["Bitcoin", "bitcoin|bitcoins|btc|xbt|₿"],["Millibitcoin", "millibitcoin|millibitcoins|milibitcoin|milibitcoins"],["Satoshi", "satoshi|satoshis"]]); - export const CurrencyNameToIsoCodeMap: ReadonlyMap = new Map([["Afegani afegão", "AFN"],["Euro", "EUR"],["Lek albanês", "ALL"],["Kwanza angolano", "AOA"],["Dram armênio", "AMD"],["Florim arubano", "AWG"],["Taka bengali", "BDT"],["Ngultrum butanês", "BTN"],["Boliviano", "BOB"],["Marco da Bósnia e Herzegovina", "BAM"],["Pula", "BWP"],["Real brasileiro", "BRL"],["Lev búlgaro", "BGN"],["Riel cambojano", "KHR"],["Escudo cabo-verdiano", "CVE"],["Colón costarriquenho", "CRC"],["Kuna croata", "HRK"],["Coroa checa", "CZK"],["Nakfa", "ERN"],["Birr etíope", "ETB"],["Dalasi gambiano", "GMD"],["Lari georgiano", "GEL"],["Cedi", "GHS"],["Quetzal guatemalteco", "GTQ"],["Gurde haitiano", "HTG"],["Lempira hondurenha", "HNL"],["Florim húngaro", "HUF"],["Rial iraniano", "IRR"],["Rial iemenita", "YER"],["Novo shekel israelense", "ILS"],["Yen", "JPY"],["Tengue cazaque", "KZT"],["Xelim queniano", "KES"],["Won norte-coreano", "KPW"],["Won sul-coreano", "KRW"],["Som quirguiz", "KGS"],["Quipe laosiano", "LAK"],["Loti do Lesoto", "LSL"],["Rand sul-africano", "ZAR"],["Pataca macaense", "MOP"],["Dinar macedônio", "MKD"],["Ariary malgaxe", "MGA"],["Kwacha do Malawi", "MWK"],["Ringuite malaio", "MYR"],["Uguia", "MRO"],["Tugrik mongol", "MNT"],["Metical moçambicao", "MZN"],["Quiate mianmarense", "MMK"],["Córdova nicaraguense", "NIO"],["Naira", "NGN"],["Lira turca", "TRY"],["Rial omanense", "OMR"],["Balboa panamenho", "PAB"],["Kina", "PGK"],["Guarani", "PYG"],["Novo Sol", "PEN"],["Złoty", "PLN"],["Rial catariano", "QAR"],["Rial saudita", "SAR"],["Tala samoano", "WST"],["São Tomé and Príncipe dobra", "STN"],["Leone serra-leonino", "SLL"],["Lilangeni", "SZL"],["Somoni tajique", "TJS"],["Baht tailandês", "THB"],["Grívnia", "UAH"],["Vatu", "VUV"],["Bolívar forte venezuelano", "VEF"],["Kwacha zambiano", "ZMW"],["Dirame marroquino", "MAD"],["Dirham dos Emirados Árabes Unidos", "AED"],["Manat azeri", "AZN"],["Manat turcomeno", "TMT"],["Xelim somali", "SOS"],["Xelim tanzaniano", "TZS"],["Xelim ugandês", "UGX"],["Leu romeno", "RON"],["Leu moldávio", "MDL"],["Rupia nepalesa", "NPR"],["Rupia paquistanesa", "PKR"],["Rupia indiana", "INR"],["Rupia seichelense", "SCR"],["Rupia maurícia", "MUR"],["Rupia maldiva", "MVR"],["Rupia do Sri Lanka", "LKR"],["Rupia indonésia", "IDR"],["Coroa dinamarquesa", "DKK"],["Coroa norueguesa", "NOK"],["Coroa islandesa", "ISK"],["Coroa sueca", "SEK"],["Franco CFA da África Ocidental", "XOF"],["Franco CFA da África Central", "XAF"],["Franco comorense", "KMF"],["Franco congolês", "CDF"],["Burundian franc", "BIF"],["Franco djibutiano", "DJF"],["Franco CFP", "XPF"],["Franco da Guiné", "GNF"],["Franco suíço", "CHF"],["Franco ruandês", "RWF"],["Rublo russo", "RUB"],["Transnistrian ruble", "PRB"],["New Belarusian ruble", "BYN"],["Dinar argelino", "DZD"],["Dinar bareinita", "BHD"],["Dinar iraquiano", "IQD"],["Dinar jordaniano", "JOD"],["Dinar kuwaitiano", "KWD"],["Dinar libio", "LYD"],["Dinar sérvio", "RSD"],["Dinar tunisiano", "TND"],["Peso argentino", "ARS"],["Chilean peso", "CLP"],["Peso colombiano", "COP"],["Peso cubano convertível", "CUC"],["Peso cubano", "CUP"],["Peso dominicano", "DOP"],["Peso mexicano", "MXN"],["Peso uruguaio", "UYU"],["Libra esterlina", "GBP"],["Libra de Santa Helena", "SHP"],["Libra egípcia", "EGP"],["Libra das Malvinas", "FKP"],["Libra de Gibraltar", "GIP"],["Libra manesa", "IMP"],["Libra de Jersey", "JEP"],["Libra libanesa", "LBP"],["Libra sul-sudanesa", "SSP"],["Libra sudanesa", "SDG"],["Libra síria", "SYP"],["Dólar estadunidense", "USD"],["Dólar australiano", "AUD"],["Dólar bahamense", "BSD"],["Dólar de Barbados", "BBD"],["Dólar de Belize", "BZD"],["Dólar bermudense", "BMD"],["Dólar de Brunei", "BND"],["Dólar de Cingapura", "SGD"],["Dólar canadense", "CAD"],["Dólar das Ilhas Cayman", "KYD"],["Dólar neozelandês", "NZD"],["Dólar fijiano", "FJD"],["Dólar guianense", "GYD"],["Dólar de Hong Kong", "HKD"],["Dólar jamaicano", "JMD"],["Dólar liberiano", "LRD"],["Dólar namibiano", "NAD"],["Dólar das Ilhas Salomão", "SBD"],["Dólar surinamês", "SRD"],["Novo dólar taiwanês", "TWD"],["Dólar de Trinidade e Tobago", "TTD"],["Tuvaluan dólar", "TVD"],["Yuan chinês", "CNY"],["Rial", "__RI"],["Xelim", "__S"],["Som", "__SO"],["Dirame", "__DR"],["Dinar", "_DN"],["Dólar", "__D"],["Manat", "__MA"],["Rupia", "__R"],["Coroa", "__K"],["Krona", "__K"],["Franco", "__F"],["Marco", "__M"],["Rublo", "__RB"],["Peso", "__PE"],["Libra", "__P"],["Tristan da Cunha libra", "_TP"],["South Georgia and the South Sandwich Islands libra", "_SP"],["Somaliland xelim", "_SS"],["Pitcairn Islands dólar", "_PND"],["Palauan dólar", "_PD"],["Niue dólar", "_NID"],["Nauruan dólar", "_ND"],["Micronesian dólar", "_MD"],["Kiribati dólar", "_KID"],["Guernsey libra", "_GGP"],["Faroese króna", "_FOK"],["Cook Islands dólar", "_CKD"],["British Virgin Islands dólar", "_BD"],["Ascension libra", "_AP"],["Alderney libra", "_ALP"],["Abkhazian apsar", "_AA"],["Bitcoin", "_XBT"]]); - export const FractionalUnitNameToCodeMap: ReadonlyMap = new Map([["Jiao", "JIAO"],["Kopek", "KOPEK"],["Pul", "PUL"],["Cent", "CENT"],["Qindarke", "QINDARKE"],["Peni", "PENNY"],["Santeem", "SANTEEM"],["Cêntimo", "CENTIMO"],["Centavo", "CENT"],["Luma", "LUMA"],["Qəpik", "QƏPIK"],["Fils", "FILS"],["Poisha", "POISHA"],["Kapyeyka", "KAPYEYKA"],["Centime", "CENTIME"],["Chetrum", "CHETRUM"],["Paisa", "PAISA"],["Fening", "FENING"],["Thebe", "THEBE"],["Sen", "SEN"],["Stotinka", "STOTINKA"],["Fen", "FEN"],["Céntimo", "CENT"],["Lipa", "LIPA"],["Haléř", "HALER"],["Øre", "ØRE"],["Piastre", "PIASTRE"],["Santim", "SANTIM"],["Oyra", "OYRA"],["Butut", "BUTUT"],["Tetri", "TETRI"],["Pesewa", "PESEWA"],["Fillér", "FILLER"],["Eyrir", "EYRIR"],["Dinar", "DINAR"],["Agora", "AGORA"],["Tïın", "TIIN"],["Chon", "CHON"],["Jeon", "JEON"],["Tyiyn", "TYIYN"],["Att", "ATT"],["Sente", "SENTE"],["Dirham", "DIRHAM"],["Rappen", "RAPPEN"],["Avo", "AVO"],["Deni", "DENI"],["Iraimbilanja", "IRAIMBILANJA"],["Tambala", "TAMBALA"],["Laari", "LAARI"],["Khoums", "KHOUMS"],["Ban", "BAN"],["Möngö", "MONGO"],["Pya", "PYA"],["Kobo", "KOBO"],["Kuruş", "KURUS"],["Baisa", "BAISA"],["Centésimo", "CENTESIMO"],["Toea", "TOEA"],["Sentimo", "SENTIMO"],["Grosz", "GROSZ"],["Sene", "SENE"],["Halala", "HALALA"],["Para", "PARA"],["Öre", "ORE"],["Diram", "DIRAM"],["Satang", "SATANG"],["Seniti", "SENITI"],["Millime", "MILLIME"],["Tennesi", "TENNESI"],["Kopiyka", "KOPIYKA"],["Tiyin", "TIYIN"],["Hào", "HAO"],["Ngwee", "NGWEE"],["Millibitcoin", "MILLIBITCOIN"],["Satoshi", "SATOSHI"]]); - export const CompoundUnitConnectorRegex = `\\b(?e|com)\\b`; - export const MultiplierRegex = `\\s*\\b(mil(h([ãa]o|[õo]es))?|bilh([ãa]o|[õo]es)|trilh([ãa]o|[õo]es)|qua[td]rilh([ãa]o|[õo]es)|quintilh([ãa]o|[õo]es))\\b`; - export const CurrencyPrefixList: ReadonlyMap = new Map([["Dólar", "$|dólar|dolar|dólares|dolares"],["Dólar estadunidense", "us$|u$d|usd$|usd"],["Dólar do Caribe Oriental", "ec$|xcd"],["Dólar australiano", "a$|aud"],["Dólar bahamense", "b$|bsd"],["Dólar de Barbados", "bds$|bbd"],["Dólar de Belize", "bz$|bzd"],["Dólar bermudense", "bd$|bmd"],["Dólar de Brunei", "brunéi $|bnd"],["Dólar de Cingapura", "s$|sgd"],["Dólar canadense", "c$|can$|cad"],["Dólar das Ilhas Cayman", "ci$|kyd"],["Dólar neozelandês", "nz$|nzd"],["Dólar fijiano", "fj$|fjd"],["Dólar guianense", "gy$|gyd"],["Dólar de Hong Kong", "hk$|hkd"],["Dólar jamaicano", "j$|ja$|jmd"],["Dólar liberiano", "l$|lrd"],["Dólar namibiano", "n$|nad"],["Dólar das Ilhas Salomão", "si$|sbd"],["Novo dólar taiwanês", "nt$|twd"],["Real brasileiro", "r$|brl"],["Guarani", "₲|gs.|pyg"],["Dólar de Trinidade e Tobago", "tt$|ttd"],["Yuan chinês", "¥|cny|rmb"],["Yen", "¥|jpy"],["Euro", "€|eur"],["Florim", "ƒ"],["Libra", "£"],["Colón costarriquenho", "₡"],["Lira turca", "₺"],["Bitcoin", "₿|btc|xbt"]]); - export const AmbiguousCurrencyUnitList = [ "le","agora" ]; - export const InformationSuffixList: ReadonlyMap = new Map([["bit", "bit|bits"],["kilobit", "kilobit|kilobits|kb|kbit"],["megabit", "megabit|megabits|Mb|Mbit"],["gigabit", "gigabit|gigabits|Gb|Gbit"],["terabit", "terabit|terabits|Tb|Tbit"],["petabit", "petabit|petabits|Pb|Pbit"],["kibibit", "kibibit|kibibits|kib|kibit"],["mebibit", "mebibit|mebibits|Mib|Mibit"],["gibibit", "gibibit|gibibits|Gib|Gibit"],["tebibit", "tebibit|tebibits|Tib|Tibit"],["pebibit", "pebibit|pebibits|Pib|Pibit"],["byte", "byte|bytes"],["kilobyte", "kilobyte|kilobytes|kB|kByte"],["megabyte", "megabyte|megabytes|MB|MByte"],["gigabyte", "gigabyte|gigabytes|GB|GByte"],["terabyte", "terabyte|terabytes|TB|TByte"],["petabyte", "petabyte|petabytes|PB|PByte"],["kibibyte", "kibibyte|kibibytes|kiB|kiByte"],["mebibyte", "mebibyte|mebibytes|MiB|MiByte"],["gibibyte", "gibibyte|gibibytes|GiB|GiByte"],["tebibyte", "tebibyte|tebibytes|TiB|TiByte"],["pebibyte", "pebibyte|pebibytes|PiB|PiByte"]]); - export const AmbiguousDimensionUnitList = [ "ton","tonelada","área","area","áreas","areas","milha","milhas","\"" ]; - export const BuildPrefix = `(?<=(\\s|^|\\P{L}))`; - export const BuildSuffix = `(?=(\\s|\\P{L}|$))`; - export const ConnectorToken = `de`; - export const LengthSuffixList: ReadonlyMap = new Map([["Quilômetro", "km|quilometro|quilômetro|quilómetro|quilometros|quilômetros|quilómetros"],["Hectômetro", "hm|hectometro|hectômetro|hectómetro|hectometros|hectômetros|hectómetros"],["Decâmetro", "decametro|decâmetro|decámetro|decametros|decâmetro|decámetros|dam"],["Metro", "m|m.|metro|metros"],["Decímetro", "dm|decimetro|decímetro|decimetros|decímetros"],["Centímetro", "cm|centimetro|centímetro|centimetros|centimetros"],["Milímetro", "mm|milimetro|milímetro|milimetros|milímetros"],["Micrômetro", "µm|um|micrometro|micrômetro|micrómetro|micrometros|micrômetros|micrómetros|micron|mícron|microns|mícrons|micra"],["Nanômetro", "nm|nanometro|nanômetro|nanómetro|nanometros|nanômetros|nanómetros|milimicron|milimícron|milimicrons|milimícrons"],["Picômetro", "pm|picometro|picômetro|picómetro|picometros|picômetros|picómetros"],["Milha", "mi|milha|milhas"],["Jarda", "yd|jarda|jardas"],["Polegada", "polegada|polegadas|\"|in"],["Pé", "pé|pe|pés|pes|ft"],["Ano luz", "ano luz|anos luz|al"]]); - export const AmbiguousLengthUnitList = [ "mi","milha","milhas","\"","in","um" ]; - export const SpeedSuffixList: ReadonlyMap = new Map([["Metro por segundo", "metro/segundo|m/s|metro por segundo|metros por segundo|metros por segundos"],["Quilômetro por hora", "km/h|quilômetro por hora|quilómetro por hora|quilometro por hora|quilômetros por hora|quilómetros por hora|quilometros por hora|quilômetro/hora|quilómetro/hora|quilometro/hora|quilômetros/hora|quilómetros/hora|quilometros/hora"],["Quilômetro por minuto", "km/min|quilômetro por minuto|quilómetro por minuto|quilometro por minuto|quilômetros por minuto|quilómetros por minuto|quilometros por minuto|quilômetro/minuto|quilómetro/minuto|quilometro/minuto|quilômetros/minuto|quilómetros/minuto|quilometros/minuto"],["Quilômetro por segundo", "km/seg|quilômetro por segundo|quilómetro por segundo|quilometro por segundo|quilômetros por segundo|quilómetros por segundo|quilometros por segundo|quilômetro/segundo|quilómetro/segundo|quilometro/segundo|quilômetros/segundo|quilómetros/segundo|quilometros/segundo"],["Milha por hora", "mph|milha por hora|mi/h|milha/hora|milhas/hora|milhas por hora|mi por hora|mi/hora"],["Nó", "kt|nó|nós|kn"],["Pé por segundo", "ft/s|pé/s|pe/s|ft/seg|pé/seg|pe/seg|pé por segundo|pe por segundo|pés por segundo|pes por segundo"],["Pé por minuto", "ft/min|pé/mind|pe/min|pé por minuto|pe por minuto|pés por minuto|pes por minuto"],["Jarda por minuto", "jardas por minuto|jardas/minuto|jardas/min"],["Jarda por segundo", "jardas por segundo|jardas/segundo|jardas/seg"]]); - export const AmbiguousSpeedUnitList = [ "nó","no","nós","nos" ]; - export const TemperatureSuffixList: ReadonlyMap = new Map([["Kelvin", "k|K|kelvin"],["Grau Rankine", "r|°r|°ra|grau rankine|graus rankine| rankine"],["Grau Celsius", "°c|° c|ºc|º c|grau c|grau celsius|graus c|graus celsius|celsius|grau centígrado|grau centrigrado|graus centígrados|graus centigrados|centígrado|centígrados|centigrado|centigrados"],["Grau Fahrenheit", "°f|° f|ºf|º f|grau f|graus f|grau fahrenheit|graus fahrenheit|fahrenheit"],["Grau", "°|graus|grau"]]); - export const VolumeSuffixList: ReadonlyMap = new Map([["Quilômetro cúbico", "quilômetro cúbico|quilómetro cúbico|quilometro cubico|quilômetros cúbicos|quilómetros cúbicos|quilometros cubicos|km3|km^3|km³"],["Hectômetro cúbico", "hectômetro cúbico|hectómetro cúbico|hectometro cubico|hectômetros cúbicos|hectómetros cúbicos|hectometros cubicos|hm3|hm^3|hm³"],["Decâmetro cúbico", "decâmetro cúbico|decámetro cúbico|decametro cubico|decâmetros cúbicos|decámetros cúbicos|decametros cubicosdam3|dam^3|dam³"],["Metro cúbico", "metro cúbico|metro cubico|metros cúbicos|metros cubicos|m3|m^3|m³"],["Decímetro cúbico", "decímetro cúbico|decimetro cubico|decímetros cúbicos|decimetros cubicos|dm3|dm^3|dm³"],["Centímetro cúbico", "centímetro cúbico|centimetro cubico|centímetros cúbicos|centrimetros cubicos|cc|cm3|cm^3|cm³"],["Milímetro cúbico", "milímetro cúbico|milimetro cubico|milímetros cúbicos|milimetros cubicos|mm3|mm^3|mm³"],["Polegada cúbica", "polegada cúbica|polegada cubica|polegadas cúbicas|polegadas cubicas"],["Pé cúbico", "pé cúbico|pe cubico|pés cúbicos|pes cubicos|pé3|pe3|pé^3|pe^3|pé³|pe³|ft3|ft^3|ft³"],["Jarda cúbica", "jarda cúbica|jarda cubica|jardas cúbicas|jardas cubicas|yd3|yd^3|yd³"],["Hectolitro", "hectolitro|hectolitros|hl"],["Litro", "litro|litros|lts|l"],["Mililitro", "mililitro|mililitros|ml"],["Galão", "galão|galões|galao|galoes"],["Pint", "pinta|pintas|pinto|pintos|quartilho|quartilhos|pint|pints"],["Barril", "barril|barris|bbl"],["Onça líquida", "onça líquida|onca liquida|onças líquidas|oncas liquidas"]]); - export const WeightSuffixList: ReadonlyMap = new Map([["Tonelada métrica", "tonelada métrica|tonelada metrica|toneladas métricas|toneladas metricas|t métrica|t metrica|t métricas|t metricas|t.métrica|t.metrica|t.métricas|t.metricas|t. metrica|t. métrica"],["Tonelada", "ton|tonelada|toneladas|t"],["Quilograma", "kg|quilograma|quilogramas|quilo|quilos|kilo|kilos"],["Hectograma", "hg|hectograma|hectogramas"],["Decagrama", "dag|decagrama|decagramas"],["Grama", "g|grama|gramas"],["Decigrama", "dg|decigrama|decigramas"],["Centigrama", "cg|centigrama|centigramas"],["Miligrama", "mg|miligrama|miligramas"],["Micrograma", "µg|ug|micrograma|microgramas"],["Nanograma", "ng|nanograma|nanogramas"],["Picograma", "pg|picograma|picogramas"],["Libra", "lb|libra|libras"],["Onça", "oz|onça|onca|onças|oncas"],["Grão", "grão|grao|grãos|graos|gr"],["Quilate", "ct|quilate|quilates"]]); - export const AmbiguousWeightUnitList = [ "g","t" ]; - export const AngleSuffixList: ReadonlyMap = new Map([["Degree", "grau|graus|°"],["Radian", "radiano|radianos|rad"],["Turn", "volta|voltas"]]); - export const AmbiguousAngleUnitList = [ "volta","voltas" ]; - export const AmbiguityFiltersDict: ReadonlyMap = new Map([["\\b\\d+\\s*\\p{L}+$", "((\\d+(\\s*\\p{L}+[-—–-]|\\p{L}+)\\d+)|(((\\p{L}|\\d)[-—–-]\\d+\\s*|\\p{L}\\d+)\\p{L}+))"],["\\bum$", "\\p{L}\\s+um\\b"]]); - export const TemperatureAmbiguityFiltersDict: ReadonlyMap = new Map([["\\b(graus?|°)$", "\\b((graus?|°)\\s*(ângulo|rotação)|(gira(r|do|ndo)?|ângulo|rotação)(\\s+(\\p{L}+|\\d+)){0,4}\\s*(graus?\\b|°))"]]); - export const DimensionAmbiguityFiltersDict: ReadonlyMap = new Map([["\\b(graus?|°)$", "\\b((graus?|°)\\s*(c(elsius|entígrado)?|f(ah?renheit)?)|(temperatura)(\\s+(\\p{L}+|\\d+)){0,4}\\s*(graus?\\b|°))"]]); -} diff --git a/JavaScript/packages/recognizers-number-with-unit/src/resources/spanishNumericWithUnit.ts b/JavaScript/packages/recognizers-number-with-unit/src/resources/spanishNumericWithUnit.ts deleted file mode 100644 index cb92b04aad..0000000000 --- a/JavaScript/packages/recognizers-number-with-unit/src/resources/spanishNumericWithUnit.ts +++ /dev/null @@ -1,43 +0,0 @@ -// ------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// ------------------------------------------------------------------------------ - -import { BaseNumbers } from "./baseNumbers"; -export namespace SpanishNumericWithUnit { - export const AgeSuffixList: ReadonlyMap = new Map([["Año", "años|año"],["Mes", "meses|mes"],["Semana", "semanas|semana"],["Día", "dias|días|día|dia"]]); - export const AmbiguousAgeUnitList = [ "años","año","meses","mes","semanas","semana","dias","días","día","dia" ]; - export const AreaSuffixList: ReadonlyMap = new Map([["Kilómetro cuadrado", "kilómetro cuadrado|kilómetros cuadrados|km2|km^2|km²"],["Hectómetro cuadrado", "hectómetro cuadrado|hectómetros cuadrados|hm2|hm^2|hm²|hectárea|hectáreas"],["Decámetro cuadrado", "decámetro cuadrado|decámetros cuadrados|dam2|dam^2|dam²|área|áreas"],["Metro cuadrado", "metro cuadrado|metros cuadrados|m2|m^2|m²"],["Decímetro cuadrado", "decímetro cuadrado|decímetros cuadrados|dm2|dm^2|dm²"],["Centímetro cuadrado", "centímetro cuadrado|centímetros cuadrados|cm2|cm^2|cm²"],["Milímetro cuadrado", "milímetro cuadrado|milímetros cuadrados|mm2|mm^2|mm²"],["Pulgada cuadrado", "pulgada cuadrada|pulgadas cuadradas"],["Pie cuadrado", "pie cuadrado|pies cuadrados|pie2|pie^2|pie²|ft2|ft^2|ft²"],["Yarda cuadrado", "yarda cuadrada|yardas cuadradas|yd2|yd^2|yd²"],["Acre", "acre|acres"]]); - export const AreaAmbiguousValues = [ "área","áreas" ]; - export const CurrencySuffixList: ReadonlyMap = new Map([["Dólar", "dólar|dólares|dolar|dolares"],["Peso", "peso|pesos"],["Rublo", "rublo|rublos"],["Libra", "libra|libras"],["Florín", "florín|florines"],["Dinar", "dinar|dinares"],["Franco", "franco|francos"],["Rupia", "rupia|rupias"],["Escudo", "escudo|escudos"],["Chelín", "chelín|chelines"],["Lira", "lira|liras"],["Centavo", "centavo|centavos"],["Céntimo", "céntimo|céntimos"],["Centésimo", "centésimo|centésimos"],["Penique", "penique|peniques"],["Euro", "euro|euros|€|eur"],["Céntimo de Euro", "céntimo de euro|céntimos de euros"],["Dólar del Caribe Oriental", "dólar del caribe oriental|dólares del caribe oriental|ec$|xcd"],["Centavo del Caribe Oriental", "centavo del caribe oriental|centavos del caribe oriental"],["Franco CFA de África Occidental", "franco cfa de África occidental|francos cfa de África occidental|fcfa|xof"],["Céntimo de CFA de África Occidental", "céntimo de cfa de África occidental|céntimos de cfa de África occidental"],["Franco CFA de África Central", "franco cfa de África central|francos cfa de África central|xaf"],["Céntimo de CFA de África Central", "céntimo de cfa de África central|céntimos de cfa de África central"],["Apsar", "apsar|apsares"],["Afgani afgano", "afgani afgano|؋|afn|afganis|afgani"],["Pul", "pul|puls"],["Lek albanés", "lek|lekë|lekes|lek albanés"],["Qindarka", "qindarka|qindarkë|qindarkas"],["Kwanza angoleño", "kwanza angoleño|kwanzas angoleños|kwanza angoleños|kwanzas angoleño|kwanzas|aoa|kz"],["Cêntimo angoleño", "cêntimo angoleño|cêntimo|cêntimos"],["Florín antillano neerlandés", "florín antillano neerlandés|florínes antillano neerlandés|ƒ antillano neerlandés|ang|naƒ"],["Cent antillano neerlandés", "cent|centen"],["Riyal saudí", "riyal saudí|riyales saudí|sar"],["Halalá saudí", "halalá saudí|hallalah"],["Dinar argelino", "dinar argelino|dinares argelinos|dzd"],["Céntimo argelino", "centimo argelino|centimos argelinos"],["Peso argentino", "peso argentino|pesos argentinos|ar$|ars"],["Centavo argentino", "centavo argentino|centavos argentinos|ctvo.|ctvos."],["Dram armenio", "dram armenio|dram armenios|dram|դր."],["Luma armenio", "luma armenio|luma armenios"],["Florín arubeño", "florín arubeño|florines arubeños|ƒ arubeños|aƒ|awg"],["Yotin arubeño", "yotin arubeño|yotines arubeños"],["Dólar australiano", "dólar australiano|dólares australianos|a$|aud"],["Centavo australiano", "centavo australiano|centavos australianos"],["Manat azerí", "manat azerí|man|azn"],["Qəpik azerí", "qəpik azerí|qəpik"],["Dólar bahameño", "dólar bahameño|dólares bahameños|b$|bsd"],["Centavo bahameño", "centavo bahameño|centavos bahameños"],["Dinar bahreiní", "dinar bahreiní|dinares bahreinies|bhd"],["Fil bahreiní", "fil bahreiní|fils bahreinies"],["Taka bangladeshí", "taka bangladeshí|takas bangladeshí|bdt"],["Poisha bangladeshí", "poisha bangladeshí|poishas bangladeshí"],["Dólar de Barbados", "dólar de barbados|dólares de barbados|bbd"],["Centavo de Barbados", "centavo de barbados|centavos de barbados"],["Dólar beliceño", "dólar beliceño|dólares beliceños|bz$|bzd"],["Centavo beliceño", "centavo beliceño|centavos beliceños"],["Dólar bermudeño", "dólar bermudeño|dólares bermudeños|bd$|bmd"],["Centavo bermudeño", "centavo bermudeño|centavos bermudeños"],["Rublo bielorruso", "rublo bielorruso|rublos bielorrusos|byr"],["Kópek bielorruso", "kópek bielorruso|kópeks bielorrusos|kap"],["Kyat birmano", "kyat birmano|kyats birmanos|mmk"],["Pya birmano", "pya birmano|pyas birmanos"],["Boliviano", "boliviano|bolivianos|bob|bs"],["Centésimo Boliviano", "centésimo boliviano|centésimos bolivianos"],["Marco bosnioherzegovino", "marco convertible|marco bosnioherzegovino|marcos convertibles|marcos bosnioherzegovinos|bam"],["Feningas bosnioherzegovino", "feninga convertible|feninga bosnioherzegovina|feningas convertibles"],["Pula", "pula|bwp"],["Thebe", "thebe"],["Real brasileño", "real brasileño|reales brasileños|r$|brl"],["Centavo brasileño", "centavo brasileño|centavos brasileños"],["Dólar de Brunéi", "dólar de brunei|dólares de brunéi|bnd"],["Sen de Brunéi", "sen|sen de brunéi"],["Lev búlgaro", "lev búlgaro|leva búlgaros|lv|bgn"],["Stotinki búlgaro", "stotinka búlgaro|stotinki búlgaros"],["Franco de Burundi", "franco de burundi|francos de burundi|fbu|fib"],["Céntimo Burundi", "céntimo burundi|céntimos burundies"],["Ngultrum butanés", "ngultrum butanés|ngultrum butaneses|btn"],["Chetrum butanés", "chetrum butanés|chetrum butaneses"],["Escudo caboverdiano", "escudo caboverdiano|escudos caboverdianos|cve"],["Riel camboyano", "riel camboyano|rieles camboyanos|khr"],["Dólar canadiense", "dólar canadiense|dólares canadienses|c$|cad"],["Centavo canadiense", "centavo canadiense|centavos canadienses"],["Peso chileno", "peso chileno|pesos chilenos|cpl"],["Yuan chino", "yuan chino|yuanes chinos|yuan|yuanes|renminbi|rmb|cny|¥"],["Peso colombiano", "peso colombiano|pesos colombianos|cop|col$"],["Centavo colombiano", "centavo colombiano|centavos colombianos"],["Franco comorano", "franco comorano|francos comoranos|kmf|₣"],["Franco congoleño", "franco congoleño|francos congoleños|cdf"],["Céntimo congoleño", "céntimo congoleño|céntimos congoleños"],["Won norcoreano", "won norcoreano|wŏn norcoreano|wŏn norcoreanos|kpw"],["Chon norcoreano", "chon norcoreano|chŏn norcoreano|chŏn norcoreanos|chon norcoreanos"],["Won surcoreano", "wŏn surcoreano|won surcoreano|wŏnes surcoreanos|wones surcoreanos|krw"],["Chon surcoreano", "chon surcoreano|chŏn surcoreano|chŏn surcoreanos|chon surcoreanos"],["Colón costarricense", "colón costarricense|colones costarricenses|crc"],["Kuna croata", "kuna croata|kuna croatas|hrk"],["Lipa croata", "lipa croata|lipa croatas"],["Peso cubano", "peso cubano|pesos cubanos|cup"],["Peso cubano convertible", "peso cubano convertible|pesos cubanos convertible|cuc"],["Corona danesa", "corona danesa|coronas danesas|dkk"],["Libra egipcia", "libra egipcia|libras egipcias|egp|l.e."],["Piastra egipcia", "piastra egipcia|piastras egipcias"],["Colón salvadoreño", "colón salvadoreño|colones salvadoreños|svc"],["Dirham de los Emiratos Árabes Unidos", "dirham|dirhams|dirham de los emiratos Árabes unidos|aed|dhs"],["Nakfa", "nakfa|nfk|ern"],["Céntimo de Nakfa", "céntimo de nakfa|céntimos de nakfa"],["Peseta", "peseta|pesetas|pts.|ptas.|esp"],["Dólar estadounidense", "dólar estadounidense|dólares estadounidenses|usd|u$d|us$"],["Corona estonia", "corona estonia|coronas estonias|eek"],["Senti estonia", "senti estonia|senti estonias"],["Birr etíope", "birr etíope|birr etíopes|br|etb"],["Santim etíope", "santim etíope|santim etíopes"],["Peso filipino", "peso filipino|pesos filipinos|php"],["Marco finlandés", "marco finlandés|marcos finlandeses"],["Dólar fiyiano", "dólar fiyiano|dólares fiyianos|fj$|fjd"],["Centavo fiyiano", "centavo fiyiano|centavos fiyianos"],["Dalasi", "dalasi|gmd"],["Bututs", "butut|bututs"],["Lari georgiano", "lari georgiano|lari georgianos|gel"],["Tetri georgiano", "tetri georgiano|tetri georgianos"],["Cedi", "cedi|ghs|gh₵"],["Pesewa", "pesewa"],["Libra gibraltareña", "libra gibraltareña|libras gibraltareñas|gip"],["Penique gibraltareña", "penique gibraltareña|peniques gibraltareñas"],["Quetzal guatemalteco", "quetzal guatemalteco|quetzales guatemaltecos|quetzal|quetzales|gtq"],["Centavo guatemalteco", "centavo guatemalteco|centavos guatemaltecos"],["Libra de Guernsey", "libra de guernsey|libras de guernsey|ggp"],["Penique de Guernsey", "penique de guernsey|peniques de guernsey"],["Franco guineano", "franco guineano|francos guineanos|gnf|fg"],["Céntimo guineano", "céntimo guineano|céntimos guineanos"],["Dólar guyanés", "dólar guyanés|dólares guyaneses|gyd|gy"],["Gourde haitiano", "gourde haitiano|gourde haitianos|htg"],["Céntimo haitiano", "céntimo haitiano|céntimos haitianos"],["Lempira hondureño", "lempira hondureño|lempira hondureños|hnl"],["Centavo hondureño", "centavo hondureño|centavos hondureño"],["Dólar de Hong Kong", "dólar de hong kong|dólares de hong kong|hk$|hkd"],["Forinto húngaro", "forinto húngaro|forinto húngaros|huf"],["Rupia india", "rupia india|rupias indias|inr"],["Paisa india", "paisa india|paise indias"],["Rupia indonesia", "rupia indonesia|rupias indonesias|idr"],["Sen indonesia", "sen indonesia|sen indonesias"],["Rial iraní", "rial iraní|rial iranies|irr"],["Dinar iraquí", "dinar iraquí|dinares iraquies|iqd"],["Fil iraquí", "fil iraquí|fils iraquies"],["Libra manesa", "libra manesa|libras manesas|imp"],["Penique manes", "penique manes|peniques maneses"],["Corona islandesa", "corona islandesa|coronas islandesas|isk|íkr"],["Aurar islandes", "aurar islandes|aurar islandeses"],["Dólar de las Islas Caimán", "dólar de las islas caimán|dólares de las islas caimán|ci$|kyd"],["Dólar de las Islas Cook", "dólar de las islas cook|dólares de las islas cook"],["Corona feroesa", "corona feroesa|coronas feroesas|fkr"],["Libra malvinense", "libra malvinense|libras malvinenses|fk£|fkp"],["Dólar de las Islas Salomón", "dólar de las islas salomón|dólares de las islas salomón|sbd"],["Nuevo shéquel", "nuevo shéquel|nuevos shéquel|ils"],["Agorot", "agorot"],["Dólar jamaiquino", "dólar jamaiquino|dólares jamaiquinos|j$|ja$|jmd"],["Yen", "yen|yenes|jpy"],["Libra de Jersey", "libra de jersey|libras de jersey|jep"],["Dinar jordano", "dinar jordano|dinares jordanos|jd|jod"],["Piastra jordano", "piastra jordano|piastras jordanos"],["Tenge kazajo", "tenge|tenge kazajo|kzt"],["Chelín keniano", "chelín keniano|chelines kenianos|ksh|kes"],["Som kirguís", "som kirguís|kgs"],["Tyiyn", "tyiyn"],["Dólar de Kiribati", "dólar de kiribati|dólares de kiribati"],["Dinar kuwaití", "dinar kuwaití|dinares kuwaití"],["Kip laosiano", "kip|kip laosiano|kip laosianos|lak"],["Att laosiano", "att|att laosiano|att laosianos"],["Loti", "loti|maloti|lsl"],["Sente", "sente|lisente"],["Libra libanesa", "libra libanesa|libras libanesas|lbp"],["Dólar liberiano", "dólar liberiano|dólares liberianos|l$|lrd"],["Dinar libio", "dinar libio|dinares libios|ld|lyd"],["Dirham libio", "dirham libio|dirhams libios"],["Litas lituana", "litas lituana|litai lituanas|ltl"],["Pataca macaense", "pataca macaense|patacas macaenses|mop$|mop"],["Avo macaense", "avo macaense|avos macaenses"],["Ho macaense", "ho macaense|ho macaenses"],["Denar macedonio", "denar macedonio|denare macedonios|den|mkd"],["Deni macedonio", "deni macedonio|deni macedonios"],["Ariary malgache", "ariary malgache|ariary malgaches|mga"],["Iraimbilanja malgache", "iraimbilanja malgache|iraimbilanja malgaches"],["Ringgit malayo", "ringgit malayo|ringgit malayos|rm|myr"],["Sen malayo", "sen malayo|sen malayos"],["Kwacha malauí", "kwacha malauí|mk|mwk"],["Támbala malauí", "támbala malauí"],["Rupia de Maldivas", "rupia de maldivas|rupias de maldivas|mvr"],["Dirham marroquí", "dirham marroquí|dirhams marroquies|mad"],["Rupia de Mauricio", "rupia de Mauricio|rupias de Mauricio|mur"],["Uguiya", "uguiya|uguiyas|mro"],["Jum", "jum|jums"],["Peso mexicano", "peso mexicano|pesos mexicanos|mxn|mxn$|mxn $|mex$"],["Centavo mexicano", "centavo mexicano|centavos mexicanos"],["Leu moldavo", "leu moldavo|lei moldavos|mdl"],["Ban moldavo", "ban moldavo|bani moldavos"],["Tugrik mongol", "tugrik mongol|tugrik|tugrik mongoles|tug|mnt"],["Metical mozambiqueño", "metical|metical mozambiqueño|meticales|meticales mozambiqueños|mtn|mzn"],["Dram de Nagorno Karabaj", "dram de nagorno karabaj|drams de nagorno karabaj"],["Luma de Nagorno Karabaj", "luma de nagorno karabaj"],["Dólar namibio", "dólar namibio|dólares namibios|n$|nad"],["Centavo namibio", "centavo namibio|centavos namibios"],["Rupia nepalí", "rupia nepalí|rupias nepalies|npr"],["Paisa nepalí", "paisa nepalí|paisas nepalies"],["Córdoba nicaragüense", "córdoba nicaragüense|córdobas nicaragüenses|nio"],["Centavo nicaragüense", "centavo nicaragüense|centavos nicaragüenses"],["Naira", "naira|ngn"],["Kobo", "kobo"],["Corona noruega", "corona noruega|coronas noruegas|nok"],["Franco CFP", "franco cfp|francos cfp|xpf"],["Dólar neozelandés", "dólar neozelandés|dólares neozelandeses|dólar de nueva zelanda|dólares de nueva zelanda|nz$|nzd"],["Centavo neozelandés", "centavo neozelandés|centavo de nueva zelanda|centavos de nueva zelanda|centavos neozelandeses"],["Rial omaní", "rial omaní|riales omanies|omr"],["Baisa omaní", "baisa omaní|baisa omanies"],["Florín neerlandés", "florín neerlandés|florines neerlandeses|nlg"],["Rupia pakistaní", "rupia pakistaní|rupias pakistanies|pkr"],["Paisa pakistaní", "paisa pakistaní|paisas pakistanies"],["Balboa panameño", "balboa panameño|balboa panameños|pab"],["Centésimo panameño", "centésimo panameño|centésimos panameños"],["Kina", "kina|pkg|pgk"],["Toea", "toea"],["Guaraní", "guaraní|guaranies|gs|pyg"],["Sol", "sol|soles|nuevo sol|pen|s#."],["Céntimo de sol", "céntimo de sol|céntimos de sol"],["Złoty", "złoty|esloti|eslotis|zł|pln"],["Groszy", "groszy"],["Riyal qatarí", "riyal qatarí|riyal qataries|qr|qar"],["Dirham qatarí", "dirham qatarí|dirhams qataries"],["Libra esterlina", "libra esterlina|libras esterlinas|gbp"],["Corona checa", "corona checa|coronas checas|kc|czk"],["Peso dominicano", "peso dominicano|pesos dominicanos|rd$|dop"],["Centavo dominicano", "centavo dominicano|centavos dominicanos"],["Franco ruandés", "franco ruandés|francos ruandeses|rf|rwf"],["Céntimo ruandés", "céntimo ruandés|céntimos ruandeses"],["Leu rumano", "leu rumano|lei rumanos|ron"],["Ban rumano", "ban rumano|bani rumanos"],["Rublo ruso", "rublo ruso|rublos rusos|rub"],["Kopek ruso", "kopek ruso|kopeks rusos"],["Tala", "tala|tālā|ws$|sat|wst"],["Sene", "sene"],["Libra de Santa Helena", "libra de santa helena|libras de santa helena|shp"],["Penique de Santa Helena", "penique de santa helena|peniques de santa helena"],["Dobra", "dobra"],["Dinar serbio", "dinar serbio|dinares serbios|rsd"],["Para serbio", "para serbio|para serbios"],["Rupia de Seychelles", "rupia de seychelles|rupias de seychelles|scr"],["Centavo de Seychelles", "centavo de seychelles|centavos de seychelles"],["Leone", "leone|le|sll"],["Dólar de Singapur", "dólar de singapur|dólares de singapur|sgb"],["Centavo de Singapur", "centavo de Singapur|centavos de Singapur"],["Libra siria", "libra siria|libras sirias|s£|syp"],["Piastra siria", "piastra siria|piastras sirias"],["Chelín somalí", "chelín somalí|chelines somalies|sos"],["Centavo somalí", "centavo somalí|centavos somalies"],["Chelín somalilandés", "chelín somalilandés|chelines somalilandeses"],["Centavo somalilandés", "centavo somalilandés|centavos somalilandeses"],["Rupia de Sri Lanka", "rupia de Sri Lanka|rupias de Sri Lanka|lkr"],["Céntimo de Sri Lanka", "céntimo de Sri Lanka|céntimos de Sri Lanka"],["Lilangeni", "lilangeni|emalangeni|szl"],["Rand sudafricano", "rand|rand sudafricano|zar"],["Libra sudanesa", "libra sudanesa|libras sudanesas|sdg"],["Piastra sudanesa", "piastra sudanesa|piastras sudanesas"],["Libra sursudanesa", "libra sursudanesa|libras sursudanesa|ssp"],["Piastra sursudanesa", "piastra sursudanesa|piastras sursudanesas"],["Corona sueca", "corona sueca|coronas suecas|sek"],["Franco suizo", "franco suizo|francos suizos|sfr|chf"],["Rappen suizo", "rappen suizo|rappens suizos"],["Dólar surinamés", "óolar surinamés|dólares surinameses|srd"],["Centavo surinamés", "centavo surinamés|centavos surinamés"],["Baht tailandés", "baht tailandés|baht tailandeses|thb"],["Satang tailandés", "satang tailandés|satang tailandeses"],["Nuevo dólar taiwanés", "nuevo dólar taiwanés|dólar taiwanés|dólares taiwaneses|twd"],["Centavo taiwanés", "centavo taiwanés|centavos taiwaneses"],["Chelín tanzano", "chelín tanzano|chelines tanzanos|tzs"],["Centavo tanzano", "centavo tanzano|centavos tanzanos"],["Somoni tayiko", "somoni tayiko|somoni|tjs"],["Diram", "diram|dirams"],["Paʻanga", "dólar tongano|dólares tonganos|paʻanga|pa'anga|top"],["Seniti", "seniti"],["Rublo de Transnistria", "rublo de transnistria|rublos de transnistria"],["Kopek de Transnistria", "kopek de transnistria|kopeks de transnistria"],["Dólar trinitense", "dólar trinitense|dólares trinitenses|ttd"],["Centavo trinitense", "centavo trinitense|centavos trinitenses"],["Dinar tunecino", "dinar tunecino|dinares tunecinos|tnd"],["Millime tunecino", "millime tunecino|millimes tunecinos"],["Lira turca", "lira turca|liras turcas|try"],["Kuruş turca", "kuruş turca|kuruş turcas"],["Manat turkmeno", "manat turkmeno|manat turkmenos|tmt"],["Tennesi turkmeno", "tennesi turkmeno|tenge turkmeno"],["Dólar tuvaluano", "dólar tuvaluano|dólares tuvaluanos"],["Centavo tuvaluano", "centavo tuvaluano|centavos tuvaluanos"],["Grivna", "grivna|grivnas|uah"],["Kopiyka", "kopiyka|kópeks"],["Chelín ugandés", "chelín ugandés|chelines ugandeses|ugx"],["Centavo ugandés", "centavo ugandés|centavos ugandeses"],["Peso uruguayo", "peso uruguayo|pesos uruguayos|uyu"],["Centésimo uruguayo", "centésimo uruguayo|centésimos uruguayos"],["Som uzbeko", "som uzbeko|som uzbekos|uzs"],["Tiyin uzbeko", "tiyin uzbeko|tiyin uzbekos"],["Vatu", "vatu|vuv"],["Bolívar fuerte", "bolívar fuerte|bolívar|bolívares|vef"],["Céntimo de bolívar", "céntimo de bolívar|céntimos de bolívar"],["Đồng vietnamita", "Đồng vietnamita|dong vietnamita|dong vietnamitas|vnd"],["Hào vietnamita", "Hào vietnamita|hao vietnamita|hao vietnamitas"],["Rial yemení", "rial yemení|riales yemenies|yer"],["Fils yemení", "fils yemení|fils yemenies"],["Franco yibutiano", "franco yibutiano|francos yibutianos|djf"],["Dinar yugoslavo", "dinar yugoslavo|dinares yugoslavos|yud"],["Kwacha zambiano", "kwacha zambiano|kwacha zambianos|zmw"],["Ngwee zambiano", "ngwee zambiano|ngwee zambianos"],["Bitcoin", "bitcoin|bitcoins|btc|xbt|₿"],["Millibitcoin", "millibitcoin|millibitcoins|milibitcoin|milibitcoins"],["Satoshi", "satoshi|satoshis"]]); - export const CurrencyNameToIsoCodeMap: ReadonlyMap = new Map([["Afgani afgano", "AFN"],["Euro", "EUR"],["Lek albanés", "ALL"],["Kwanza angoleño", "AOA"],["Dram armenio", "AMD"],["Florín arubeño", "AWG"],["Taka bangladeshí", "BDT"],["Ngultrum butanés", "BTN"],["Boliviano", "BOB"],["Marco bosnioherzegovino", "BAM"],["Pula", "BWP"],["Real brasileño", "BRL"],["Lev búlgaro", "BGN"],["Riel camboyano", "KHR"],["Escudo caboverdiano", "CVE"],["Colón costarricense", "CRC"],["Kuna croata", "HRK"],["Corona checa", "CZK"],["Nakfa", "ERN"],["Birr etíope", "ETB"],["Dalasi", "GMD"],["Lari georgiano", "GEL"],["Cedi", "GHS"],["Quetzal guatemalteco", "GTQ"],["Gourde haitiano", "HTG"],["Lempira hondureño", "HNL"],["Forinto húngaro", "HUF"],["Rial iraní", "IRR"],["Rial yemení", "YER"],["Nuevo shéquel", "ILS"],["Yen", "JPY"],["Tenge kazajo", "KZT"],["Chelín keniano", "KES"],["Won norcoreano", "KPW"],["Won surcoreano", "KRW"],["Som kirguís", "KGS"],["Kip laosiano", "LAK"],["Loti", "LSL"],["Rand sudafricano", "ZAR"],["Pataca macaense", "MOP"],["Denar macedonio", "MKD"],["Ariary malgache", "MGA"],["Kwacha malauí", "MWK"],["Ringgit malayo", "MYR"],["Uguiya", "MRO"],["Tugrik mongol", "MNT"],["Metical mozambiqueño", "MZN"],["Kyat birmano", "MMK"],["Córdoba nicaragüense", "NIO"],["Naira", "NGN"],["Lira turca", "TRY"],["Rial omaní", "OMR"],["Balboa panameño", "PAB"],["Kina", "PGK"],["Guaraní", "PYG"],["Sol", "PEN"],["Złoty", "PLN"],["Riyal qatarí", "QAR"],["Riyal saudí", "SAR"],["Tala", "WST"],["São Tomé and Príncipe dobra", "STN"],["Leone", "SLL"],["Lilangeni", "SZL"],["Somoni tayiko", "TJS"],["Baht tailandés", "THB"],["Grivna", "UAH"],["Vatu", "VUV"],["Bolívar fuerte", "VEF"],["Kwacha zambiano", "ZMW"],["Dirham marroquí", "MAD"],["Dirham de los Emiratos Árabes Unidos", "AED"],["Manat azerí", "AZN"],["Manat turkmeno", "TMT"],["Chelín somalí", "SOS"],["Chelín tanzano", "TZS"],["Chelín ugandés", "UGX"],["Leu rumano", "RON"],["Leu moldavo", "MDL"],["Rupia nepalí", "NPR"],["Rupia pakistaní", "PKR"],["Rupia india", "INR"],["Rupia de Seychelles", "SCR"],["Rupia de Mauricio", "MUR"],["Rupia de Maldivas", "MVR"],["Rupia de Sri Lanka", "LKR"],["Rupia indonesia", "IDR"],["Corona danesa", "DKK"],["Corona noruega", "NOK"],["Corona islandesa", "ISK"],["Corona sueca", "SEK"],["Franco CFA de África Occidental", "XOF"],["Franco CFA de África Central", "XAF"],["Franco comorano", "KMF"],["Franco congoleño", "CDF"],["Burundian franc", "BIF"],["Franco yibutiano", "DJF"],["Franco CFP", "XPF"],["Franco guineano", "GNF"],["Franco suizo", "CHF"],["Franco ruandés", "RWF"],["Rublo ruso", "RUB"],["Transnistrian ruble", "PRB"],["New Belarusian ruble", "BYN"],["Dinar argelino", "DZD"],["Dinar bahreiní", "BHD"],["Dinar iraquí", "IQD"],["Dinar jordano", "JOD"],["Kuwaiti dinar", "KWD"],["Dinar libio", "LYD"],["Dinar serbio", "RSD"],["Dinar tunecino", "TND"],["Peso argentino", "ARS"],["Chilean peso", "CLP"],["Peso colombiano", "COP"],["Peso cubano convertible", "CUC"],["Peso cubano", "CUP"],["Peso dominicano", "DOP"],["Peso mexicano", "MXN"],["Peso uruguayo", "UYU"],["Libra esterlina", "GBP"],["Libra de Santa Helena", "SHP"],["Libra egipcia", "EGP"],["Libra malvinense", "FKP"],["Libra gibraltareña", "GIP"],["Libra manesa", "IMP"],["Libra de Jersey", "JEP"],["Libra libanesa", "LBP"],["Libra sursudanesa", "SSP"],["Libra sudanesa", "SDG"],["Libra siria", "SYP"],["Dólar estadounidense", "USD"],["Dólar australiano", "AUD"],["Dólar bahameño", "BSD"],["Dólar de Barbados", "BBD"],["Dólar beliceño", "BZD"],["Dólar bermudeño", "BMD"],["Dólar de Brunéi", "BND"],["Dólar de Singapur", "SGD"],["Dólar canadiense", "CAD"],["Dólar de las Islas Caimán", "KYD"],["Dólar neozelandés", "NZD"],["Dólar fiyiano", "FJD"],["Dólar guyanés", "GYD"],["Dólar de Hong Kong", "HKD"],["Dólar jamaiquino", "JMD"],["Dólar liberiano", "LRD"],["Dólar namibio", "NAD"],["Dólar de las Islas Salomón", "SBD"],["Dólar surinamés", "SRD"],["Nuevo dólar taiwanés", "TWD"],["Dólar trinitense", "TTD"],["Tuvaluan dollar", "TVD"],["Yuan chino", "CNY"],["Rial", "__RI"],["Chelín", "__S"],["Som", "__SO"],["Dirham", "__DR"],["Dinar", "_DN"],["Dólar", "__D"],["Manat", "__MA"],["Rupia", "__R"],["Corona", "__K"],["Franco", "__F"],["Marco", "__M"],["Rublo", "__RB"],["Peso", "__PE"],["Libra", "__P"],["Tristan da Cunha libra", "_TP"],["South Georgia and the South Sandwich Islands libra", "_SP"],["Somaliland chelín", "_SS"],["Pitcairn Islands dólar", "_PND"],["Palauan dólar", "_PD"],["Niue dólar", "_NID"],["Nauruan dólar", "_ND"],["Micronesian dólar", "_MD"],["Kiribati dólar", "_KID"],["Guernsey libra", "_GGP"],["Faroese corona", "_FOK"],["Cook Islands dólar", "_CKD"],["British Virgin Islands dólar", "_BD"],["Ascension libra", "_AP"],["Alderney libra", "_ALP"],["Abkhazian apsar", "_AA"],["Bitcoin", "_XBT"]]); - export const FractionalUnitNameToCodeMap: ReadonlyMap = new Map([["Jiao", "JIAO"],["Kópek", "KOPEK"],["Kopek", "KOPEK"],["Pul", "PUL"],["Cent", "CENT"],["Qindarka", "QINDARKE"],["Penique", "PENNY"],["Santeem", "SANTEEM"],["Cêntimo", "CENT"],["Centavo", "CENT"],["Luma", "LUMA"],["Qəpik", "QƏPIK"],["Fils", "FILS"],["Poisha", "POISHA"],["Kapyeyka", "KAPYEYKA"],["Kopyeyka", "KOPYEYKA"],["Centime", "CENTIME"],["Chetrum", "CHETRUM"],["Paisa", "PAISA"],["Feningas", "FENING"],["Thebe", "THEBE"],["Sen", "SEN"],["Stotinka", "STOTINKA"],["Fen", "FEN"],["Céntimo", "CENT"],["Lipa", "LIPA"],["Haléř", "HALER"],["Øre", "ØRE"],["Piastre", "PIASTRE"],["Santim", "SANTIM"],["Oyra", "OYRA"],["Butut", "BUTUT"],["Tetri", "TETRI"],["Pesewa", "PESEWA"],["Fillér", "FILLER"],["Eyrir", "EYRIR"],["Dinar", "DINAR"],["Agora", "AGORA"],["Tïın", "TIIN"],["Chon", "CHON"],["Jeon", "JEON"],["Tyiyn", "TYIYN"],["Att", "ATT"],["Sente", "SENTE"],["Dirham", "DIRHAM"],["Rappen", "RAPPEN"],["Avo", "AVO"],["Deni", "DENI"],["Iraimbilanja", "IRAIMBILANJA"],["Tambala", "TAMBALA"],["Laari", "LAARI"],["Khoums", "KHOUMS"],["Ban", "BAN"],["Möngö", "MONGO"],["Pya", "PYA"],["Kobo", "KOBO"],["Kuruş", "KURUS"],["Baisa", "BAISA"],["Centésimo", "CENTESIMO"],["Toea", "TOEA"],["Sentimo", "SENTIMO"],["Grosz", "GROSZ"],["Sene", "SENE"],["Halala", "HALALA"],["Para", "PARA"],["Öre", "ORE"],["Diram", "DIRAM"],["Satang", "SATANG"],["Seniti", "SENITI"],["Millime", "MILLIME"],["Tennesi", "TENNESI"],["Kopiyka", "KOPIYKA"],["Tiyin", "TIYIN"],["Hào", "HAO"],["Ngwee", "NGWEE"],["Millibitcoin", "MILLIBITCOIN"],["Satoshi", "SATOSHI"]]); - export const CompoundUnitConnectorRegex = `(?y|con)`; - export const MultiplierRegex = `\\s*\\b(((mil\\s+)?mi|bi|cuatri|quinti|sexti|septi)ll[oó]n|mil)(es)?\\b`; - export const CurrencyPrefixList: ReadonlyMap = new Map([["Dobra", "db|std"],["Dólar", "$|dólar|dólares|dolar|dolares"],["Dólar estadounidense", "us$|u$d|usd"],["Dólar del Caribe Oriental", "ec$|xcd"],["Dólar australiano", "a$|aud"],["Dólar bahameño", "b$|bsd"],["Dólar de Barbados", "bds$|bbd"],["Dólar beliceño", "bz$|bzd"],["Dólar bermudeño", "bd$|bmd"],["Dólar de Brunéi", "brunéi $|bnd"],["Dólar de Singapur", "s$|sgd"],["Dólar canadiense", "c$|can$|cad"],["Dólar de las Islas Caimán", "ci$|kyd"],["Dólar neozelandés", "nz$|nzd"],["Dólar fiyiano", "fj$|fjd"],["Dólar guyanés", "gy$|gyd"],["Dólar de Hong Kong", "hk$|hkd"],["Dólar jamaiquino", "j$|ja$|jmd"],["Dólar liberiano", "l$|lrd"],["Dólar namibio", "n$|nad"],["Dólar de las Islas Salomón", "si$|sbd"],["Nuevo dólar taiwanés", "nt$|twd"],["Peso mexicano", "mxn|mxn$|mxn $|mex$"],["Real brasileño", "r$|brl"],["Guaraní", "₲|gs.|pyg"],["Dólar trinitense", "tt$|ttd"],["Yuan chino", "¥|cny|rmb"],["Yen", "¥|jpy"],["Euro", "€|eur"],["Florín", "ƒ"],["Libra", "£"],["Colón costarricense", "₡"],["Lira turca", "₺"],["Bitcoin", "₿|btc|xbt"]]); - export const AmbiguousCurrencyUnitList = [ "le","db","std" ]; - export const InformationSuffixList: ReadonlyMap = new Map([["bit", "bit|bits"],["kilobit", "kilobit|kilobits|kb|kbit"],["megabit", "megabit|megabits|Mb|Mbit"],["gigabit", "gigabit|gigabits|Gb|Gbit"],["terabit", "terabit|terabits|Tb|Tbit"],["petabit", "petabit|petabits|Pb|Pbit"],["kibibit", "kibibit|kibibits|kib|kibit"],["mebibit", "mebibit|mebibits|Mib|Mibit"],["gibibit", "gibibit|gibibits|Gib|Gibit"],["tebibit", "tebibit|tebibits|Tib|Tibit"],["pebibit", "pebibit|pebibits|Pib|Pibit"],["byte", "byte|bytes"],["kilobyte", "kilobyte|kilobytes|kB|kByte"],["megabyte", "megabyte|megabytes|MB|MByte"],["gigabyte", "gigabyte|gigabytes|GB|GByte"],["terabyte", "terabyte|terabytes|TB|TByte"],["petabyte", "petabyte|petabytes|PB|PByte"],["kibibyte", "kibibyte|kibibytes|kiB|kiByte"],["mebibyte", "mebibyte|mebibytes|MiB|MiByte"],["gibibyte", "gibibyte|gibibytes|GiB|GiByte"],["tebibyte", "tebibyte|tebibytes|TiB|TiByte"],["pebibyte", "pebibyte|pebibytes|PiB|PiByte"]]); - export const AmbiguousDimensionUnitList = [ "al","mi","área","áreas","pie","pies","\"" ]; - export const LengthSuffixList: ReadonlyMap = new Map([["Kilómetro", "km|kilometro|kilómetro|kilometros|kilómetros"],["Hectómetro", "hm|hectometro|hectómetro|hectometros|hectómetros"],["Decámetro", "decametro|decámetro|decametros|decámetros|dam"],["Metro", "m|m.|metro|metros"],["Decímetro", "dm|decimetro|decímetro|decimetros|decímetros"],["Centímetro", "cm|centimetro|centímetro|centimetros|centimetros"],["Milímetro", "mm|milimetro|milímetro|milimetros|milímetros"],["Micrómetro", "µm|um|micrometro|micrómetro|micrometros|micrómetros|micrón|micrónes"],["Nanómetro", "nm|nanometro|nanómetro|nanometros|nanómetros"],["Picómetro", "pm|picometro|picómetro|picometros|picómetros"],["Milla", "mi|milla|millas"],["Yarda", "yd|yarda|yardas"],["Pulgada", "pulgada|pulgadas|\""],["Pie", "pie|pies|ft"],["Año luz", "año luz|años luz|al"]]); - export const AmbiguousLengthUnitList = [ "mi","área","áreas","\"" ]; - export const BuildPrefix = `(?<=(\\s|^|\\P{L}))`; - export const BuildSuffix = `(?=(\\s|\\P{L}|$))`; - export const ConnectorToken = `de`; - export const SpeedSuffixList: ReadonlyMap = new Map([["Metro por segundo", "metro/segundo|m/s|metro por segundo|metros por segundo|metros por segundos"],["Kilómetro por hora", "km/h|kilómetro por hora|kilometro por hora|kilómetros por hora|kilometros por hora|kilómetro/hora|kilometro/hora|kilómetros/hora|kilometros/hora"],["Kilómetro por minuto", "km/min|kilómetro por minuto|kilometro por minuto|kilómetros por minuto|kilometros por minuto|kilómetro/minuto|kilometro/minuto|kilómetros/minuto|kilometros/minuto"],["Kilómetro por segundo", "km/seg|kilómetro por segundo|kilometro por segundo|kilómetros por segundo|kilometros por segundo|kilómetro/segundo|kilometro/segundo|kilómetros/segundo|kilometros/segundo"],["Milla por hora", "mph|milla por hora|mi/h|milla/hora|millas/hora|millas por hora"],["Nudo", "kt|nudo|nudos|kn"],["Pie por segundo", "ft/s|pie/s|ft/seg|pie/seg|pie por segundo|pies por segundo"],["Pie por minuto", "ft/min|pie/min|pie por minuto|pies por minuto"],["Yarda por minuto", "yardas por minuto|yardas/minuto|yardas/min"],["Yarda por segundo", "yardas por segundo|yardas/segundo|yardas/seg"]]); - export const AmbiguousSpeedUnitList = [ "nudo","nudos" ]; - export const TemperatureSuffixList: ReadonlyMap = new Map([["Kelvin", "k|K|kelvin"],["Rankine", "r|rankine"],["Grado Celsius", "°c|° c|ºc|º c|grado c|grados c|grado celsius|grados celsius|celsius|grado centígrado|grados centígrados|centígrado|centígrados"],["Grado Fahrenheit", "°f|° f|ºf|º f|grado f|grados f|grado fahrenheit|grados fahrenheit|fahrenheit"],["Grado Réaumur", "°r|°re|grados r|grado réaumur|grados réaumur|réaumur"],["Grado Delisle", "°d|grados d|grado delisle|grados delisle|delisle"],["Grado", "°|grados|grado"]]); - export const VolumeSuffixList: ReadonlyMap = new Map([["Kilómetro cúbico", "kilómetro cúbico|kilómetros cúbico|km3|km^3|km³"],["Hectómetro cúbico", "hectómetro cúbico|hectómetros cúbico|hm3|hm^3|hm³"],["Decámetro cúbico", "decámetro cúbico|decámetros cúbico|dam3|dam^3|dam³"],["Metro cúbico", "metro cúbico|metros cúbico|m3|m^3|m³"],["Decímetro cúbico", "decímetro cúbico|decímetros cúbico|dm3|dm^3|dm³"],["Centímetro cúbico", "centímetro cúbico|centímetros cúbico|cc|cm3|cm^3|cm³"],["Milímetro cúbico", "milímetro cúbico|milímetros cúbico|mm3|mm^3|mm³"],["Pulgada cúbica", "pulgada cúbica|pulgadas cúbicas"],["Pie cúbico", "pie cúbico|pies cúbicos|pie3|pie^3|pie³|ft3|ft^3|ft³"],["Yarda cúbica", "yarda cúbica|yardas cúbicas|yd3|yd^3|yd³"],["Hectolitro", "hectolitro|hectolitros|hl"],["Litro", "litro|litros|lts|l"],["Mililitro", "mililitro|mililitros|ml"],["Galón", "galón|galones"],["Pinta", "pinta|pintas"],["Barril", "barril|barriles|bbl"],["Onza líquida", "onza líquida|onzas líquidas"]]); - export const WeightSuffixList: ReadonlyMap = new Map([["Tonelada métrica", "tonelada métrica|toneladas métricas|t.métrica|t métrica|t. métrica|tonelada metrica|toneladas metricas|t.metrica|t metrica|t. metrica"],["Tonelada", "ton|tonelada|toneladas|t"],["Kilogramo", "kg|kilogramo|kilogramos"],["Hectogramo", "hg|hectogramo|hectogramos"],["Decagramo", "dag|decagramo|decagramos"],["Gramo", "g|gr|gramo|gramos"],["Decigramo", "dg|decigramo|decigramos"],["Centigramo", "cg|centigramo|centigramos"],["Miligramo", "mg|miligramo|miligramos"],["Microgramo", "µg|ug|microgramo|microgramos"],["Nanogramo", "ng|nanogramo|nanogramos"],["Picogramo", "pg|picogramo|picogramos"],["Libra", "lb|libra|libras"],["Onza", "oz|onza|onzas"],["Grano", "grano|granos"],["Quilate", "ct|quilate|quilates"]]); - export const AmbiguousWeightUnitList = [ "g","t" ]; - export const AngleSuffixList: ReadonlyMap = new Map([["Degree", "grado|grados|°"],["Radian", "radián|radian|radianes|rad"],["Turn", "vuelta|vueltas"]]); - export const AmbiguousAngleUnitList = [ "vuelta","vueltas" ]; - export const AmbiguityFiltersDict: ReadonlyMap = new Map([["null", "null"]]); - export const TemperatureAmbiguityFiltersDict: ReadonlyMap = new Map([["\\b(grados?|°)$", "\\b((grados?|°)\\s*(angolo|rotaci[oó]n)|(gira(r|do|torio)?|angolo|rotaci[oó]n)(\\s+(\\p{L}+|\\d+)){0,4}\\s*(grados?\\b|°))"]]); - export const DimensionAmbiguityFiltersDict: ReadonlyMap = new Map([["\\b(grados?|°)$", "\\b((grados?|°)\\s*(c(elsius|entígrado)?|f(ah?renheit)?)|(temperatura)(\\s+(\\p{L}+|\\d+)){0,4}\\s*(grados?\\b|°))"]]); -} diff --git a/JavaScript/packages/recognizers-number-with-unit/tsconfig.json b/JavaScript/packages/recognizers-number-with-unit/tsconfig.json deleted file mode 100644 index 4c43817e54..0000000000 --- a/JavaScript/packages/recognizers-number-with-unit/tsconfig.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "target": "es2015", - "outDir": "compiled", - "sourceMap": true, - "rootDir": "src", - "moduleResolution": "node", - "declaration": true, - "declarationDir": "dist/types", - "typeRoots": [ - "node_modules/@types" - ] - }, - "include": [ - "src" - ] -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-number/.npmignore b/JavaScript/packages/recognizers-number/.npmignore deleted file mode 100644 index 757fb9517d..0000000000 --- a/JavaScript/packages/recognizers-number/.npmignore +++ /dev/null @@ -1,4 +0,0 @@ -* -!dist/*.js -!dist/types/**/* -!README.md \ No newline at end of file diff --git a/JavaScript/packages/recognizers-number/README.md b/JavaScript/packages/recognizers-number/README.md deleted file mode 100644 index 4407681b40..0000000000 --- a/JavaScript/packages/recognizers-number/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# Microsoft.Recognizers.Text for JavaScript - -This module (`recognizers-text-number`) is a sub-module of `recognizers-text-suite`. - -Please check the [main README](https://github.com/Microsoft/Recognizers-Text/tree/master/JavaScript/packages/recognizers-text-suite) for more details. \ No newline at end of file diff --git a/JavaScript/packages/recognizers-number/package-lock.json b/JavaScript/packages/recognizers-number/package-lock.json deleted file mode 100644 index f4ebb1fdee..0000000000 --- a/JavaScript/packages/recognizers-number/package-lock.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "name": "@microsoft/recognizers-text-number", - "version": "1.3.0", - "lockfileVersion": 1, - "requires": true, - "dependencies": { - "bignumber.js": { - "version": "7.2.1", - "resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-7.2.1.tgz", - "integrity": "sha512-S4XzBk5sMB+Rcb/LNcpzXr57VRTxgAvaAEDAl1AwRx27j00hT84O6OkteE7u8UB3NuaaygCRrEpqox4uDOrbdQ==" - }, - "lodash.escaperegexp": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/lodash.escaperegexp/-/lodash.escaperegexp-4.1.2.tgz", - "integrity": "sha1-ZHYsSGGAglGKw99Mz11YhtriA0c=" - }, - "lodash.sortby": { - "version": "4.7.0", - "resolved": "https://registry.npmjs.org/lodash.sortby/-/lodash.sortby-4.7.0.tgz", - "integrity": "sha1-7dFMgk4sycHgsKG0K7UhBRakJDg=" - }, - "lodash.trimend": { - "version": "4.5.1", - "resolved": "https://registry.npmjs.org/lodash.trimend/-/lodash.trimend-4.5.1.tgz", - "integrity": "sha1-EoBENyhrmMrYmWt5QU4RMAEUCC8=" - } - } -} diff --git a/JavaScript/packages/recognizers-number/package.json b/JavaScript/packages/recognizers-number/package.json deleted file mode 100644 index 856b596dcd..0000000000 --- a/JavaScript/packages/recognizers-number/package.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "name": "@microsoft/recognizers-text-number", - "version": "1.3.0", - "description": "recognizers-text-number provides robust recognition and resolution of numbers expressed in multiple languages.", - "author": "Microsoft Corp.", - "license": "MIT", - "keywords": [ - "nlp", - "nlp-entity-extraction", - "entity-extraction", - "numex", - "parser-library" - ], - "main": "dist/recognizers-text-number.umd.js", - "module": "dist/recognizers-text-number.es5.js", - "typings": "dist/types/recognizers-text-number.d.ts", - "browser": "dist/recognizers-text-number.browser.js", - "repository": { - "type": "git", - "url": "https://github.com/Microsoft/Recognizers-Text" - }, - "bugs": { - "url": "https://github.com/Microsoft/Recognizers-Text/issues" - }, - "engines": { - "node": ">=10.3.0" - }, - "scripts": { - "build-resources": "ts-node --project ../resource-generator/tsconfig.json ../resource-generator/ ../recognizers-number/resource-definitions.json", - "clean-build": "rimraf dist && rimraf compiled", - "prepare": "npm run build-resources && npm run clean-build && tsc && rollup -c" - }, - "dependencies": { - "@microsoft/recognizers-text": "~1.3.0", - "bignumber.js": "^7.2.1", - "lodash.escaperegexp": "^4.1.2", - "lodash.sortby": "^4.7.0", - "lodash.trimend": "^4.5.1" - } -} diff --git a/JavaScript/packages/recognizers-number/resource-definitions.json b/JavaScript/packages/recognizers-number/resource-definitions.json deleted file mode 100644 index 41a3b1ac84..0000000000 --- a/JavaScript/packages/recognizers-number/resource-definitions.json +++ /dev/null @@ -1,67 +0,0 @@ -{ - "outputPath": "./src/resources/", - "configFiles": [ - { - "input": [ "Base-Numbers" ], - "output": "baseNumbers", - "header": [ - "export namespace BaseNumbers {" - ], - "footer": [ "}" ] - }, - { - "input": [ "English", "English-Numbers" ], - "output": "englishNumeric", - "header": [ - "import { BaseNumbers } from \"./baseNumbers\";", - "export namespace EnglishNumeric {" - ], - "footer": [ "}" ] - }, - { - "input": [ "Spanish", "Spanish-Numbers" ], - "output": "spanishNumeric", - "header": [ - "import { BaseNumbers } from \"./baseNumbers\";", - "export namespace SpanishNumeric {" - ], - "footer": [ "}" ] - }, - { - "input": [ "Portuguese", "Portuguese-Numbers" ], - "output": "portugueseNumeric", - "header": [ - "import { BaseNumbers } from \"./baseNumbers\";", - "export namespace PortugueseNumeric {" - ], - "footer": [ "}" ] - }, - { - "input": [ "Chinese", "Chinese-Numbers" ], - "output": "chineseNumeric", - "header": [ - "import { BaseNumbers } from \"./baseNumbers\";", - "export namespace ChineseNumeric {" - ], - "footer": [ "}" ] - }, - { - "input": [ "Japanese", "Japanese-Numbers" ], - "output": "japaneseNumeric", - "header": [ - "import { BaseNumbers } from \"./baseNumbers\";", - "export namespace JapaneseNumeric {" - ], - "footer": [ "}" ] - }, - { - "input": [ "French", "French-Numbers" ], - "output": "frenchNumeric", - "header": [ - "import { BaseNumbers } from \"./baseNumbers\";", - "export namespace FrenchNumeric {" - ], - "footer": [ "}" ] - } - ] -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-number/rollup.config.js b/JavaScript/packages/recognizers-number/rollup.config.js deleted file mode 100644 index 4e98e5691a..0000000000 --- a/JavaScript/packages/recognizers-number/rollup.config.js +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import resolve from 'rollup-plugin-node-resolve'; -import commonjs from 'rollup-plugin-commonjs'; -import sourceMaps from 'rollup-plugin-sourcemaps'; -import pkg from './package.json'; -import camelCase from 'lodash.camelcase'; -import alias from 'rollup-plugin-alias'; -import path from 'path'; - -export default { - input: `compiled/recognizers-text-number.js`, - output: [ - { file: pkg.module, format: 'es' }, - { file: pkg.main, name: camelCase(pkg.name), format: 'umd', exports: 'named' }, - { file: pkg.browser, format: 'iife', name: camelCase(pkg.name), exports: 'named' } - ], - exports: 'named', - sourcemap: true, - plugins: [ - alias({ - '@microsoft/recognizers-text': path.resolve(__dirname, '../recognizers-text/compiled/recognizers-text.js') - }), - // Allow bundling cjs modules (unlike webpack, rollup doesn't understand cjs) - commonjs(), - // Allow node_modules resolution, so you can use 'external' to control - // which external modules to include in the bundle - // https://github.com/rollup/rollup-plugin-node-resolve#usage - resolve(), - - // Resolve source maps to the original source - sourceMaps() - ] -}; diff --git a/JavaScript/packages/recognizers-number/src/culture.ts b/JavaScript/packages/recognizers-number/src/culture.ts deleted file mode 100644 index f074898a82..0000000000 --- a/JavaScript/packages/recognizers-number/src/culture.ts +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { Culture as BaseCulture, CultureInfo as BaseCultureInfo } from "@microsoft/recognizers-text"; -import trimEnd = require("lodash.trimend"); -import { BigNumber } from 'bignumber.js/bignumber'; -import { LongFormatType } from "./number/models"; - -export class Culture extends BaseCulture { - - static readonly supportedCultures: Culture[] = [ - new Culture("English", Culture.English, new LongFormatType(',', '.')), - new Culture("EnglishOthers", Culture.EnglishOthers, new LongFormatType(',', '.')), - new Culture("Chinese", Culture.Chinese, null), - new Culture("Spanish", Culture.Spanish, new LongFormatType('.', ',')), - new Culture("Portuguese", Culture.Portuguese, new LongFormatType('.', ',')), - new Culture("French", Culture.French, new LongFormatType('.', ',')), - new Culture("Japanese", Culture.Japanese, new LongFormatType(',', '.')) - ] - - readonly longFormat: LongFormatType - - private constructor(cultureName: string, cultureCode: string, longFormat: LongFormatType) { - super(cultureName, cultureCode); - this.longFormat = longFormat; - } -} - -export class CultureInfo extends BaseCultureInfo { - format(value: number | BigNumber): string { - - let bigNumber = new BigNumber(value); - let s: string; - if (bigNumber.decimalPlaces()) { - s = bigNumber.precision(15, BigNumber.ROUND_HALF_UP).toString(); - } - else { - s = bigNumber.toString().toUpperCase(); - } - - if (s.indexOf('.') > -1) { - // trim leading 0 from decimal places - s = trimEnd(s, '0'); - } - - if (s.indexOf('e-') > -1) { - // mimic .NET behavior by adding leading 0 to exponential. E.g.: 1E-07 - let p = s.split('e-'); - p[1] = p[1].length === 1 ? ('0' + p[1]) : p[1]; - s = p.join('E-'); - } - - // TODO: Use BigNumber.toFormat instead - let culture = Culture.supportedCultures.find(c => c.cultureCode === this.code); - if (culture && culture.longFormat) { - return s - .split(',') - .map(t => t.split('.').join(culture.longFormat.decimalsMark)) - .join(culture.longFormat.thousandsMark); - } - - return s; - } -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-number/src/number/agnosticNumberParser.ts b/JavaScript/packages/recognizers-number/src/number/agnosticNumberParser.ts deleted file mode 100644 index 0bdbec2503..0000000000 --- a/JavaScript/packages/recognizers-number/src/number/agnosticNumberParser.ts +++ /dev/null @@ -1,65 +0,0 @@ - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { INumberParserConfiguration, BaseNumberParser, BasePercentageParser } from "./parsers"; -import { Culture } from "../culture"; -import { Constants } from "./constants"; -import { BaseCJKNumberParser } from "./cjkParsers"; -import { ChineseNumberParserConfiguration } from "./chinese/parserConfiguration"; -import { JapaneseNumberParserConfiguration } from "./japanese/parserConfiguration"; - -export enum AgnosticNumberParserType { - Cardinal, - Double, - Fraction, - Integer, - Number, - Ordinal, - Percentage -} - -export class AgnosticNumberParserFactory { - static getParser(type: AgnosticNumberParserType, languageConfiguration: INumberParserConfiguration): BaseNumberParser { - - let isChinese = languageConfiguration.cultureInfo.code.toLowerCase() === Culture.Chinese; - let isJapanese = languageConfiguration.cultureInfo.code.toLowerCase() === Culture.Japanese; - - let parser: BaseNumberParser; - - if (isChinese) { - parser = new BaseCJKNumberParser(languageConfiguration as ChineseNumberParserConfiguration); - } - else if (isJapanese) { - parser = new BaseCJKNumberParser(languageConfiguration as JapaneseNumberParserConfiguration); - } - else { - parser = new BaseNumberParser(languageConfiguration); - } - - switch (type) { - case AgnosticNumberParserType.Cardinal: - parser.supportedTypes = [Constants.SYS_NUM_CARDINAL, Constants.SYS_NUM_INTEGER, Constants.SYS_NUM_DOUBLE]; - break; - case AgnosticNumberParserType.Double: - parser.supportedTypes = [Constants.SYS_NUM_DOUBLE]; - break; - case AgnosticNumberParserType.Fraction: - parser.supportedTypes = [Constants.SYS_NUM_FRACTION]; - break; - case AgnosticNumberParserType.Integer: - parser.supportedTypes = [Constants.SYS_NUM_INTEGER]; - break; - case AgnosticNumberParserType.Ordinal: - parser.supportedTypes = [Constants.SYS_NUM_ORDINAL]; - break; - case AgnosticNumberParserType.Percentage: - if (!isChinese && !isJapanese) { - parser = new BasePercentageParser(languageConfiguration); - } - break; - } - - return parser; - } -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-number/src/number/chinese/extractors.ts b/JavaScript/packages/recognizers-number/src/number/chinese/extractors.ts deleted file mode 100644 index 73d91547ab..0000000000 --- a/JavaScript/packages/recognizers-number/src/number/chinese/extractors.ts +++ /dev/null @@ -1,307 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { BaseNumberExtractor, RegExpValue, RegExpRegExp, BasePercentageExtractor } from "../extractors"; -import { Constants } from "../constants"; -import { LongFormatType } from "../models"; -import { ChineseNumeric } from "../../resources/chineseNumeric"; -import { RegExpUtility } from "@microsoft/recognizers-text"; - -export enum ChineseNumberExtractorMode { - // Number extraction with an allow list that filters what numbers to extract. - Default, - // Extract all number-related terms aggressively. - ExtractAll, -} - -export class ChineseNumberExtractor extends BaseNumberExtractor { - protected extractType: string = Constants.SYS_NUM; - - constructor(mode: ChineseNumberExtractorMode = ChineseNumberExtractorMode.Default) { - super(); - let regexes = new Array(); - - // Add Cardinal - let cardExtract = new ChineseCardinalExtractor(mode); - cardExtract.regexes.forEach(r => regexes.push(r)); - - // Add Fraction - let fracExtract = new ChineseFractionExtractor(); - fracExtract.regexes.forEach(r => regexes.push(r)); - - this.regexes = regexes; - - // Add filter - let ambiguityFiltersDict = new Array(); - - - for (let [key, value] of ChineseNumeric.AmbiguityFiltersDict) { - ambiguityFiltersDict.push({ regExpKey: RegExpUtility.getSafeRegExp(key, "gs"), regExpValue: RegExpUtility.getSafeRegExp(value, "gs") }) - } - - this.ambiguityFiltersDict = ambiguityFiltersDict; - } -} - -export class ChineseCardinalExtractor extends BaseNumberExtractor { - protected extractType: string = Constants.SYS_NUM_CARDINAL; - - constructor(mode: ChineseNumberExtractorMode = ChineseNumberExtractorMode.Default) { - super(); - let regexes = new Array(); - - // Add Integer Regexes - let intExtract = new ChineseIntegerExtractor(mode); - intExtract.regexes.forEach(r => regexes.push(r)); - - // Add Double Regexes - let doubleExtract = new ChineseDoubleExtractor(); - doubleExtract.regexes.forEach(r => regexes.push(r)); - - this.regexes = regexes; - } -} - -export class ChineseIntegerExtractor extends BaseNumberExtractor { - protected extractType: string = Constants.SYS_NUM_INTEGER; - - constructor(mode: ChineseNumberExtractorMode = ChineseNumberExtractorMode.Default) { - super(); - - let regexes = new Array( - { // 123456, -123456 - regExp: RegExpUtility.getSafeRegExp(ChineseNumeric.NumbersSpecialsChars, "gi"), - value: "IntegerNum" - }, - { // 15k, 16 G - regExp: RegExpUtility.getSafeRegExp(ChineseNumeric.NumbersSpecialsCharsWithSuffix, "gs"), - value: "IntegerNum" - }, - { // 1,234, 2,332,111 - regExp: RegExpUtility.getSafeRegExp(ChineseNumeric.DottedNumbersSpecialsChar, "gis"), - value: "IntegerNum" - }, - { // 半百 半打 - regExp: RegExpUtility.getSafeRegExp(ChineseNumeric.NumbersWithHalfDozen, "gis"), - value: "Integer" + ChineseNumeric.LangMarker - }, - { // 半 - regExp: RegExpUtility.getSafeRegExp(ChineseNumeric.HalfUnitRegex, "gis"), - value: "Integer" + ChineseNumeric.LangMarker - }, - { // 一打 五十打 - regExp: RegExpUtility.getSafeRegExp(ChineseNumeric.NumbersWithDozen, "gis"), - value: "Integer" + ChineseNumeric.LangMarker - } - ); - - switch (mode) { - case ChineseNumberExtractorMode.Default: - regexes.push({ // 一百五十五, 负一亿三百二十二. Uses an allow list to avoid extracting "四" from "四川" - regExp: RegExpUtility.getSafeRegExp(ChineseNumeric.NumbersWithAllowListRegex, "gi"), - value: "Integer" + ChineseNumeric.LangMarker - }); - break; - - case ChineseNumberExtractorMode.ExtractAll: - regexes.push({ // 一百五十五, 负一亿三百二十二, "四" from "四川". Uses no allow lists and extracts all potential integers (useful in Units, for example). - regExp: RegExpUtility.getSafeRegExp(ChineseNumeric.NumbersAggressiveRegex, "gi"), - value: "Integer" + ChineseNumeric.LangMarker - }); - break; - } - - this.regexes = regexes; - } -} - -export class ChineseDoubleExtractor extends BaseNumberExtractor { - protected extractType: string = Constants.SYS_NUM_DOUBLE; - - constructor() { - super(); - - let regexes = new Array( - { - regExp: RegExpUtility.getSafeRegExp(ChineseNumeric.DoubleSpecialsChars, "gis"), - value: "DoubleNum" - }, - { // (-)2.5, can avoid cases like ip address xx.xx.xx.xx - regExp: RegExpUtility.getSafeRegExp(ChineseNumeric.DoubleSpecialsCharsWithNegatives, "gis"), - value: "DoubleNum" - }, - { // (-).2 - regExp: RegExpUtility.getSafeRegExp(ChineseNumeric.SimpleDoubleSpecialsChars, "gis"), - value: "DoubleNum" - }, - { // 1.0 K - regExp: RegExpUtility.getSafeRegExp(ChineseNumeric.DoubleWithMultiplierRegex, "gi"), - value: "DoubleNum" - }, - { // 15.2万 - regExp: RegExpUtility.getSafeRegExp(ChineseNumeric.DoubleWithThousandsRegex, "gi"), - value: "Double" + ChineseNumeric.LangMarker - }, - { // 四十五点三三 - regExp: RegExpUtility.getSafeRegExp(ChineseNumeric.DoubleAllFloatRegex, "gi"), - value: "Double" + ChineseNumeric.LangMarker - }, - { // 2e6, 21.2e0 - regExp: RegExpUtility.getSafeRegExp(ChineseNumeric.DoubleExponentialNotationRegex, "gis"), - value: "DoublePow" - }, - { // 2^5 - regExp: RegExpUtility.getSafeRegExp(ChineseNumeric.DoubleScientificNotationRegex, "gis"), - value: "DoublePow" - } - ); - - this.regexes = regexes; - } -} - -export class ChineseFractionExtractor extends BaseNumberExtractor { - - protected extractType: string = Constants.SYS_NUM_FRACTION; - - constructor() { - super(); - - let regexes = new Array( - { // -4 5/2, 4 6/3 - regExp: RegExpUtility.getSafeRegExp(ChineseNumeric.FractionNotationSpecialsCharsRegex, "gis"), - value: "FracNum" - }, - { // 8/3 - regExp: RegExpUtility.getSafeRegExp(ChineseNumeric.FractionNotationRegex, "gis"), - value: "FracNum" - }, - { // 四分之六十五 - regExp: RegExpUtility.getSafeRegExp(ChineseNumeric.AllFractionNumber, "gi"), - value: "Frac" + ChineseNumeric.LangMarker - } - ); - - this.regexes = regexes; - } -} - -export class ChineseOrdinalExtractor extends BaseNumberExtractor { - protected extractType: string = Constants.SYS_NUM_ORDINAL; - - constructor() { - super(); - let regexes = new Array( - { // 第一百五十四 - regExp: RegExpUtility.getSafeRegExp(ChineseNumeric.OrdinalRegex, "gi"), - value: "Ordinal" + ChineseNumeric.LangMarker - }, - { // 第2565, 第1234 - regExp: RegExpUtility.getSafeRegExp(ChineseNumeric.OrdinalNumbersRegex, "gi"), - value: "Ordinal" + ChineseNumeric.LangMarker - } - ); - - this.regexes = regexes; - } -} - -export class ChinesePercentageExtractor extends BaseNumberExtractor { - protected extractType: string = Constants.SYS_NUM_PERCENTAGE; - - constructor() { - super(); - let regexes = new Array( - { // 二十个百分点, 四点五个百分点 - regExp: RegExpUtility.getSafeRegExp(ChineseNumeric.PercentagePointRegex, "gi"), - value: "Per" + ChineseNumeric.LangMarker - }, - { // 百分之五十 百分之一点五 - regExp: RegExpUtility.getSafeRegExp(ChineseNumeric.SimplePercentageRegex, "gi"), - value: "Per" + ChineseNumeric.LangMarker - }, - { // 百分之56.2 百分之12 - regExp: RegExpUtility.getSafeRegExp(ChineseNumeric.NumbersPercentagePointRegex, "gis"), - value: "PerNum" - }, - { // 百分之3,000 百分之1,123 - regExp: RegExpUtility.getSafeRegExp(ChineseNumeric.NumbersPercentageWithSeparatorRegex, "gis"), - value: "PerNum" - }, - { // 百分之3.2 k - regExp: RegExpUtility.getSafeRegExp(ChineseNumeric.NumbersPercentageWithMultiplierRegex, "gi"), - value: "PerNum" - }, - { // 12.56个百分点 0.4个百分点 - regExp: RegExpUtility.getSafeRegExp(ChineseNumeric.FractionPercentagePointRegex, "gis"), - value: "PerNum" - }, - { // 15,123个百分点 111,111个百分点 - regExp: RegExpUtility.getSafeRegExp(ChineseNumeric.FractionPercentageWithSeparatorRegex, "gis"), - value: "PerNum" - }, - { // 12.1k个百分点 15.1k个百分点 - regExp: RegExpUtility.getSafeRegExp(ChineseNumeric.FractionPercentageWithMultiplierRegex, "gi"), - value: "PerNum" - }, - { // 百分之22 百分之120 - regExp: RegExpUtility.getSafeRegExp(ChineseNumeric.SimpleNumbersPercentageRegex, "gis"), - value: "PerNum" - }, - { // 百分之15k - regExp: RegExpUtility.getSafeRegExp(ChineseNumeric.SimpleNumbersPercentageWithMultiplierRegex, "gi"), - value: "PerNum" - }, - { // 百分之1,111 百分之9,999 - regExp: RegExpUtility.getSafeRegExp(ChineseNumeric.SimpleNumbersPercentagePointRegex, "gis"), - value: "PerNum" - }, - { // 12个百分点 - regExp: RegExpUtility.getSafeRegExp(ChineseNumeric.IntegerPercentageRegex, "gis"), - value: "PerNum" - }, - { // 12k个百分点 - regExp: RegExpUtility.getSafeRegExp(ChineseNumeric.IntegerPercentageWithMultiplierRegex, "gi"), - value: "PerNum" - }, - { // 2,123个百分点 - regExp: RegExpUtility.getSafeRegExp(ChineseNumeric.NumbersFractionPercentageRegex, "gis"), - value: "PerNum" - }, - { // 32.5% - regExp: RegExpUtility.getSafeRegExp(ChineseNumeric.SimpleIntegerPercentageRegex, "gis"), - value: "PerNum" - }, - { // 2折 2.5折 - regExp: RegExpUtility.getSafeRegExp(ChineseNumeric.NumbersFoldsPercentageRegex, "gis"), - value: "PerSpe" - }, - { // 三折 六点五折 七五折 - regExp: RegExpUtility.getSafeRegExp(ChineseNumeric.FoldsPercentageRegex, "gis"), - value: "PerSpe" - }, - { // 5成 6成半 6成4 - regExp: RegExpUtility.getSafeRegExp(ChineseNumeric.SimpleFoldsPercentageRegex, "gis"), - value: "PerSpe" - }, - { // 七成半 七成五 - regExp: RegExpUtility.getSafeRegExp(ChineseNumeric.SpecialsPercentageRegex, "gis"), - value: "PerSpe" - }, - { // 2成 2.5成 - regExp: RegExpUtility.getSafeRegExp(ChineseNumeric.NumbersSpecialsPercentageRegex, "gis"), - value: "PerSpe" - }, - { // 三成 六点五成 - regExp: RegExpUtility.getSafeRegExp(ChineseNumeric.SimpleSpecialsPercentageRegex, "gis"), - value: "PerSpe" - }, - { // 打对折 半成 - regExp: RegExpUtility.getSafeRegExp(ChineseNumeric.SpecialsFoldsPercentageRegex, "gis"), - value: "PerSpe" - } - ); - - this.regexes = regexes; - } -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-number/src/number/chinese/parserConfiguration.ts b/JavaScript/packages/recognizers-number/src/number/chinese/parserConfiguration.ts deleted file mode 100644 index 4ec98f936a..0000000000 --- a/JavaScript/packages/recognizers-number/src/number/chinese/parserConfiguration.ts +++ /dev/null @@ -1,104 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { ParseResult } from "@microsoft/recognizers-text"; -import { ICJKNumberParserConfiguration } from "../cjkParsers"; -import { CultureInfo, Culture } from "../../culture"; -import { ChineseNumeric } from "../../resources/chineseNumeric"; -import { RegExpUtility } from "@microsoft/recognizers-text"; - -export class ChineseNumberParserConfiguration implements ICJKNumberParserConfiguration { - - readonly cardinalNumberMap: ReadonlyMap; - readonly ordinalNumberMap: ReadonlyMap; - readonly roundNumberMap: ReadonlyMap; - readonly cultureInfo: CultureInfo; - readonly digitalNumberRegex: RegExp; - readonly fractionMarkerToken: string; - readonly halfADozenRegex: RegExp; - readonly halfADozenText: string; - readonly langMarker: string; - readonly nonDecimalSeparatorChar: string; - readonly decimalSeparatorChar: string; - readonly wordSeparatorToken: string; - readonly zeroChar: string; - readonly pairChar: string; - readonly writtenDecimalSeparatorTexts: readonly string[]; - readonly writtenGroupSeparatorTexts: readonly string[]; - readonly writtenIntegerSeparatorTexts: readonly string[]; - readonly writtenFractionSeparatorTexts: readonly string[]; - - readonly zeroToNineMap: ReadonlyMap; - readonly roundNumberMapChar: ReadonlyMap; - readonly fullToHalfMap: ReadonlyMap; - readonly tratoSimMap: ReadonlyMap; - readonly unitMap: ReadonlyMap; - readonly roundDirectList: readonly string[]; - readonly tenChars: readonly string[]; - readonly digitNumRegex: RegExp; - readonly dozenRegex: RegExp; - readonly percentageRegex: RegExp; - readonly percentageNumRegex: RegExp; - readonly doubleAndRoundRegex: RegExp; - readonly fracSplitRegex: RegExp; - readonly negativeNumberSignRegex: RegExp; - readonly pointRegex: RegExp; - readonly speGetNumberRegex: RegExp; - readonly pairRegex: RegExp; - readonly roundNumberIntegerRegex: RegExp; - - constructor(ci?: CultureInfo) { - if (!ci) { - ci = new CultureInfo(Culture.Chinese); - } - - this.cultureInfo = ci; - - this.langMarker = ChineseNumeric.LangMarker; - this.decimalSeparatorChar = ChineseNumeric.DecimalSeparatorChar; - this.fractionMarkerToken = ChineseNumeric.FractionMarkerToken; - this.nonDecimalSeparatorChar = ChineseNumeric.NonDecimalSeparatorChar; - this.halfADozenText = ChineseNumeric.HalfADozenText; - this.wordSeparatorToken = ChineseNumeric.WordSeparatorToken; - this.zeroChar = ChineseNumeric.ZeroChar; - this.pairChar = ChineseNumeric.PairChar; - - this.writtenDecimalSeparatorTexts = []; - this.writtenGroupSeparatorTexts = []; - this.writtenIntegerSeparatorTexts = []; - this.writtenFractionSeparatorTexts = []; - - this.cardinalNumberMap = new Map(); - this.ordinalNumberMap = new Map(); - this.roundNumberMap = ChineseNumeric.RoundNumberMap; - this.halfADozenRegex = null; - this.digitalNumberRegex = RegExpUtility.getSafeRegExp(ChineseNumeric.DigitalNumberRegex, "gis"); - - this.zeroToNineMap = ChineseNumeric.ZeroToNineMap; - this.roundNumberMapChar = ChineseNumeric.RoundNumberMapChar; - this.fullToHalfMap = ChineseNumeric.FullToHalfMap; - this.tratoSimMap = ChineseNumeric.TratoSimMap; - this.unitMap = ChineseNumeric.UnitMap; - this.roundDirectList = ChineseNumeric.RoundDirectList; - this.tenChars = ChineseNumeric.TenChars; - this.digitNumRegex = RegExpUtility.getSafeRegExp(ChineseNumeric.DigitNumRegex, "gis"); - this.dozenRegex = RegExpUtility.getSafeRegExp(ChineseNumeric.DozenRegex, "gis"); - this.percentageRegex = RegExpUtility.getSafeRegExp(ChineseNumeric.PercentageRegex, "gis"); - this.percentageNumRegex = RegExpUtility.getSafeRegExp(ChineseNumeric.PercentageNumRegex, "gis"); - this.doubleAndRoundRegex = RegExpUtility.getSafeRegExp(ChineseNumeric.DoubleAndRoundRegex, "gis"); - this.fracSplitRegex = RegExpUtility.getSafeRegExp(ChineseNumeric.FracSplitRegex, "gis"); - this.negativeNumberSignRegex = RegExpUtility.getSafeRegExp(ChineseNumeric.NegativeNumberSignRegex, "gis"); - this.pointRegex = RegExpUtility.getSafeRegExp(ChineseNumeric.PointRegex, "gis"); - this.speGetNumberRegex = RegExpUtility.getSafeRegExp(ChineseNumeric.SpeGetNumberRegex, "gis"); - this.pairRegex = RegExpUtility.getSafeRegExp(ChineseNumeric.PairRegex, "gis"); - this.roundNumberIntegerRegex = RegExpUtility.getSafeRegExp(ChineseNumeric.RoundNumberIntegerRegex, "gis"); - } - - normalizeTokenSet(tokens: readonly string[], context: ParseResult): readonly string[] { - return tokens; - } - - resolveCompositeNumber(numberStr: string): number { - return 0; - } -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-number/src/number/cjkParsers.ts b/JavaScript/packages/recognizers-number/src/number/cjkParsers.ts deleted file mode 100644 index 660a10d245..0000000000 --- a/JavaScript/packages/recognizers-number/src/number/cjkParsers.ts +++ /dev/null @@ -1,519 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { ExtractResult, IParser, ParseResult } from "@microsoft/recognizers-text"; -import { BaseNumberParser, INumberParserConfiguration } from "./parsers"; -import { Constants } from "./constants"; -import { LongFormatType } from "./models"; -import { CultureInfo, Culture } from "../culture"; -import { RegExpUtility, StringUtility } from "@microsoft/recognizers-text"; -import { BigNumber } from 'bignumber.js/bignumber'; -import trimEnd = require("lodash.trimend"); -import sortBy = require("lodash.sortby"); - -export interface ICJKNumberParserConfiguration extends INumberParserConfiguration { - readonly zeroToNineMap: ReadonlyMap; - readonly roundNumberMapChar: ReadonlyMap; - readonly fullToHalfMap: ReadonlyMap; - readonly tratoSimMap: ReadonlyMap; - readonly unitMap: ReadonlyMap; - readonly roundDirectList: readonly string[]; - readonly tenChars: readonly string[]; - readonly digitNumRegex: RegExp; - readonly dozenRegex: RegExp; - readonly percentageRegex: RegExp; - readonly percentageNumRegex: RegExp; - readonly doubleAndRoundRegex: RegExp; - readonly fracSplitRegex: RegExp; - readonly pointRegex: RegExp; - readonly speGetNumberRegex: RegExp; - readonly pairRegex: RegExp; - readonly roundNumberIntegerRegex: RegExp; - readonly zeroChar: string; - readonly pairChar: string; -} - -export class BaseCJKNumberParser extends BaseNumberParser { - readonly config: ICJKNumberParserConfiguration; - - constructor(config: ICJKNumberParserConfiguration) { - super(config); - this.config = config; - } - - private toString(value: any): string { - return this.config.cultureInfo - ? this.config.cultureInfo.format(value) - : value.toString(); - } - - private isDigitCode(n: string): boolean { - return n >= '0' && n <= '9'; - } - - parse(extResult: ExtractResult): ParseResult | null { - let extra = ''; - let result: ParseResult; - extra = extResult.data; - let getExtResult: ExtractResult = { - start: extResult.start, - length: extResult.length, - data: extResult.data, - text: this.replaceTraditionalWithSimplified(extResult.text), - type: extResult.type - }; - - if (!extra) { - return result; - } - - if (extra.includes("Per")) { - result = this.perParseCJK(getExtResult); - } - else if (extra.includes("Num")) { - getExtResult.text = this.replaceFullWithHalf(getExtResult.text); - result = this.digitNumberParse(getExtResult); - if(RegExpUtility.isMatch(this.config.negativeNumberSignRegex, getExtResult.text) && result.value > 0){ - result.value = - result.value; - } - result.resolutionStr = this.toString(result.value); - } - else if (extra.includes("Pow")) { - getExtResult.text = this.replaceFullWithHalf(getExtResult.text); - result = this.powerNumberParse(getExtResult); - result.resolutionStr = this.toString(result.value); - } - else if (extra.includes("Frac")) { - result = this.fracParseCJK(getExtResult); - } - else if (extra.includes("Dou")) { - result = this.douParseCJK(getExtResult); - } - else if (extra.includes("Integer")) { - result = this.intParseCJK(getExtResult); - } - else if (extra.includes("Ordinal")) { - result = this.ordParseCJK(getExtResult); - } - - if (result) { - result.text = extResult.text.toLowerCase(); - } - - return result; - } - - private replaceTraditionalWithSimplified(value: string): string { - if (StringUtility.isNullOrWhitespace(value)) { - return value; - } - if (this.config.tratoSimMap == null) { - return value; - } - - let result = ''; - for(let index = 0; index < value.length; index++) { - result = result.concat(this.config.tratoSimMap.get(value.charAt(index)) || value.charAt(index)); - } - return result; - } - - private replaceFullWithHalf(value: string): string { - if (StringUtility.isNullOrWhitespace(value)) { - return value; - } - - let result = ''; - for(let index = 0; index < value.length; index++) { - result = result.concat(this.config.fullToHalfMap.get(value.charAt(index)) || value.charAt(index)); - } - return result; - } - - private replaceUnit(value: string): string { - if (StringUtility.isNullOrEmpty(value)) { -return value; -} - let result = value; - this.config.unitMap.forEach((value: string, key: string) => { - result = result.replace(new RegExp(key, 'g'), value); - }); - return result; - } - - private perParseCJK(extResult: ExtractResult): ParseResult { - let result = new ParseResult(extResult); - - let resultText = extResult.text; - let power = 1; - - if (extResult.data.includes("Spe")) { - resultText = this.replaceFullWithHalf(resultText); - resultText = this.replaceUnit(resultText); - - if (resultText === "半額" || resultText === "半折" || resultText === "半折") { - result.value = 50; - } - else if (resultText === "10成" || resultText === "10割" || resultText === "十割") { - result.value = 100; - } - else { - let matches = RegExpUtility.getMatches(this.config.speGetNumberRegex, resultText); - let intNumber: number; - - if (matches.length === 2) { - let intNumberChar = matches[0].value.charAt(0); - - if (intNumberChar === this.config.pairChar) { - intNumber = 5; - } - else if (this.config.tenChars.some(o => o === intNumberChar)) { - intNumber = 10; - } - else { - intNumber = this.config.zeroToNineMap.get(intNumberChar); - } - - let pointNumberChar = matches[1].value.charAt(0); - let pointNumber: number; - - if (pointNumberChar === "半") { - pointNumber = 0.5; - } - else { - pointNumber = this.config.zeroToNineMap.get(pointNumberChar) * 0.1; - } - - result.value = (intNumber + pointNumber) * 10; - } - else if (matches.length === 5) { - // Deal the Japanese percentage case like "xxx割xxx分xxx厘", get the integer value and convert into result. - let intNumberChar = matches[0].value.charAt(0); - let pointNumberChar = matches[1].value.charAt(0); - let dotNumberChar = matches[3].value.charAt(0); - - let pointNumber = this.config.zeroToNineMap.get(pointNumberChar) * 0.1; - let dotNumber = this.config.zeroToNineMap.get(dotNumberChar) * 0.01; - - intNumber = this.config.zeroToNineMap.get(intNumberChar); - - result.value = (intNumber + pointNumber + dotNumber) * 10; - } - else { - let intNumberChar = matches[0].value.charAt(0); - - if (intNumberChar === this.config.pairChar) { - intNumber = 5; - } - else if (this.config.tenChars.some(o => o === intNumberChar)) { - intNumber = 10; - } - else { - intNumber = this.config.zeroToNineMap.get(intNumberChar); - } - result.value = intNumber * 10; - } - } - } - else if (extResult.data.includes("Num")) { - let doubleMatch = RegExpUtility.getMatches(this.config.percentageRegex, resultText).pop(); - let doubleText = doubleMatch.value; - - if (doubleText.includes("k") || doubleText.includes("K") || doubleText.includes("k") || doubleText.includes("K")) { - power = 1000; - } - - if (doubleText.includes("M") || doubleText.includes("M")) { - power = 1000000; - } - - if (doubleText.includes("G") || doubleText.includes("G")) { - power = 1000000000; - } - - if (doubleText.includes("T") || doubleText.includes("T")) { - power = 1000000000000; - } - - result.value = this.getDigitValueCJK(resultText, power); - } - else { - let doubleMatch = RegExpUtility.getMatches(this.config.percentageRegex, resultText).pop(); - let doubleText = this.replaceUnit(doubleMatch.value); - - let splitResult = RegExpUtility.split(this.config.pointRegex, doubleText); - if (splitResult[0] === "") { - splitResult[0] = this.config.zeroChar; - } - - let doubleValue = this.getIntValueCJK(splitResult[0]); - if (splitResult.length === 2) { - if (RegExpUtility.isMatch(this.config.negativeNumberSignRegex, splitResult[0])) { - doubleValue -= this.getPointValueCJK(splitResult[1]); - } - else { - doubleValue += this.getPointValueCJK(splitResult[1]); - } - } - result.value = doubleValue; - } - let perMatch = RegExpUtility.getMatches(this.config.percentageNumRegex, resultText); - if (perMatch.length > 0) { - let splitResult = perMatch[0].value; - let splitResultList = RegExpUtility.split(this.config.fracSplitRegex, splitResult); - let demoValue = this.isDigitCJK(splitResultList[0]) - ? this.getDigitValueCJK(splitResult[0], 1.0) - : this.getIntValueCJK(splitResult[0]); - result.value /= (demoValue / 100); - } - - - result.resolutionStr = this.toString(result.value) + "%"; - return result; - } - - private fracParseCJK(extResult: ExtractResult): ParseResult { - let result = new ParseResult(extResult); - - let resultText = extResult.text; - let splitResult = RegExpUtility.split(this.config.fracSplitRegex, resultText); - let intPart = ""; - let demoPart = ""; - let numPart = ""; - if (splitResult.length === 3) { - intPart = splitResult[0] || ""; - demoPart = splitResult[1] || ""; - numPart = splitResult[2] || ""; - } - else { - intPart = this.config.zeroChar; - demoPart = splitResult[0] || ""; - numPart = splitResult[1] || ""; - } - - let intValue = this.isDigitCJK(intPart) - ? this.getDigitValueCJK(intPart, 1.0) - : this.getIntValueCJK(intPart); - - let numValue = this.isDigitCJK(numPart) - ? this.getDigitValueCJK(numPart, 1.0) - : this.getIntValueCJK(numPart); - - let demoValue = this.isDigitCJK(demoPart) - ? this.getDigitValueCJK(demoPart, 1.0) - : this.getIntValueCJK(demoPart); - - if (RegExpUtility.isMatch(this.config.negativeNumberSignRegex, intPart)) { - result.value = intValue - numValue / demoValue; - } - else { - result.value = intValue + numValue / demoValue; - } - - result.resolutionStr = this.toString(result.value); - return result; - } - - private douParseCJK(extResult: ExtractResult): ParseResult { - let result = new ParseResult(extResult); - - let resultText = extResult.text; - - if (RegExpUtility.isMatch(this.config.doubleAndRoundRegex, resultText)) { - resultText = this.replaceUnit(resultText); - let power = this.config.roundNumberMapChar.get(resultText.charAt(resultText.length - 1)); - result.value = this.getDigitValueCJK(resultText.substr(0, resultText.length - 1), power); - } - else { - resultText = this.replaceUnit(resultText); - let splitResult = RegExpUtility.split(this.config.pointRegex, resultText); - - if (splitResult[0] === "") { - splitResult[0] = this.config.zeroChar; - } - - if (RegExpUtility.isMatch(this.config.negativeNumberSignRegex, splitResult[0])) { - result.value = this.getIntValueCJK(splitResult[0]) - this.getPointValueCJK(splitResult[1]); - } - else { - result.value = this.getIntValueCJK(splitResult[0]) + this.getPointValueCJK(splitResult[1]); - } - } - - result.resolutionStr = this.toString(result.value); - return result; - } - - private intParseCJK(extResult: ExtractResult): ParseResult { - let result = new ParseResult(extResult); - - result.value = this.getIntValueCJK(extResult.text); - result.resolutionStr = this.toString(result.value); - return result; - } - - private ordParseCJK(extResult: ExtractResult): ParseResult { - let result = new ParseResult(extResult); - - let resultText = extResult.text.substr(1); - - if (RegExpUtility.isMatch(this.config.digitNumRegex, resultText) && !RegExpUtility.isMatch(this.config.roundNumberIntegerRegex, resultText)) { - result.value = this.getDigitValueCJK(resultText, 1); - } - else { - result.value = this.getIntValueCJK(resultText); - } - - result.resolutionStr = this.toString(result.value); - return result; - } - - private getDigitValueCJK(value: string, power: number): number { - let isNegative = false; - let resultStr = value; - if (RegExpUtility.isMatch(this.config.negativeNumberSignRegex, resultStr)) { - isNegative = true; - resultStr = resultStr.substr(1); - } - - resultStr = this.replaceFullWithHalf(resultStr); - let result = this.getDigitalValue(resultStr, power); - if (isNegative) { - result = - result; - } - - return result; - } - - private getIntValueCJK(value: string): number { - let resultStr = value; - - let isDozen = false; - let isPair = false; - if (RegExpUtility.isMatch(this.config.dozenRegex, resultStr)) { - isDozen = true; - if (this.config.cultureInfo.code.toLowerCase() === Culture.Chinese) { - resultStr = resultStr.substr(0, resultStr.length - 1); - } - else if (this.config.cultureInfo.code.toLowerCase() === Culture.Japanese) { - resultStr = resultStr.substr(0, resultStr.length - 3); - } - } - else if (RegExpUtility.isMatch(this.config.pairRegex, resultStr)) { - isPair = true; - resultStr = resultStr.substr(0, resultStr.length - 1); - } - - resultStr = this.replaceUnit(resultStr); - let intValue = 0; - let partValue = 0; - let beforeValue = 1; - let isRoundBefore = false; - let roundBefore = -1; - let roundDefault = 1; - let isNegative = false; - let hasPreviousDigits = false; - - if (RegExpUtility.isMatch(this.config.negativeNumberSignRegex, resultStr)) { - isNegative = true; - resultStr = resultStr.substr(1); - } - - for(let index = 0; index < resultStr.length; index++) { - let currentChar = resultStr.charAt(index); - if (this.config.roundNumberMapChar.has(currentChar)) { - let roundRecent = this.config.roundNumberMapChar.get(currentChar); - if (roundBefore !== -1 && roundRecent > roundBefore) { - if (isRoundBefore) { - intValue += partValue * roundRecent; - isRoundBefore = false; - } - else { - partValue += beforeValue * roundDefault; - intValue += partValue * roundRecent; - } - - roundBefore = -1; - partValue = 0; - } - else { - isRoundBefore = true; - partValue += beforeValue * roundRecent; - roundBefore = roundRecent; - - if ((index === resultStr.length - 1) || this.config.roundDirectList.some(o => o === currentChar)) { - intValue += partValue; - partValue = 0; - } - } - - roundDefault = roundRecent / 10; - } - else if (this.config.zeroToNineMap.has(currentChar)) { - if (index !== resultStr.length - 1) { - let is_not_round_next = this.config.tenChars.some(o => o === resultStr.charAt(index + 1)) || !this.config.roundNumberMapChar.has(resultStr.charAt(index + 1)); - if (currentChar === this.config.zeroChar && is_not_round_next) { - beforeValue = 1; - roundDefault = 1; - } - else { - let currentDigit = this.config.zeroToNineMap.get(currentChar); - if (hasPreviousDigits) { - beforeValue = beforeValue * 10 + currentDigit; - } else { - beforeValue = currentDigit; - } - isRoundBefore = false; - } - } - else { - // In colloquial Chinese, 百 may be omitted from the end of a number, similarly to how 一 - // can be dropped from the beginning. Japanese doesn't have such behaviour. - if (this.config.cultureInfo.code.toLowerCase() === Culture.Japanese || this.isDigit(currentChar)) { - roundDefault = 1; - } - let currentDigit = this.config.zeroToNineMap.get(currentChar); - if (hasPreviousDigits) { - beforeValue = beforeValue * 10 + currentDigit; - } else { - beforeValue = currentDigit; - } - partValue += beforeValue * roundDefault; - intValue += partValue; - partValue = 0; - } - } - hasPreviousDigits = this.isDigit(currentChar); - } - - if (isNegative) { - intValue = - intValue; - } - - if (isDozen) { - intValue = intValue * 12; - } - - if (isPair) { - intValue = intValue * 2; - } - - return intValue; - } - - private getPointValueCJK(value: string): number { - let result = 0; - let scale = 0.1; - for(let index = 0; index < value.length; index++) { - result += scale * this.config.zeroToNineMap.get(value.charAt(index)); - scale *= 0.1; - } - - return result; - } - - private isDigitCJK(value: string): boolean { - return !StringUtility.isNullOrEmpty(value) - && RegExpUtility.isMatch(this.config.digitNumRegex, value); - } -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-number/src/number/constants.ts b/JavaScript/packages/recognizers-number/src/number/constants.ts deleted file mode 100644 index 93777919ce..0000000000 --- a/JavaScript/packages/recognizers-number/src/number/constants.ts +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -export class Constants { - static readonly SYS_NUM_CARDINAL: string = "builtin.num.cardinal"; - static readonly SYS_NUM_DOUBLE: string = "builtin.num.double"; - static readonly SYS_NUM_FRACTION: string = "builtin.num.fraction"; - static readonly SYS_NUM_INTEGER: string = "builtin.num.integer"; - static readonly SYS_NUM: string = "builtin.num"; - static readonly SYS_NUM_ORDINAL: string = "builtin.num.ordinal"; - static readonly SYS_NUM_PERCENTAGE: string = "builtin.num.percentage"; - - // NARROW NO-BREAK SPACE - static readonly NO_BREAK_SPACE = '\u202f'; -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-number/src/number/english/extractors.ts b/JavaScript/packages/recognizers-number/src/number/english/extractors.ts deleted file mode 100644 index 9a638d9ee5..0000000000 --- a/JavaScript/packages/recognizers-number/src/number/english/extractors.ts +++ /dev/null @@ -1,257 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { BaseNumberExtractor, RegExpValue, RegExpRegExp, BasePercentageExtractor } from "../extractors"; -import { Constants } from "../constants"; -import { NumberMode, LongFormatType } from "../models"; -import { EnglishNumeric } from "../../resources/englishNumeric"; -import { BaseNumbers } from "../../resources/baseNumbers"; -import { RegExpUtility } from "@microsoft/recognizers-text"; - -export class EnglishNumberExtractor extends BaseNumberExtractor { - protected extractType: string = Constants.SYS_NUM; - protected negativeNumberTermsRegex: RegExp; - - constructor(mode: NumberMode = NumberMode.Default) { - super(); - - this.negativeNumberTermsRegex = RegExpUtility.getSafeRegExp(EnglishNumeric.NegativeNumberTermsRegex + "$", "is"); - - let regexes = new Array(); - - // Add Cardinal - let cardExtract: EnglishCardinalExtractor | null = null; - switch (mode) { - case NumberMode.PureNumber: - cardExtract = new EnglishCardinalExtractor(EnglishNumeric.PlaceHolderPureNumber); - break; - case NumberMode.Currency: - regexes.push({ regExp: RegExpUtility.getSafeRegExp(BaseNumbers.CurrencyRegex, "gs"), value: "IntegerNum" }); - break; - case NumberMode.Default: - break; - } - - if (cardExtract === null) { - cardExtract = new EnglishCardinalExtractor(); - } - - cardExtract.regexes.forEach(r => regexes.push(r)); - - // Add Fraction - let fracExtract = new EnglishFractionExtractor(mode); - fracExtract.regexes.forEach(r => regexes.push(r)); - - this.regexes = regexes; - - // Add filter - let ambiguityFiltersDict = new Array(); - - if (mode != NumberMode.Unit) { - for (let [ key, value ] of EnglishNumeric.AmbiguityFiltersDict){ - ambiguityFiltersDict.push({ regExpKey: RegExpUtility.getSafeRegExp(key, "gs"), regExpValue: RegExpUtility.getSafeRegExp(value, "gs")}) - } - - } - - this.ambiguityFiltersDict = ambiguityFiltersDict; - } -} - -export class EnglishCardinalExtractor extends BaseNumberExtractor { - protected extractType: string = Constants.SYS_NUM_CARDINAL; - - constructor(placeholder: string = EnglishNumeric.PlaceHolderDefault) { - super(); - let regexes = new Array(); - - // Add Integer Regexes - let intExtract = new EnglishIntegerExtractor(placeholder); - intExtract.regexes.forEach(r => regexes.push(r)); - - // Add Double Regexes - let doubleExtract = new EnglishDoubleExtractor(placeholder); - doubleExtract.regexes.forEach(r => regexes.push(r)); - - this.regexes = regexes; - } -} - -export class EnglishIntegerExtractor extends BaseNumberExtractor { - protected extractType: string = Constants.SYS_NUM_INTEGER; - - constructor(placeholder: string = EnglishNumeric.PlaceHolderDefault) { - super(); - - let regexes = new Array( - { - regExp: RegExpUtility.getSafeRegExp(EnglishNumeric.NumbersWithPlaceHolder(placeholder), "gi"), - value: "IntegerNum" - }, - { - regExp: RegExpUtility.getSafeRegExp(EnglishNumeric.NumbersWithSuffix, "gs"), - value: "IntegerNum" - }, - { - regExp: this.generateLongFormatNumberRegexes(LongFormatType.integerNumComma, placeholder), - value: "IntegerNum" - }, - { - regExp: this.generateLongFormatNumberRegexes(LongFormatType.integerNumBlank, placeholder), - value: "IntegerNum" - }, - { - regExp: this.generateLongFormatNumberRegexes(LongFormatType.integerNumNoBreakSpace, placeholder), - value: "IntegerNum" - }, - { - regExp: RegExpUtility.getSafeRegExp(EnglishNumeric.RoundNumberIntegerRegexWithLocks, "gis"), - value: "IntegerNum" - }, - { - regExp: RegExpUtility.getSafeRegExp(EnglishNumeric.NumbersWithDozenSuffix, "gis"), - value: "IntegerNum" - }, - { - regExp: RegExpUtility.getSafeRegExp(EnglishNumeric.AllIntRegexWithLocks, "gis"), - value: "IntegerEng" - }, - { - regExp: RegExpUtility.getSafeRegExp(EnglishNumeric.AllIntRegexWithDozenSuffixLocks, "gis"), - value: "IntegerEng" - } - ); - - this.regexes = regexes; - } -} - -export class EnglishDoubleExtractor extends BaseNumberExtractor { - protected extractType: string = Constants.SYS_NUM_DOUBLE; - - constructor(placeholder: string = EnglishNumeric.PlaceHolderDefault) { - super(); - - let regexes = new Array( - { - regExp: RegExpUtility.getSafeRegExp(EnglishNumeric.DoubleDecimalPointRegex(placeholder), "gis"), - value: "DoubleNum" - }, - { - regExp: RegExpUtility.getSafeRegExp(EnglishNumeric.DoubleWithoutIntegralRegex(placeholder), "gis"), - value: "DoubleNum" - }, - { - regExp: this.generateLongFormatNumberRegexes(LongFormatType.doubleNumCommaDot, placeholder), - value: "DoubleNum" - }, - { - regExp: this.generateLongFormatNumberRegexes(LongFormatType.doubleNumNoBreakSpaceDot, placeholder), - value: "DoubleNum" - }, - { - regExp: RegExpUtility.getSafeRegExp(EnglishNumeric.DoubleWithMultiplierRegex, "gs"), - value: "DoubleNum" - }, - { - regExp: RegExpUtility.getSafeRegExp(EnglishNumeric.DoubleWithRoundNumber, "gis"), - value: "DoubleNum" - }, - { - regExp: RegExpUtility.getSafeRegExp(EnglishNumeric.DoubleAllFloatRegex, "gis"), - value: "DoubleEng" - }, - { - regExp: RegExpUtility.getSafeRegExp(EnglishNumeric.DoubleExponentialNotationRegex, "gis"), - value: "DoublePow" - }, - { - regExp: RegExpUtility.getSafeRegExp(EnglishNumeric.DoubleCaretExponentialNotationRegex, "gis"), - value: "DoublePow" - } - ); - - this.regexes = regexes; - } -} - -export class EnglishFractionExtractor extends BaseNumberExtractor { - - protected extractType: string = Constants.SYS_NUM_FRACTION; - - constructor(mode: NumberMode = NumberMode.Default) { - super(); - - let regexes = new Array( - { - regExp: RegExpUtility.getSafeRegExp(EnglishNumeric.FractionNotationWithSpacesRegex, "gis"), - value: "FracNum" - }, - { - regExp: RegExpUtility.getSafeRegExp(EnglishNumeric.FractionNotationRegex, "gis"), - value: "FracNum" - }, - { - regExp: RegExpUtility.getSafeRegExp(EnglishNumeric.FractionNounRegex, "gis"), - value: "FracEng" - }, - { - regExp: RegExpUtility.getSafeRegExp(EnglishNumeric.FractionNounWithArticleRegex, "gis"), - value: "FracEng" - } - ); - - // Not add FractionPrepositionRegex when the mode is Unit to avoid wrong recognize cases like "$1000 over 3" - if (mode != NumberMode.Unit) { - regexes.push({ - regExp: RegExpUtility.getSafeRegExp(EnglishNumeric.FractionPrepositionRegex, "gis"), - value: "FracEng" - }); - }; - - this.regexes = regexes; - } -} - -export class EnglishOrdinalExtractor extends BaseNumberExtractor { - protected extractType: string = Constants.SYS_NUM_ORDINAL; - - constructor() { - super(); - let regexes = new Array( - { - regExp: RegExpUtility.getSafeRegExp(EnglishNumeric.OrdinalSuffixRegex, "gis"), - value: "OrdinalNum" - }, - { - regExp: RegExpUtility.getSafeRegExp(EnglishNumeric.OrdinalNumericRegex, "gis"), - value: "OrdinalNum" - }, - { - regExp: RegExpUtility.getSafeRegExp(EnglishNumeric.OrdinalEnglishRegex, "gis"), - value: "OrdEng" - }, - { - regExp: RegExpUtility.getSafeRegExp(EnglishNumeric.OrdinalRoundNumberRegex, "gis"), - value: "OrdEng" - } - ); - - this.regexes = regexes; - } -} - -export class EnglishPercentageExtractor extends BasePercentageExtractor { - constructor() { - super(new EnglishNumberExtractor()); - } - - protected initRegexes(): RegExp[] { - let regexStrs = [ - EnglishNumeric.NumberWithSuffixPercentage, - EnglishNumeric.NumberWithPrefixPercentage - ]; - - return this.buildRegexes(regexStrs); - } -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-number/src/number/english/parserConfiguration.ts b/JavaScript/packages/recognizers-number/src/number/english/parserConfiguration.ts deleted file mode 100644 index 57ec7e9afd..0000000000 --- a/JavaScript/packages/recognizers-number/src/number/english/parserConfiguration.ts +++ /dev/null @@ -1,116 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { ParseResult } from "@microsoft/recognizers-text"; -import { INumberParserConfiguration } from "../parsers"; -import { CultureInfo, Culture } from "../../culture"; -import { EnglishNumeric } from "../../resources/englishNumeric"; -import { RegExpUtility } from "@microsoft/recognizers-text"; - -export class EnglishNumberParserConfiguration implements INumberParserConfiguration { - - readonly cardinalNumberMap: ReadonlyMap; - readonly ordinalNumberMap: ReadonlyMap; - readonly roundNumberMap: ReadonlyMap; - readonly cultureInfo: CultureInfo; - readonly digitalNumberRegex: RegExp; - readonly fractionMarkerToken: string; - readonly negativeNumberSignRegex: RegExp; - readonly halfADozenRegex: RegExp; - readonly halfADozenText: string; - readonly langMarker: string; - readonly nonDecimalSeparatorChar: string; - readonly decimalSeparatorChar: string; - readonly wordSeparatorToken: string; - readonly writtenDecimalSeparatorTexts: readonly string[]; - readonly writtenGroupSeparatorTexts: readonly string[]; - readonly writtenIntegerSeparatorTexts: readonly string[]; - readonly writtenFractionSeparatorTexts: readonly string[]; - - constructor(ci?: CultureInfo) { - if (!ci) { - ci = new CultureInfo(Culture.English); - } - - this.cultureInfo = ci; - - this.langMarker = EnglishNumeric.LangMarker; - this.decimalSeparatorChar = EnglishNumeric.DecimalSeparatorChar; - this.fractionMarkerToken = EnglishNumeric.FractionMarkerToken; - this.nonDecimalSeparatorChar = EnglishNumeric.NonDecimalSeparatorChar; - this.halfADozenText = EnglishNumeric.HalfADozenText; - this.wordSeparatorToken = EnglishNumeric.WordSeparatorToken; - - this.writtenDecimalSeparatorTexts = EnglishNumeric.WrittenDecimalSeparatorTexts; - this.writtenGroupSeparatorTexts = EnglishNumeric.WrittenGroupSeparatorTexts; - this.writtenIntegerSeparatorTexts = EnglishNumeric.WrittenIntegerSeparatorTexts; - this.writtenFractionSeparatorTexts = EnglishNumeric.WrittenFractionSeparatorTexts; - - this.cardinalNumberMap = EnglishNumeric.CardinalNumberMap; - this.ordinalNumberMap = EnglishNumeric.OrdinalNumberMap; - this.roundNumberMap = EnglishNumeric.RoundNumberMap; - this.negativeNumberSignRegex = RegExpUtility.getSafeRegExp(EnglishNumeric.NegativeNumberSignRegex, "is"); - this.halfADozenRegex = RegExpUtility.getSafeRegExp(EnglishNumeric.HalfADozenRegex, "gis"); - this.digitalNumberRegex = RegExpUtility.getSafeRegExp(EnglishNumeric.DigitalNumberRegex, "gis"); - } - - normalizeTokenSet(tokens: readonly string[], context: ParseResult): readonly string[] { - let fracWords = new Array(); - let tokenList = Array.from(tokens); - let tokenLen = tokenList.length; - for (let i = 0; i < tokenLen; i++) { - if (tokenList[i].includes("-")) { - let spiltedTokens = tokenList[i].split("-"); - if (spiltedTokens.length === 2 && this.ordinalNumberMap.has(spiltedTokens[1])) { - fracWords.push(spiltedTokens[0]); - fracWords.push(spiltedTokens[1]); - } - else { - fracWords.push(tokenList[i]); - } - } - else if ((i < tokenLen - 2) && tokenList[i + 1] === "-") { - if (this.ordinalNumberMap.has(tokenList[i + 2])) { - fracWords.push(tokenList[i]); - fracWords.push(tokenList[i + 2]); - } - else { - fracWords.push(tokenList[i] + tokenList[i + 1] + tokenList[i + 2]); - } - - i += 2; - } - else { - fracWords.push(tokenList[i]); - } - } - return fracWords; - } - - resolveCompositeNumber(numberStr: string): number { - if (numberStr.includes("-")) { - let numbers = numberStr.split('-'); - let ret = 0; - numbers.forEach(num => { - if (this.ordinalNumberMap.has(num)) { - ret += this.ordinalNumberMap.get(num) as number; - } - else if (this.cardinalNumberMap.has(num)) { - ret += this.cardinalNumberMap.get(num) as number; - } - }); - - return ret; - } - - if (this.ordinalNumberMap.has(numberStr)) { - return this.ordinalNumberMap.get(numberStr) as number; - } - - if (this.cardinalNumberMap.has(numberStr)) { - return this.cardinalNumberMap.get(numberStr) as number; - } - - return 0; - } -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-number/src/number/extractors.ts b/JavaScript/packages/recognizers-number/src/number/extractors.ts deleted file mode 100644 index 79dd21344d..0000000000 --- a/JavaScript/packages/recognizers-number/src/number/extractors.ts +++ /dev/null @@ -1,312 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { IExtractor, ExtractResult } from "@microsoft/recognizers-text"; -import { Constants } from "./constants"; -import { BaseNumbers } from "../resources/baseNumbers"; -import { EnglishNumeric } from "../resources/englishNumeric"; -import { Match, RegExpUtility } from "@microsoft/recognizers-text"; -import { LongFormatType } from "./models"; -import escapeRegExp = require("lodash.escaperegexp"); - -export interface RegExpValue { - regExp: RegExp; - value: string; -} - -export interface RegExpRegExp { - regExpKey: RegExp; - regExpValue: RegExp; -} - -export abstract class BaseNumberExtractor implements IExtractor { - - regexes: RegExpValue[]; - - ambiguityFiltersDict: RegExpRegExp[]; - - protected extractType: string = ""; - - protected negativeNumberTermsRegex: RegExp = null; - - extract(source: string): ExtractResult[] { - if (!source || source.trim().length === 0) { - return []; - } - - let result = new Array(); - let matchSource = new Map(); - let matched = new Array(source.length); - for (let i = 0; i < source.length; i++) { - matched[i] = false; - } - - let collections = this.regexes - .map(o => ({ matches: RegExpUtility.getMatches(o.regExp, source), value: o.value })) - .filter(o => o.matches && o.matches.length); - - collections.forEach(collection => { - collection.matches.forEach(m => { - for (let j = 0; j < m.length; j++) { - matched[m.index + j] = true; - } - - // Keep Source Data for extra information - matchSource.set(m, collection.value); - }); - }); - - let last = -1; - for (let i = 0; i < source.length; i++) { - if (matched[i]) { - if (i + 1 === source.length || !matched[i + 1]) { - let start = last + 1; - let length = i - last; - let substr = source.substring(start, start + length); - let srcMatch = Array.from(matchSource.keys()).find(m => m.index === start && m.length === length); - - // Extract negative numbers - if (this.negativeNumberTermsRegex !== null) { - let match = source.substr(0, start).match(this.negativeNumberTermsRegex); - if (match) { - start = match.index; - length = length + match[0].length; - substr = match[0] + substr; - } - } - - if (srcMatch) { - result.push({ - start: start, - length: length, - text: substr, - type: this.extractType, - data: matchSource.has(srcMatch) ? matchSource.get(srcMatch) : null - } as ExtractResult); - } - } - } - else { - last = i; - } - } - - result = this.filterAmbiguity(result, source); - return result; - } - - private filterAmbiguity(extractResults: ExtractResult[], text: string) { - if (this.ambiguityFiltersDict !== null && this.ambiguityFiltersDict !== undefined){ - for (let regex of this.ambiguityFiltersDict){ - for (let extractResult of extractResults){ - if (RegExpUtility.isMatch(regex.regExpKey, extractResult.text)){ - let matches = RegExpUtility.getMatches(regex.regExpValue, text); - if (matches && matches.length){ - extractResults = extractResults.filter(er => matches.find(m => m.index < er.start + er.length && m.index + m.length > er.start) === undefined); - } - } - } - } - } - - return extractResults; - } - - protected generateLongFormatNumberRegexes(type: LongFormatType, placeholder: string = BaseNumbers.PlaceHolderDefault): RegExp { - - let thousandsMark = escapeRegExp(type.thousandsMark); - let decimalsMark = escapeRegExp(type.decimalsMark); - - let regexDefinition = type.decimalsMark === '\0' - ? BaseNumbers.IntegerRegexDefinition(placeholder, thousandsMark) - : BaseNumbers.DoubleRegexDefinition(placeholder, thousandsMark, decimalsMark); - - return RegExpUtility.getSafeRegExp(regexDefinition, "gis"); - } -} - -export abstract class BasePercentageExtractor implements IExtractor { - regexes: RegExp[]; - - protected static readonly numExtType: string = Constants.SYS_NUM; - - protected extractType: string = Constants.SYS_NUM_PERCENTAGE; - - private readonly numberExtractor: BaseNumberExtractor; - - constructor(numberExtractor: BaseNumberExtractor) { - this.numberExtractor = numberExtractor; - this.regexes = this.initRegexes(); - } - - protected abstract initRegexes(): RegExp[]; - - extract(source: string): ExtractResult[] { - let originSource = source; - let positionMap: Map; - let numExtResults: ExtractResult[]; - - // preprocess the source sentence via extracting and replacing the numbers in it - let preprocess = this.preprocessStrWithNumberExtracted(originSource); - source = preprocess.source; - positionMap = preprocess.positionMap; - numExtResults = preprocess.numExtResults; - - let allMatches = this.regexes.map(rx => RegExpUtility.getMatches(rx, source)); - - let matched = new Array(source.length); - for (let i = 0; i < source.length; i++) { - matched[i] = false; - } - - for (let i = 0; i < allMatches.length; i++) { - allMatches[i].forEach(match => { - for (let j = 0; j < match.length; j++) { - matched[j + match.index] = true; - } - }); - } - - let result = new Array(); - let last = -1; - // get index of each matched results - for (let i = 0; i < source.length; i++) { - if (matched[i]) { - if (i + 1 === source.length || matched[i + 1] === false) { - let start = last + 1; - let length = i - last; - let substr = source.substring(start, start + length); - let er: ExtractResult = { - start: start, - length: length, - text: substr, - type: this.extractType - } as ExtractResult; - result.push(er); - } - } - else { - last = i; - } - } - - // post-processing, restoring the extracted numbers - this.postProcessing(result, originSource, positionMap, numExtResults); - - return result; - } - - // get the number extractor results and convert the extracted numbers to @sys.num, so that the regexes can work - private preprocessStrWithNumberExtracted(str: string): { - source: string, - positionMap: Map, - numExtResults: ExtractResult[] - } { - let positionMap = new Map(); - - let numExtResults = this.numberExtractor.extract(str); - let replaceText = BaseNumbers.NumberReplaceToken; - - let match = new Array(str.length); - let strParts = new Array(); - let start: number; - let end: number; - for (let i = 0; i < str.length; i++) { - match[i] = -1; - } - - for (let i = 0; i < numExtResults.length; i++) { - let extraction = numExtResults[i]; - let subtext = extraction.text; - start = extraction.start; - end = extraction.length + start; - for (let j = start; j < end; j++) { - if (match[j] === -1) { - match[j] = i; - } - } - } - - start = 0; - for (let i = 1; i < str.length; i++) { - if (match[i] !== match[i - 1]) { - strParts.push([start, i - 1]); - start = i; - } - } - strParts.push([start, str.length - 1]); - - let ret = ""; - let index = 0; - strParts.forEach(strPart => { - start = strPart[0]; - end = strPart[1]; - let type = match[start]; - if (type === -1) { - ret += str.substring(start, end + 1); - for (let i = start; i <= end; i++) { - positionMap.set(index++, i); - } - } - else { - let originalText = str.substring(start, end + 1); - ret += replaceText; - for (let i = 0; i < replaceText.length; i++) { - positionMap.set(index++, start); - } - } - }); - - - positionMap.set(index++, str.length); - - return { - numExtResults: numExtResults, - source: ret, - positionMap: positionMap - }; - } - - // replace the @sys.num to the real patterns, directly modifies the ExtractResult - private postProcessing(results: ExtractResult[], originSource: string, positionMap: Map, numExtResults: ExtractResult[]): void { - let replaceText = BaseNumbers.NumberReplaceToken; - for (let i = 0; i < results.length; i++) { - let start = results[i].start; - let end = start + results[i].length; - let str = results[i].text; - if (positionMap.has(start) && positionMap.has(end)) { - let originStart = positionMap.get(start); - let originLenth = positionMap.get(end) - originStart; - results[i].start = originStart; - results[i].length = originLenth; - results[i].text = originSource.substring(originStart, originStart + originLenth).trim(); - let numStart = str.indexOf(replaceText); - if (numStart !== -1) { - let numOriginStart = start + numStart; - if (positionMap.has(numStart)) { - let dataKey = originSource.substring(positionMap.get(numOriginStart), positionMap.get(numOriginStart + replaceText.length)); - - for (let j = i; j < numExtResults.length; j++) { - if (results[i].start === numExtResults[j].start && results[i].text.includes(numExtResults[j].text)) { - results[i].data = [dataKey, numExtResults[j]]; - break; - } - } - } - } - } - } - } - - // read the rules - protected buildRegexes(regexStrs: string[], ignoreCase: boolean = true): RegExp[] { - return regexStrs.map(regexStr => { - let options = "gs"; - if (ignoreCase) { - options += "i"; - } - - return RegExpUtility.getSafeRegExp(regexStr, options); - }); - } -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-number/src/number/french/extractors.ts b/JavaScript/packages/recognizers-number/src/number/french/extractors.ts deleted file mode 100644 index b1632d6b34..0000000000 --- a/JavaScript/packages/recognizers-number/src/number/french/extractors.ts +++ /dev/null @@ -1,245 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { BaseNumberExtractor, RegExpValue, RegExpRegExp, BasePercentageExtractor } from "../extractors"; -import { Constants } from "../constants"; -import { NumberMode, LongFormatType } from "../models"; -import { FrenchNumeric } from "../../resources/frenchNumeric"; -import { BaseNumbers } from "../../resources/baseNumbers"; -import { RegExpUtility } from "@microsoft/recognizers-text"; - -export class FrenchNumberExtractor extends BaseNumberExtractor { - protected extractType: string = Constants.SYS_NUM; - - constructor(mode: NumberMode = NumberMode.Default) { - super(); - let regexes = new Array(); - - // Add Cardinal - let cardExtract: FrenchCardinalExtractor | null = null; - switch (mode) { - case NumberMode.PureNumber: - cardExtract = new FrenchCardinalExtractor(FrenchNumeric.PlaceHolderPureNumber); - break; - case NumberMode.Currency: - regexes.push({ regExp: RegExpUtility.getSafeRegExp(BaseNumbers.CurrencyRegex, "gs"), value: "IntegerNum" }); - break; - case NumberMode.Default: - break; - } - - if (cardExtract === null) { - cardExtract = new FrenchCardinalExtractor(); - } - - cardExtract.regexes.forEach(r => regexes.push(r)); - - // Add Fraction - let fracExtract = new FrenchFractionExtractor(mode); - fracExtract.regexes.forEach(r => regexes.push(r)); - - this.regexes = regexes; - - // Add filter - let ambiguityFiltersDict = new Array(); - - if (mode != NumberMode.Unit) { - for (let [ key, value ] of FrenchNumeric.AmbiguityFiltersDict){ - ambiguityFiltersDict.push({ regExpKey: RegExpUtility.getSafeRegExp(key, "gs"), regExpValue: RegExpUtility.getSafeRegExp(value, "gs")}) - } - - } - - this.ambiguityFiltersDict = ambiguityFiltersDict; - } -} - -export class FrenchCardinalExtractor extends BaseNumberExtractor { - protected extractType: string = Constants.SYS_NUM_CARDINAL; - - constructor(placeholder: string = FrenchNumeric.PlaceHolderDefault) { - super(); - let regexes = new Array(); - - // Add Integer Regexes - let intExtract = new FrenchIntegerExtractor(placeholder); - intExtract.regexes.forEach(r => regexes.push(r)); - - // Add Double Regexes - let doubleExtract = new FrenchDoubleExtractor(placeholder); - doubleExtract.regexes.forEach(r => regexes.push(r)); - - this.regexes = regexes; - } -} - -export class FrenchIntegerExtractor extends BaseNumberExtractor { - protected extractType: string = Constants.SYS_NUM_INTEGER; - - constructor(placeholder: string = FrenchNumeric.PlaceHolderDefault) { - super(); - - let regexes = new Array( - { - regExp: RegExpUtility.getSafeRegExp(FrenchNumeric.NumbersWithPlaceHolder(placeholder), "gi"), - value: "IntegerNum" - }, - { - regExp: RegExpUtility.getSafeRegExp(FrenchNumeric.NumbersWithSuffix, "gs"), - value: "IntegerNum" - }, - { - regExp: this.generateLongFormatNumberRegexes(LongFormatType.integerNumDot, placeholder), - value: "IntegerNum" - }, - { - regExp: this.generateLongFormatNumberRegexes(LongFormatType.integerNumBlank, placeholder), - value: "IntegerNum" - }, - { - regExp: this.generateLongFormatNumberRegexes(LongFormatType.integerNumNoBreakSpace, placeholder), - value: "IntegerNum" - }, - { - regExp: RegExpUtility.getSafeRegExp(FrenchNumeric.RoundNumberIntegerRegexWithLocks), - value: "IntegerNum" - }, - { - regExp: RegExpUtility.getSafeRegExp(FrenchNumeric.NumbersWithDozenSuffix), - value: "IntegerNum" - }, - { - regExp: RegExpUtility.getSafeRegExp(FrenchNumeric.AllIntRegexWithLocks), - value: "Integer" + FrenchNumeric.LangMarker - }, - { - regExp: RegExpUtility.getSafeRegExp(FrenchNumeric.AllIntRegexWithDozenSuffixLocks), - value: "Integer" + FrenchNumeric.LangMarker - } - ); - - this.regexes = regexes; - } -} - -export class FrenchDoubleExtractor extends BaseNumberExtractor { - protected extractType: string = Constants.SYS_NUM_DOUBLE; - - constructor(placeholder: string = FrenchNumeric.PlaceHolderDefault) { - super(); - - let regexes = new Array( - { - regExp: RegExpUtility.getSafeRegExp(FrenchNumeric.DoubleDecimalPointRegex(placeholder)), - value: "DoubleNum" - }, - { - regExp: RegExpUtility.getSafeRegExp(FrenchNumeric.DoubleWithoutIntegralRegex(placeholder)), - value: "DoubleNum" - }, - { - regExp: RegExpUtility.getSafeRegExp(FrenchNumeric.DoubleWithMultiplierRegex, "gs"), - value: "DoubleNum" - }, - { - regExp: RegExpUtility.getSafeRegExp(FrenchNumeric.DoubleWithRoundNumber), - value: "DoubleNum" - }, - { - regExp: RegExpUtility.getSafeRegExp(FrenchNumeric.DoubleAllFloatRegex), - value: "Double" + FrenchNumeric.LangMarker - }, - { - regExp: RegExpUtility.getSafeRegExp(FrenchNumeric.DoubleExponentialNotationRegex), - value: "DoublePow" - }, - { - regExp: RegExpUtility.getSafeRegExp(FrenchNumeric.DoubleCaretExponentialNotationRegex), - value: "DoublePow" - }, - { - regExp: this.generateLongFormatNumberRegexes(LongFormatType.doubleNumDotComma, placeholder), - value: "DoubleNum" - }, - { - regExp: this.generateLongFormatNumberRegexes(LongFormatType.doubleNumNoBreakSpaceComma, placeholder), - value: "DoubleNum" - } - ); - - this.regexes = regexes; - } -} - -export class FrenchFractionExtractor extends BaseNumberExtractor { - - protected extractType: string = Constants.SYS_NUM_FRACTION; - - constructor(mode: NumberMode = NumberMode.Default) { - super(); - - let regexes = new Array( - { - regExp: RegExpUtility.getSafeRegExp(FrenchNumeric.FractionNotationRegex), - value: "FracNum" - }, - { - regExp: RegExpUtility.getSafeRegExp(FrenchNumeric.FractionNotationWithSpacesRegex), - value: "FracNum" - }, - { - regExp: RegExpUtility.getSafeRegExp(FrenchNumeric.FractionNounRegex), - value: "Frac" + FrenchNumeric.LangMarker - }, - { - regExp: RegExpUtility.getSafeRegExp(FrenchNumeric.FractionNounWithArticleRegex), - value: "Frac" + FrenchNumeric.LangMarker - } - ); - - // Not add FractionPrepositionRegex when the mode is Unit to avoid wrong recognize cases like "$1000 over 3" - if (mode != NumberMode.Unit) { - regexes.push({ - regExp: RegExpUtility.getSafeRegExp(FrenchNumeric.FractionPrepositionRegex), - value: "Frac" + FrenchNumeric.LangMarker - }); - }; - - this.regexes = regexes; - } -} - -export class FrenchOrdinalExtractor extends BaseNumberExtractor { - protected extractType: string = Constants.SYS_NUM_ORDINAL; - - constructor() { - super(); - let regexes = new Array( - { - regExp: RegExpUtility.getSafeRegExp(FrenchNumeric.OrdinalSuffixRegex), - value: "OrdinalNum" - }, - { - regExp: RegExpUtility.getSafeRegExp(FrenchNumeric.OrdinalFrenchRegex), - value: "Ord" + FrenchNumeric.LangMarker - } - ); - - this.regexes = regexes; - } -} - -export class FrenchPercentageExtractor extends BasePercentageExtractor { - constructor() { - super(new FrenchNumberExtractor()); - } - - protected initRegexes(): RegExp[] { - let regexStrs = [ - FrenchNumeric.NumberWithSuffixPercentage, - FrenchNumeric.NumberWithPrefixPercentage - ]; - - return this.buildRegexes(regexStrs); - } -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-number/src/number/french/parserConfiguration.ts b/JavaScript/packages/recognizers-number/src/number/french/parserConfiguration.ts deleted file mode 100644 index cd6f6daa9e..0000000000 --- a/JavaScript/packages/recognizers-number/src/number/french/parserConfiguration.ts +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { ParseResult } from "@microsoft/recognizers-text"; -import { INumberParserConfiguration } from "../parsers"; -import { CultureInfo, Culture } from "../../culture"; -import { FrenchNumeric } from "../../resources/frenchNumeric"; -import { RegExpUtility } from "@microsoft/recognizers-text"; - -export class FrenchNumberParserConfiguration implements INumberParserConfiguration { - - readonly cardinalNumberMap: ReadonlyMap; - readonly ordinalNumberMap: ReadonlyMap; - readonly roundNumberMap: ReadonlyMap; - readonly cultureInfo: CultureInfo; - readonly digitalNumberRegex: RegExp; - readonly fractionMarkerToken: string; - readonly negativeNumberSignRegex: RegExp; - readonly halfADozenRegex: RegExp; - readonly halfADozenText: string; - readonly langMarker: string; - readonly nonDecimalSeparatorChar: string; - readonly decimalSeparatorChar: string; - readonly wordSeparatorToken: string; - readonly writtenDecimalSeparatorTexts: readonly string[]; - readonly writtenGroupSeparatorTexts: readonly string[]; - readonly writtenIntegerSeparatorTexts: readonly string[]; - readonly writtenFractionSeparatorTexts: readonly string[]; - - constructor(ci?: CultureInfo) { - if (!ci) { - ci = new CultureInfo(Culture.French); - } - - this.cultureInfo = ci; - - this.langMarker = FrenchNumeric.LangMarker; - this.decimalSeparatorChar = FrenchNumeric.DecimalSeparatorChar; - this.fractionMarkerToken = FrenchNumeric.FractionMarkerToken; - this.nonDecimalSeparatorChar = FrenchNumeric.NonDecimalSeparatorChar; - this.halfADozenText = FrenchNumeric.HalfADozenText; - this.wordSeparatorToken = FrenchNumeric.WordSeparatorToken; - - this.writtenDecimalSeparatorTexts = FrenchNumeric.WrittenDecimalSeparatorTexts; - this.writtenGroupSeparatorTexts = FrenchNumeric.WrittenGroupSeparatorTexts; - this.writtenIntegerSeparatorTexts = FrenchNumeric.WrittenIntegerSeparatorTexts; - this.writtenFractionSeparatorTexts = FrenchNumeric.WrittenFractionSeparatorTexts; - - this.cardinalNumberMap = FrenchNumeric.CardinalNumberMap; - this.ordinalNumberMap = FrenchNumeric.OrdinalNumberMap; - this.roundNumberMap = FrenchNumeric.RoundNumberMap; - this.negativeNumberSignRegex = RegExpUtility.getSafeRegExp(FrenchNumeric.NegativeNumberSignRegex, "is"); - this.halfADozenRegex = RegExpUtility.getSafeRegExp(FrenchNumeric.HalfADozenRegex); - this.digitalNumberRegex = RegExpUtility.getSafeRegExp(FrenchNumeric.DigitalNumberRegex); - } - - normalizeTokenSet(tokens: readonly string[], context: ParseResult): readonly string[] { - return tokens; - } - - resolveCompositeNumber(numberStr: string): number { - if (this.ordinalNumberMap.has(numberStr)) { - return this.ordinalNumberMap.get(numberStr); - } - - if (this.cardinalNumberMap.has(numberStr)) { - return this.cardinalNumberMap.get(numberStr); - } - - let value = 0; - let finalValue = 0; - let strBuilder = ""; - let lastGoodChar = 0; - for (let i = 0; i < numberStr.length; i++) { - strBuilder = strBuilder.concat(numberStr[i]); - if (this.cardinalNumberMap.has(strBuilder) && this.cardinalNumberMap.get(strBuilder) > value) { - lastGoodChar = i; - value = this.cardinalNumberMap.get(strBuilder); - } - - if ((i + 1) === numberStr.length) { - finalValue += value; - strBuilder = ""; - i = lastGoodChar++; - value = 0; - } - } - - return finalValue; - } -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-number/src/number/japanese/extractors.ts b/JavaScript/packages/recognizers-number/src/number/japanese/extractors.ts deleted file mode 100644 index 059ab4baad..0000000000 --- a/JavaScript/packages/recognizers-number/src/number/japanese/extractors.ts +++ /dev/null @@ -1,260 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { BaseNumberExtractor, RegExpValue, RegExpRegExp, BasePercentageExtractor } from "../extractors"; -import { Constants } from "../constants"; -import { NumberMode, LongFormatType } from "../models"; -import { JapaneseNumeric } from "../../resources/japaneseNumeric"; -import { RegExpUtility } from "@microsoft/recognizers-text"; - -export enum JapaneseNumberExtractorMode { - // Number extraction with an allow list that filters what numbers to extract. - Default, - // Extract all number-related terms aggressively. - ExtractAll, -} - -export class JapaneseNumberExtractor extends BaseNumberExtractor { - protected extractType: string = Constants.SYS_NUM; - - constructor(mode: JapaneseNumberExtractorMode = JapaneseNumberExtractorMode.Default) { - super(); - let regexes = new Array(); - - // Add Cardinal - let cardExtract = new JapaneseCardinalExtractor(mode); - cardExtract.regexes.forEach(r => regexes.push(r)); - - // Add Fraction - let fracExtract = new JapaneseFractionExtractor(); - fracExtract.regexes.forEach(r => regexes.push(r)); - - this.regexes = regexes; - - // Add filter - let ambiguityFiltersDict = new Array(); - this.ambiguityFiltersDict = ambiguityFiltersDict; - } -} - -export class JapaneseCardinalExtractor extends BaseNumberExtractor { - protected extractType: string = Constants.SYS_NUM_CARDINAL; - - constructor(mode: JapaneseNumberExtractorMode = JapaneseNumberExtractorMode.Default) { - super(); - let regexes = new Array(); - - // Add Integer Regexes - let intExtract = new JapaneseIntegerExtractor(mode); - intExtract.regexes.forEach(r => regexes.push(r)); - - // Add Double Regexes - let doubleExtract = new JapaneseDoubleExtractor(); - doubleExtract.regexes.forEach(r => regexes.push(r)); - - this.regexes = regexes; - } -} - -export class JapaneseIntegerExtractor extends BaseNumberExtractor { - protected extractType: string = Constants.SYS_NUM_INTEGER; - - constructor(mode: JapaneseNumberExtractorMode = JapaneseNumberExtractorMode.Default) { - super(); - - let regexes = new Array( - { // 123456, -123456 - regExp: RegExpUtility.getSafeRegExp(JapaneseNumeric.NumbersSpecialsChars, "gi"), - value: "IntegerNum" - }, - { // 15k, 16 G - regExp: RegExpUtility.getSafeRegExp(JapaneseNumeric.NumbersSpecialsCharsWithSuffix, "gi"), - value: "IntegerNum" - }, - { // 1,234, 2,332,111 - regExp: RegExpUtility.getSafeRegExp(JapaneseNumeric.DottedNumbersSpecialsChar, "gi"), - value: "IntegerNum" - }, - { // 半百 半ダース - regExp: RegExpUtility.getSafeRegExp(JapaneseNumeric.NumbersWithHalfDozen, "gi"), - value: "IntegerJpn" - }, - { // 一ダース 五十ダース - regExp: RegExpUtility.getSafeRegExp(JapaneseNumeric.NumbersWithDozen, "gi"), - value: "IntegerJpn" - } - ); - - switch (mode) { - case JapaneseNumberExtractorMode.Default: - regexes.push({ // 一百五十五, 负一亿三百二十二. Uses an allow list to avoid extracting "西九条" from "九" - regExp: RegExpUtility.getSafeRegExp(JapaneseNumeric.NumbersWithAllowListRegex, "gi"), - value: "IntegerJpn" - }); - break; - - case JapaneseNumberExtractorMode.ExtractAll: - regexes.push({ // 一百五十五, 负一亿三百二十二, "西九条" from "九". Uses no allow lists and extracts all potential integers (useful in Units, for example). - regExp: RegExpUtility.getSafeRegExp(JapaneseNumeric.NumbersAggressiveRegex, "gi"), - value: "IntegerJpn" - }); - break; - } - - this.regexes = regexes; - } -} - -export class JapaneseDoubleExtractor extends BaseNumberExtractor { - protected extractType: string = Constants.SYS_NUM_DOUBLE; - - constructor() { - super(); - - let regexes = new Array( - { - regExp: RegExpUtility.getSafeRegExp(JapaneseNumeric.DoubleSpecialsChars, "gis"), - value: "DoubleNum" - }, - { // (-)2.5, can avoid cases like ip address xx.xx.xx.xx - regExp: RegExpUtility.getSafeRegExp(JapaneseNumeric.DoubleSpecialsCharsWithNegatives, "gis"), - value: "DoubleNum" - }, - { // (-).2 - regExp: RegExpUtility.getSafeRegExp(JapaneseNumeric.SimpleDoubleSpecialsChars, "gis"), - value: "DoubleNum" - }, - { // 1.0 K - regExp: RegExpUtility.getSafeRegExp(JapaneseNumeric.DoubleWithMultiplierRegex, "gis"), - value: "DoubleNum" - }, - { // 15.2万 - regExp: RegExpUtility.getSafeRegExp(JapaneseNumeric.DoubleWithThousandsRegex, "gis"), - value: "DoubleJpn" - }, - { // 2e6, 21.2e0 - regExp: RegExpUtility.getSafeRegExp(JapaneseNumeric.DoubleExponentialNotationRegex, "gis"), - value: "DoublePow" - }, - { // 2^5 - regExp: RegExpUtility.getSafeRegExp(JapaneseNumeric.DoubleScientificNotationRegex, "gis"), - value: "DoublePow" - } - ); - - this.regexes = regexes; - } -} - -export class JapaneseFractionExtractor extends BaseNumberExtractor { - protected extractType: string = Constants.SYS_NUM_FRACTION; - - constructor() { - super(); - - let regexes = new Array( - { // -4 5/2, 4 6/3 - regExp: RegExpUtility.getSafeRegExp(JapaneseNumeric.FractionNotationSpecialsCharsRegex, "gis"), - value: "FracNum" - }, - { // 8/3 - regExp: RegExpUtility.getSafeRegExp(JapaneseNumeric.FractionNotationRegex, "gis"), - value: "FracNum" - }, - { // 五分の二 七分の三 - regExp: RegExpUtility.getSafeRegExp(JapaneseNumeric.AllFractionNumber, "gis"), - value: "FracJpn" - } - ); - - this.regexes = regexes; - } -} - -export class JapaneseOrdinalExtractor extends BaseNumberExtractor { - protected extractType: string = Constants.SYS_NUM_ORDINAL; - - constructor() { - super(); - let regexes = new Array( - { // だい一百五十四 - regExp: RegExpUtility.getSafeRegExp(JapaneseNumeric.OrdinalRegex, "gi"), - value: "OrdinalJpn" - }, - { // だい2565 - regExp: RegExpUtility.getSafeRegExp(JapaneseNumeric.OrdinalNumbersRegex, "gi"), - value: "OrdinalJpn" - }, - { // 2折 2.5折 - regExp: RegExpUtility.getSafeRegExp(JapaneseNumeric.NumbersFoldsPercentageRegex, "gi"), - value: "OrdinalJpn" - } - ); - - this.regexes = regexes; - } -} - -export class JapanesePercentageExtractor extends BaseNumberExtractor { - extractType: string = Constants.SYS_NUM_PERCENTAGE; - - constructor() { - super(); - let regexes = new Array( - { // 百パーセント 十五パーセント - regExp: RegExpUtility.getSafeRegExp(JapaneseNumeric.SimplePercentageRegex, "gi"), - value: "PerJpn" - }, - { // 19パーセント 1パーセント - regExp: RegExpUtility.getSafeRegExp(JapaneseNumeric.NumbersPercentagePointRegex, "gis"), - value: "PerNum" - }, - { // 3,000パーセント 1,123パーセント - regExp: RegExpUtility.getSafeRegExp(JapaneseNumeric.NumbersPercentageWithSeparatorRegex, "gis"), - value: "PerNum" - }, - { // 3.2 k パーセント - regExp: RegExpUtility.getSafeRegExp(JapaneseNumeric.NumbersPercentageWithMultiplierRegex, "gi"), - value: "PerNum" - }, - { // 15kパーセント - regExp: RegExpUtility.getSafeRegExp(JapaneseNumeric.SimpleNumbersPercentageWithMultiplierRegex, "gi"), - value: "PerNum" - }, - { - regExp: RegExpUtility.getSafeRegExp(JapaneseNumeric.SimpleIntegerPercentageRegex, "gis"), - value: "PerNum" - }, - { // 2割引 2.5割引 - regExp: RegExpUtility.getSafeRegExp(JapaneseNumeric.NumbersFoldsPercentageRegex, "gis"), - value: "PerSpe" - }, - { // 三割引 六点五折 七五折 - regExp: RegExpUtility.getSafeRegExp(JapaneseNumeric.FoldsPercentageRegex, "gis"), - value: "PerSpe" - }, - { // 5割 7割半 - regExp: RegExpUtility.getSafeRegExp(JapaneseNumeric.SimpleFoldsPercentageRegex, "gis"), - value: "PerSpe" - }, - { // 七割半 - regExp: RegExpUtility.getSafeRegExp(JapaneseNumeric.SpecialsPercentageRegex, "gis"), - value: "PerSpe" - }, - { // 2割 2.5割 - regExp: RegExpUtility.getSafeRegExp(JapaneseNumeric.NumbersSpecialsPercentageRegex, "gis"), - value: "PerSpe" - }, - { // 三割 - regExp: RegExpUtility.getSafeRegExp(JapaneseNumeric.SimpleSpecialsPercentageRegex, "gis"), - value: "PerSpe" - }, - { - regExp: RegExpUtility.getSafeRegExp(JapaneseNumeric.SpecialsFoldsPercentageRegex, "gis"), - value: "PerSpe" - }, - ); - - this.regexes = regexes; - } -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-number/src/number/japanese/parserConfiguration.ts b/JavaScript/packages/recognizers-number/src/number/japanese/parserConfiguration.ts deleted file mode 100644 index 019d81e54a..0000000000 --- a/JavaScript/packages/recognizers-number/src/number/japanese/parserConfiguration.ts +++ /dev/null @@ -1,108 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { ParseResult } from "@microsoft/recognizers-text"; -import { ICJKNumberParserConfiguration } from "../cjkParsers"; -import { CultureInfo, Culture } from "../../culture"; -import { JapaneseNumeric } from "../../resources/japaneseNumeric"; -import { RegExpUtility } from "@microsoft/recognizers-text"; - -export class JapaneseNumberParserConfiguration implements ICJKNumberParserConfiguration { - - readonly cardinalNumberMap: ReadonlyMap; - readonly ordinalNumberMap: ReadonlyMap; - readonly roundNumberMap: ReadonlyMap; - readonly cultureInfo: CultureInfo; - readonly digitalNumberRegex: RegExp; - readonly fractionMarkerToken: string; - readonly halfADozenRegex: RegExp; - readonly halfADozenText: string; - readonly langMarker: string; - readonly nonDecimalSeparatorChar: string; - readonly decimalSeparatorChar: string; - readonly wordSeparatorToken: string; - readonly zeroChar: string; - readonly pairChar: string; - readonly writtenDecimalSeparatorTexts: readonly string[]; - readonly writtenGroupSeparatorTexts: readonly string[]; - readonly writtenIntegerSeparatorTexts: readonly string[]; - readonly writtenFractionSeparatorTexts: readonly string[]; - - readonly zeroToNineMap: ReadonlyMap; - readonly roundNumberMapChar: ReadonlyMap; - readonly fullToHalfMap: ReadonlyMap; - readonly tratoSimMap: ReadonlyMap; - readonly unitMap: ReadonlyMap; - readonly roundDirectList: readonly string[]; - readonly tenChars: readonly string[]; - readonly digitNumRegex: RegExp; - readonly dozenRegex: RegExp; - readonly percentageRegex: RegExp; - readonly percentageNumRegex: RegExp; - readonly doubleAndRoundRegex: RegExp; - readonly fracSplitRegex: RegExp; - readonly negativeNumberSignRegex: RegExp; - readonly pointRegex: RegExp; - readonly speGetNumberRegex: RegExp; - readonly pairRegex: RegExp; - readonly roundNumberIntegerRegex: RegExp; - - // readonly NumberOptions Options { get; } - // readonly Regex FractionPrepositionRegex { get; } - // readonly string NonDecimalSeparatorText - - constructor(ci?: CultureInfo) { - if (!ci) { - ci = new CultureInfo(Culture.Japanese); - } - - this.cultureInfo = ci; - - this.langMarker = JapaneseNumeric.LangMarker; - this.decimalSeparatorChar = JapaneseNumeric.DecimalSeparatorChar; - this.fractionMarkerToken = JapaneseNumeric.FractionMarkerToken; - this.nonDecimalSeparatorChar = JapaneseNumeric.NonDecimalSeparatorChar; - this.halfADozenText = JapaneseNumeric.HalfADozenText; - this.wordSeparatorToken = JapaneseNumeric.WordSeparatorToken; - this.zeroChar = JapaneseNumeric.ZeroChar; - this.pairChar = JapaneseNumeric.PairChar; - - this.writtenDecimalSeparatorTexts = []; - this.writtenGroupSeparatorTexts = []; - this.writtenIntegerSeparatorTexts = []; - this.writtenFractionSeparatorTexts = []; - - this.cardinalNumberMap = new Map(); - this.ordinalNumberMap = new Map(); - this.roundNumberMap = JapaneseNumeric.RoundNumberMap; - this.halfADozenRegex = null; - this.digitalNumberRegex = RegExpUtility.getSafeRegExp(JapaneseNumeric.DigitalNumberRegex, "gis"); - - this.zeroToNineMap = JapaneseNumeric.ZeroToNineMap; - this.roundNumberMapChar = JapaneseNumeric.RoundNumberMapChar; - this.fullToHalfMap = JapaneseNumeric.FullToHalfMap; - this.tratoSimMap = null; - this.unitMap = JapaneseNumeric.UnitMap; - this.roundDirectList = JapaneseNumeric.RoundDirectList; - this.tenChars = JapaneseNumeric.TenChars; - this.digitNumRegex = RegExpUtility.getSafeRegExp(JapaneseNumeric.DigitNumRegex, "gis"); - this.dozenRegex = RegExpUtility.getSafeRegExp(JapaneseNumeric.DozenRegex, "gis"); - this.percentageRegex = RegExpUtility.getSafeRegExp(JapaneseNumeric.PercentageRegex, "gis"); - this.percentageNumRegex = null; - this.doubleAndRoundRegex = RegExpUtility.getSafeRegExp(JapaneseNumeric.DoubleAndRoundRegex, "gis"); - this.fracSplitRegex = RegExpUtility.getSafeRegExp(JapaneseNumeric.FracSplitRegex, "gis"); - this.negativeNumberSignRegex = RegExpUtility.getSafeRegExp(JapaneseNumeric.NegativeNumberSignRegex, "is"); - this.pointRegex = RegExpUtility.getSafeRegExp(JapaneseNumeric.PointRegex, "gis"); - this.speGetNumberRegex = RegExpUtility.getSafeRegExp(JapaneseNumeric.SpeGetNumberRegex, "gis"); - this.pairRegex = RegExpUtility.getSafeRegExp(JapaneseNumeric.PairRegex, "gis"); - this.roundNumberIntegerRegex = RegExpUtility.getSafeRegExp(JapaneseNumeric.RoundNumberIntegerRegex, "gis"); - - } - normalizeTokenSet(tokens: readonly string[], context: ParseResult): readonly string[] { - return tokens; - } - - resolveCompositeNumber(numberStr: string): number { - return 0; - } -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-number/src/number/models.ts b/JavaScript/packages/recognizers-number/src/number/models.ts deleted file mode 100644 index d7bf53e50b..0000000000 --- a/JavaScript/packages/recognizers-number/src/number/models.ts +++ /dev/null @@ -1,116 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { IModel, ModelResult, IExtractor, IParser, ParseResult, QueryProcessor } from "@microsoft/recognizers-text"; -import { Constants } from "./constants"; - -export enum NumberMode { - // Default is for unit and datetime - Default, - // Add 67.5 billion & million support. - Currency, - // Don't extract number from cases like 16ml - PureNumber, - // Unit is for unit - Unit -} - -export class LongFormatType { - // Reference : https://www.wikiwand.com/en/Decimal_mark - // Value : 1234567.89 - // 1,234,567 - static readonly integerNumComma = new LongFormatType(',', '\0'); - - // 1.234.567 - static readonly integerNumDot = new LongFormatType('.', '\0'); - - // 1 234 567 - static readonly integerNumBlank = new LongFormatType(' ', '\0'); - - // 1 234 567 - static readonly integerNumNoBreakSpace = new LongFormatType(Constants.NO_BREAK_SPACE, '\0'); - - // 1'234'567 - static readonly integerNumQuote = new LongFormatType('\'', '\0'); - - // 1,234,567.89 - static readonly doubleNumCommaDot = new LongFormatType(',', '.'); - - // 1,234,567·89 - static readonly doubleNumCommaCdot = new LongFormatType(',', '·'); - - // 1 234 567,89 - static readonly doubleNumBlankComma = new LongFormatType(' ', ','); - - // 1 234 567,89 - static readonly doubleNumNoBreakSpaceComma = new LongFormatType(Constants.NO_BREAK_SPACE, ','); - - // 1 234 567.89 - static readonly doubleNumBlankDot = new LongFormatType(' ', '.'); - - // 1 234 567.89 - static readonly doubleNumNoBreakSpaceDot = new LongFormatType(Constants.NO_BREAK_SPACE, '.'); - - // 1.234.567,89 - static readonly doubleNumDotComma = new LongFormatType('.', ','); - - // 1'234'567,89 - static readonly doubleNumQuoteComma = new LongFormatType('\'', ','); - - readonly thousandsMark: string; - readonly decimalsMark: string; - - constructor(thousandsMark: string, decimalsMark: string) { - this.thousandsMark = thousandsMark; - this.decimalsMark = decimalsMark; - } -} - -export abstract class AbstractNumberModel implements IModel { - abstract modelTypeName: string; - - protected readonly parser: IParser; - protected readonly extractor: IExtractor; - - constructor(parser: IParser, extractor: IExtractor) { - this.extractor = extractor; - this.parser = parser; - } - - parse(query: string): ModelResult[] { - query = QueryProcessor.preProcess(query, true); - let parseNums: ParseResult[]; - - try { - let extractResults = this.extractor.extract(query); - parseNums = extractResults.map(r => this.parser.parse(r)); - } - catch (err) { - // Nothing to do. Exceptions in result process should not affect other extracted entities. - // No result. - } - finally { - return parseNums - .map(o => o as ParseResult) - .map(o => ({ - start: o.start, - end: o.start + o.length - 1, - resolution: { value: o.resolutionStr }, - text: o.text, - typeName: this.modelTypeName - })); - } - } -} - -export class NumberModel extends AbstractNumberModel { - modelTypeName: string = "number"; -} - -export class OrdinalModel extends AbstractNumberModel { - modelTypeName: string = "ordinal"; -} - -export class PercentModel extends AbstractNumberModel { - modelTypeName: string = "percentage"; -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-number/src/number/numberRecognizer.ts b/JavaScript/packages/recognizers-number/src/number/numberRecognizer.ts deleted file mode 100644 index 15b50b1f11..0000000000 --- a/JavaScript/packages/recognizers-number/src/number/numberRecognizer.ts +++ /dev/null @@ -1,138 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { IModel, ModelResult } from "@microsoft/recognizers-text"; -import { Recognizer } from "@microsoft/recognizers-text"; -import { Culture } from "../culture"; -import { NumberMode, NumberModel, OrdinalModel, PercentModel } from "./models"; -import { AgnosticNumberParserType, AgnosticNumberParserFactory } from "./agnosticNumberParser"; -import { EnglishNumberParserConfiguration } from "./english/parserConfiguration"; -import { SpanishNumberParserConfiguration } from "./spanish/parserConfiguration"; -import { PortugueseNumberParserConfiguration } from "./portuguese/parserConfiguration"; -import { FrenchNumberParserConfiguration } from "./french/parserConfiguration"; -import { ChineseNumberParserConfiguration } from "./chinese/parserConfiguration"; -import { JapaneseNumberParserConfiguration } from "./japanese/parserConfiguration"; -import { EnglishNumberExtractor, EnglishOrdinalExtractor, EnglishPercentageExtractor } from "./english/extractors"; -import { SpanishNumberExtractor, SpanishOrdinalExtractor, SpanishPercentageExtractor } from "./spanish/extractors"; -import { PortugueseNumberExtractor, PortugueseOrdinalExtractor, PortuguesePercentageExtractor } from "./portuguese/extractors"; -import { FrenchNumberExtractor, FrenchOrdinalExtractor, FrenchPercentageExtractor } from "./french/extractors"; -import { ChineseNumberExtractor, ChineseOrdinalExtractor, ChinesePercentageExtractor } from "./chinese/extractors"; -import { JapaneseNumberExtractor, JapaneseOrdinalExtractor, JapanesePercentageExtractor } from "./japanese/extractors"; - -export enum NumberOptions { - None = 0, -} - -export function recognizeNumber(query: string, culture: string, options: NumberOptions = NumberOptions.None, fallbackToDefaultCulture: boolean = true): ModelResult[] { - return recognizeByModel(recognizer => recognizer.getNumberModel(culture, fallbackToDefaultCulture), query, culture, options); -} - -export function recognizeOrdinal(query: string, culture: string, options: NumberOptions = NumberOptions.None, fallbackToDefaultCulture: boolean = true): ModelResult[] { - return recognizeByModel(recognizer => recognizer.getOrdinalModel(culture, fallbackToDefaultCulture), query, culture, options); -} - -export function recognizePercentage(query: string, culture: string, options: NumberOptions = NumberOptions.None, fallbackToDefaultCulture: boolean = true): ModelResult[] { - return recognizeByModel(recognizer => recognizer.getPercentageModel(culture, fallbackToDefaultCulture), query, culture, options); -} - -function recognizeByModel(getModelFunc: (n: NumberRecognizer) => IModel, query: string, culture: string, options: NumberOptions): ModelResult[] { - let recognizer = new NumberRecognizer(culture, options); - let model = getModelFunc(recognizer); - return model.parse(query); -} - -export default class NumberRecognizer extends Recognizer { - constructor(culture, options: NumberOptions = NumberOptions.None, lazyInitialization: boolean = false) { - super(culture, options, lazyInitialization); - } - - protected InitializeConfiguration() { - // #region English - this.registerModel("NumberModel", Culture.English, (options) => new NumberModel( - AgnosticNumberParserFactory.getParser(AgnosticNumberParserType.Number, new EnglishNumberParserConfiguration()), - new EnglishNumberExtractor(NumberMode.PureNumber))); - this.registerModel("OrdinalModel", Culture.English, (options) => new OrdinalModel( - AgnosticNumberParserFactory.getParser(AgnosticNumberParserType.Ordinal, new EnglishNumberParserConfiguration()), - new EnglishOrdinalExtractor())); - this.registerModel("PercentModel", Culture.English, (options) => new PercentModel( - AgnosticNumberParserFactory.getParser(AgnosticNumberParserType.Percentage, new EnglishNumberParserConfiguration()), - new EnglishPercentageExtractor())); - // #endregion - - // #region Spanish - this.registerModel("NumberModel", Culture.Spanish, (options) => new NumberModel( - AgnosticNumberParserFactory.getParser(AgnosticNumberParserType.Number, new SpanishNumberParserConfiguration()), - new SpanishNumberExtractor(NumberMode.PureNumber))); - this.registerModel("OrdinalModel", Culture.Spanish, (options) => new OrdinalModel( - AgnosticNumberParserFactory.getParser(AgnosticNumberParserType.Ordinal, new SpanishNumberParserConfiguration()), - new SpanishOrdinalExtractor())); - this.registerModel("PercentModel", Culture.Spanish, (options) => new PercentModel( - AgnosticNumberParserFactory.getParser(AgnosticNumberParserType.Percentage, new SpanishNumberParserConfiguration()), - new SpanishPercentageExtractor())); - // #endregion - - // #region Portuguese - this.registerModel("NumberModel", Culture.Portuguese, (options) => new NumberModel( - AgnosticNumberParserFactory.getParser(AgnosticNumberParserType.Number, new PortugueseNumberParserConfiguration()), - new PortugueseNumberExtractor(NumberMode.PureNumber))); - this.registerModel("OrdinalModel", Culture.Portuguese, (options) => new OrdinalModel( - AgnosticNumberParserFactory.getParser(AgnosticNumberParserType.Ordinal, new PortugueseNumberParserConfiguration()), - new PortugueseOrdinalExtractor())); - this.registerModel("PercentModel", Culture.Portuguese, (options) => new PercentModel( - AgnosticNumberParserFactory.getParser(AgnosticNumberParserType.Percentage, new PortugueseNumberParserConfiguration()), - new PortuguesePercentageExtractor())); - // #endregion - - // #region Chinese - this.registerModel("NumberModel", Culture.Chinese, (options) => new NumberModel( - AgnosticNumberParserFactory.getParser(AgnosticNumberParserType.Number, new ChineseNumberParserConfiguration()), - new ChineseNumberExtractor())); - this.registerModel("OrdinalModel", Culture.Chinese, (options) => new OrdinalModel( - AgnosticNumberParserFactory.getParser(AgnosticNumberParserType.Ordinal, new ChineseNumberParserConfiguration()), - new ChineseOrdinalExtractor())); - this.registerModel("PercentModel", Culture.Chinese, (options) => new PercentModel( - AgnosticNumberParserFactory.getParser(AgnosticNumberParserType.Percentage, new ChineseNumberParserConfiguration()), - new ChinesePercentageExtractor())); - // #endregion - - // #region Japanese - this.registerModel("NumberModel", Culture.Japanese, (options) => new NumberModel( - AgnosticNumberParserFactory.getParser(AgnosticNumberParserType.Number, new JapaneseNumberParserConfiguration()), - new JapaneseNumberExtractor())); - this.registerModel("OrdinalModel", Culture.Japanese, (options) => new OrdinalModel( - AgnosticNumberParserFactory.getParser(AgnosticNumberParserType.Ordinal, new JapaneseNumberParserConfiguration()), - new JapaneseOrdinalExtractor())); - this.registerModel("PercentModel", Culture.Japanese, (options) => new PercentModel( - AgnosticNumberParserFactory.getParser(AgnosticNumberParserType.Percentage, new JapaneseNumberParserConfiguration()), - new JapanesePercentageExtractor())); - // #endregion - - // #region French - this.registerModel("NumberModel", Culture.French, (options) => new NumberModel( - AgnosticNumberParserFactory.getParser(AgnosticNumberParserType.Number, new FrenchNumberParserConfiguration()), - new FrenchNumberExtractor(NumberMode.PureNumber))); - this.registerModel("OrdinalModel", Culture.French, (options) => new OrdinalModel( - AgnosticNumberParserFactory.getParser(AgnosticNumberParserType.Ordinal, new FrenchNumberParserConfiguration()), - new FrenchOrdinalExtractor())); - this.registerModel("PercentModel", Culture.French, (options) => new PercentModel( - AgnosticNumberParserFactory.getParser(AgnosticNumberParserType.Percentage, new FrenchNumberParserConfiguration()), - new FrenchPercentageExtractor())); - // #endregion - } - - protected IsValidOptions(options: number): boolean { - return options >= 0 && options <= NumberOptions.None; - } - - getNumberModel(culture: string = null, fallbackToDefaultCulture: boolean = true): IModel { - return this.getModel("NumberModel", culture, fallbackToDefaultCulture); - } - - getOrdinalModel(culture: string = null, fallbackToDefaultCulture: boolean = true): IModel { - return this.getModel("OrdinalModel", culture, fallbackToDefaultCulture); - } - - getPercentageModel(culture: string = null, fallbackToDefaultCulture: boolean = true): IModel { - return this.getModel("PercentModel", culture, fallbackToDefaultCulture); - } -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-number/src/number/parsers.ts b/JavaScript/packages/recognizers-number/src/number/parsers.ts deleted file mode 100644 index 0625662f7e..0000000000 --- a/JavaScript/packages/recognizers-number/src/number/parsers.ts +++ /dev/null @@ -1,701 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { IParser, ParseResult, ExtractResult } from "@microsoft/recognizers-text"; -import { CultureInfo, Culture } from "../culture"; -import { Constants } from "./constants"; -import trimEnd = require("lodash.trimend"); -import sortBy = require("lodash.sortby"); -import { RegExpUtility } from "@microsoft/recognizers-text"; -import { BigNumber } from 'bignumber.js/bignumber'; - -// The exponent value(s) at which toString returns exponential notation. -BigNumber.config({ EXPONENTIAL_AT: [-5, 15] }); - -export interface INumberParserConfiguration { - readonly cardinalNumberMap: ReadonlyMap; - readonly ordinalNumberMap: ReadonlyMap; - readonly roundNumberMap: ReadonlyMap; - readonly cultureInfo: CultureInfo; - readonly digitalNumberRegex: RegExp; - readonly fractionMarkerToken: string; - readonly negativeNumberSignRegex: RegExp; - readonly halfADozenRegex: RegExp; - readonly halfADozenText: string; - readonly langMarker: string; - readonly nonDecimalSeparatorChar: string; - readonly decimalSeparatorChar: string; - readonly wordSeparatorToken: string; - readonly writtenDecimalSeparatorTexts: readonly string[]; - readonly writtenGroupSeparatorTexts: readonly string[]; - readonly writtenIntegerSeparatorTexts: readonly string[]; - readonly writtenFractionSeparatorTexts: readonly string[]; - - normalizeTokenSet(tokens: readonly string[], context: ParseResult): readonly string[]; - resolveCompositeNumber(numberStr: string): number; -} - -export class BaseNumberParser implements IParser { - protected readonly config: INumberParserConfiguration; - protected readonly textNumberRegex: RegExp; - protected readonly arabicNumberRegex: RegExp; - protected readonly roundNumberSet: Set; - - supportedTypes: readonly string[]; - - constructor(config: INumberParserConfiguration) { - this.config = config; - - let singleIntFrac = `${this.config.wordSeparatorToken}| -|${this.getKeyRegex(this.config.cardinalNumberMap)}|${this.getKeyRegex(this.config.ordinalNumberMap)}`; - - this.textNumberRegex = RegExpUtility.getSafeRegExp(String.raw`(?=\b)(${singleIntFrac})(?=\b)`, "gis"); - this.arabicNumberRegex = RegExpUtility.getSafeRegExp(String.raw`\d+`, "is"); - this.roundNumberSet = new Set(); - this.config.roundNumberMap.forEach((value, key) => - this.roundNumberSet.add(key) - ); - } - - parse(extResult: ExtractResult): ParseResult | null { - - // check if the parser is configured to support specific types - if (this.supportedTypes && !this.supportedTypes.find(t => t === extResult.type)) { - return null; - } - - let ret: ParseResult | null = null; - let extra = extResult.data as string; - if (!extra) { - if (this.arabicNumberRegex.test(extResult.text)) { - extra = "Num"; - } - else { - extra = this.config.langMarker; - } - } - - // Resolve symbol prefix - let isNegative = false; - let matchNegative = extResult.text.match(this.config.negativeNumberSignRegex); - - if (matchNegative) { - isNegative = true; - extResult.text = extResult.text.substr(matchNegative[1].length); - } - - if (extra.includes("Num")) { - ret = this.digitNumberParse(extResult); - } - else if (extra.includes(`Frac${this.config.langMarker}`)) // Frac is a special number, parse via another method - { - ret = this.fracLikeNumberParse(extResult); - } - else if (extra.includes(this.config.langMarker)) { - ret = this.textNumberParse(extResult); - } - else if (extra.includes("Pow")) { - ret = this.powerNumberParse(extResult); - } - - if (ret && ret.value !== null) { - if (isNegative) { - // Recover to the original extracted Text - ret.text = matchNegative[1] + extResult.text; - // Check if ret.value is a BigNumber - if (typeof ret.value === "number") { - ret.value = -ret.value; - } - else { - ret.value.s = -1; - } - } - - ret.resolutionStr = this.config.cultureInfo - ? this.config.cultureInfo.format(ret.value) - : ret.value.toString(); - - ret.text = ret.text.toLowerCase(); - } - - return ret; - } - - protected getKeyRegex(regexMap: ReadonlyMap): string { - let keys = new Array(); - regexMap.forEach((value, key) => keys.push(key)); - let sortKeys = sortBy(keys, key => key.length).reverse(); - return sortKeys.join('|'); - } - - protected digitNumberParse(extResult: ExtractResult): ParseResult { - let result: ParseResult = { - start: extResult.start, - length: extResult.length, - text: extResult.text, - type: extResult.type - }; - - // [1] 24 - // [2] 12 32/33 - // [3] 1,000,000 - // [4] 234.567 - // [5] 44/55 - // [6] 2 hundred - // dot occured. - - let power = 1; - let tmpIndex = -1; - let startIndex = 0; - let handle = extResult.text.toLowerCase(); - - let matches = RegExpUtility.getMatches(this.config.digitalNumberRegex, handle); - if (matches) { - matches.forEach(match => { - // HACK: Matching regex may be buggy, may include a digit before the unit - match.value = match.value.replace(/\d/g, ''); - match.length = match.value.length; - - let rep: number = this.config.roundNumberMap.get(match.value) as number; - // \\s+ for filter the spaces. - power *= rep; - - // tslint:disable-next-line:no-conditional-assignment - while ((tmpIndex = handle.indexOf(match.value, startIndex)) >= 0) { - let front = trimEnd(handle.substring(0, tmpIndex)); - startIndex = front.length; - handle = front + handle.substring(tmpIndex + match.length); - } - }); - } - - // scale used in the calculate of double - result.value = this.getDigitalValue(handle, power); - - return result; - } - - protected isDigit(c: string): boolean { - return c >= '0' && c <= '9'; - } - - protected fracLikeNumberParse(extResult: ExtractResult): ParseResult { - - let result = - { - start: extResult.start, - length: extResult.length, - text: extResult.text, - type: extResult.type - } as ParseResult; - - let resultText = extResult.text.toLowerCase(); - if (resultText.includes(this.config.fractionMarkerToken)) { - let overIndex = resultText.indexOf(this.config.fractionMarkerToken); - let smallPart = resultText.substring(0, overIndex).trim(); - let bigPart = resultText.substring(overIndex + this.config.fractionMarkerToken.length, resultText.length).trim(); - - let smallValue = this.isDigit(smallPart[0]) - ? this.getDigitalValue(smallPart, 1) - : this.getIntValue(this.getMatches(smallPart)); - - let bigValue = this.isDigit(bigPart[0]) - ? this.getDigitalValue(bigPart, 1) - : this.getIntValue(this.getMatches(bigPart)); - - result.value = smallValue / bigValue; - } - else { - let words = resultText.split(" ").filter(s => s && s.length); - let fracWords = Array.from(this.config.normalizeTokenSet(words, result)); - - // Split fraction with integer - let splitIndex = fracWords.length - 1; - let currentValue = this.config.resolveCompositeNumber(fracWords[splitIndex]); - let roundValue = 1; - - if (fracWords.length == 1) { - result.value = 1 / this.getIntValue(fracWords); - return result; - } - - for (splitIndex = fracWords.length - 2; splitIndex >= 0; splitIndex--) { - - if (this.config.writtenFractionSeparatorTexts.indexOf(fracWords[splitIndex]) > -1 || - this.config.writtenIntegerSeparatorTexts.indexOf(fracWords[splitIndex]) > -1) { - continue; - } - - let previousValue = currentValue; - currentValue = this.config.resolveCompositeNumber(fracWords[splitIndex]); - - let smHundreds = 100; - - // previous : hundred - // current : one - if ((previousValue >= smHundreds && previousValue > currentValue) - || (previousValue < smHundreds && this.isComposable(currentValue, previousValue))) { - if (previousValue < smHundreds && currentValue >= roundValue) { - roundValue = currentValue; - } - else if (previousValue < smHundreds && currentValue < roundValue) { - splitIndex++; - break; - } - // current is the first word - if (splitIndex === 0) { - // scan, skip the first word - splitIndex = 1; - while (splitIndex <= fracWords.length - 2) { - // e.g. one hundred thousand - // frac[i+1] % 100 && frac[i] % 100 = 0 - if (this.config.resolveCompositeNumber(fracWords[splitIndex]) >= smHundreds - && !(this.config.writtenFractionSeparatorTexts.indexOf(fracWords[splitIndex + 1]) > -1) - && this.config.resolveCompositeNumber(fracWords[splitIndex + 1]) < smHundreds) { - splitIndex++; - break; - } - splitIndex++; - } - break; - } - continue; - } - splitIndex++; - break; - } - - let fracPart = new Array(); - for (let i = splitIndex; i < fracWords.length; i++) { - if (fracWords[i].indexOf("-") > -1) { - let split = fracWords[i].split('-'); - fracPart.push(split[0]); - fracPart.push("-"); - fracPart.push(split[1]); - } - else { - fracPart.push(fracWords[i]); - } - } - - fracWords.splice(splitIndex, fracWords.length - splitIndex); - - // denomi = denominator - let denomiValue = this.getIntValue(fracPart); - // Split mixed number with fraction - let numerValue = 0; - let intValue = 0; - - let mixedIndex = fracWords.length; - for (let i = fracWords.length - 1; i >= 0; i--) { - if (i < fracWords.length - 1 && this.config.writtenFractionSeparatorTexts.indexOf(fracWords[i]) > -1) { - let numerStr = fracWords.slice(i + 1, fracWords.length).join(" "); - numerValue = this.getIntValue(this.getMatches(numerStr)); - mixedIndex = i + 1; - break; - } - } - - let intStr = fracWords.slice(0, mixedIndex).join(" "); - intValue = this.getIntValue(this.getMatches(intStr)); - - // Find mixed number - if (mixedIndex !== fracWords.length && numerValue < denomiValue) { - // intValue + numerValue / denomiValue - result.value = new BigNumber(intValue).plus(new BigNumber(numerValue).dividedBy(denomiValue)); - } - else { - // (intValue + numerValue) / denomiValue - result.value = new BigNumber(intValue + numerValue).dividedBy(denomiValue); - } - } - - return result; - } - - protected textNumberParse(extResult: ExtractResult): ParseResult { - let result = - { - start: extResult.start, - length: extResult.length, - text: extResult.text, - type: extResult.type - } as ParseResult; - - let handle = extResult.text.toLowerCase(); - - handle = handle.replace(this.config.halfADozenRegex, this.config.halfADozenText); - - let numGroup = this.splitMulti(handle, Array.from(this.config.writtenDecimalSeparatorTexts)).filter(s => s && s.length > 0); - - let intPart = numGroup[0]; - - let matchStrs = (intPart && intPart.match(this.textNumberRegex)) - ? intPart.match(this.textNumberRegex).map(s => s.toLowerCase()) - : new Array(); - - // Get the value recursively - let intPartRet = this.getIntValue(matchStrs); - - let pointPartRet = 0; - if (numGroup.length === 2) { - let pointPart = numGroup[1]; - let matchStrs = pointPart.match(this.textNumberRegex).map(s => s.toLowerCase()); - pointPartRet += this.getPointValue(matchStrs); - } - - result.value = intPartRet + pointPartRet; - - return result; - } - - protected powerNumberParse(extResult: ExtractResult): ParseResult { - let result = - { - start: extResult.start, - length: extResult.length, - text: extResult.text, - type: extResult.type - } as ParseResult; - - let handle = extResult.text.toUpperCase(); - let isE = !extResult.text.includes("^"); - - // [1] 1e10 - // [2] 1.1^-23 - let calStack = new Array(); - - let scale = new BigNumber(10); - let dot = false; - let isNegative = false; - let tmp = new BigNumber(0); - for (let i = 0; i < handle.length; i++) { - let ch = handle[i]; - if (ch === '^' || ch === 'E') { - if (isNegative) { - calStack.push(tmp.negated()); - } - else { - calStack.push(tmp); - } - tmp = new BigNumber(0); - scale = new BigNumber(10); - dot = false; - isNegative = false; - } - else if (ch.charCodeAt(0) - 48 >= 0 && ch.charCodeAt(0) - 48 <= 9) { - if (dot) { - // tmp = tmp + scale * (ch.charCodeAt(0) - 48); - // scale *= 0.1; - tmp = tmp.plus(scale.times(ch.charCodeAt(0) - 48)); - scale = scale.times(0.1); - } - else { - // tmp = tmp * scale + (ch.charCodeAt(0) - 48); - tmp = tmp.times(scale).plus(ch.charCodeAt(0) - 48); - } - } - else if (ch === this.config.decimalSeparatorChar) { - dot = true; - scale = new BigNumber(0.1); - } - else if (ch === '-') { - isNegative = !isNegative; - } - else if (ch === '+') { - continue; - } - - if (i === handle.length - 1) { - if (isNegative) { - calStack.push(tmp.negated()); - } - else { - calStack.push(tmp); - } - } - } - - let ret = 0; - if (isE) { - // ret = calStack.shift() * Math.pow(10, calStack.shift()); - ret = calStack.shift().times(Math.pow(10, calStack.shift().toNumber())).toNumber(); - } - else { - ret = Math.pow(calStack.shift().toNumber(), calStack.shift().toNumber()); - } - - result.value = ret; - result.resolutionStr = ret.toString(); // @TODO Possible Culture bug. - - return result; - } - - private splitMulti(str: string, tokens: string[]): string[] { - let tempChar = tokens[0]; // We can use the first token as a temporary join character - for (let i = 0; i < tokens.length; i++) { - str = str.split(tokens[i]).join(tempChar); - } - return str.split(tempChar); - } - - private getMatches(input: string): string[] { - let matches = input.match(this.textNumberRegex); - return (matches || []).map(match => { - return match.toLowerCase(); - }); - } - - // Test if big and combine with small. - // e.g. "hundred" can combine with "thirty" but "twenty" can't combine with "thirty". - private isComposable(big: number, small: number): boolean { - let baseNumber = small > 10 ? 100 : 10; - - if (big % baseNumber === 0 && big / baseNumber >= 1) { - return true; - } - - return false; - } - - private getIntValue(matchStrs: string[]): number { - let isEnd = new Array(matchStrs.length); - for (let i = 0; i < isEnd.length; i++) { - isEnd[i] = false; - } - - let tempValue = 0; - let endFlag = 1; - - // Scan from end to start, find the end word - for (let i = matchStrs.length - 1; i >= 0; i--) { - if (this.roundNumberSet.has(matchStrs[i])) { - // if false,then continue - // You will meet hundred first, then thousand. - if (endFlag > this.config.roundNumberMap.get(matchStrs[i])) { - continue; - } - isEnd[i] = true; - endFlag = this.config.roundNumberMap.get(matchStrs[i]); - } - } - - if (endFlag === 1) { - let tempStack = new Array(); - let oldSym = ""; - matchStrs.forEach(matchStr => { - let isCardinal = this.config.cardinalNumberMap.has(matchStr); - let isOrdinal = this.config.ordinalNumberMap.has(matchStr); - if (isCardinal || isOrdinal) { - let matchValue = isCardinal - ? this.config.cardinalNumberMap.get(matchStr) - : this.config.ordinalNumberMap.get(matchStr); - - // This is just for ordinal now. Not for fraction ever. - if (isOrdinal) { - let fracPart = this.config.ordinalNumberMap.get(matchStr); - if (tempStack.length > 0) { - let intPart = tempStack.pop(); - // if intPart >= fracPart, it means it is an ordinal number - // it begins with an integer, ends with an ordinal - // e.g. ninety-ninth - if (intPart >= fracPart) { - tempStack.push(intPart + fracPart); - } - // another case of the type is ordinal - // e.g. three hundredth - else { - while (tempStack.length > 0) { - intPart = intPart + tempStack.pop(); - } - tempStack.push(intPart * fracPart); - } - } - else { - tempStack.push(fracPart); - } - } - else if (this.config.cardinalNumberMap.has(matchStr)) { - if (oldSym === "-") { - let sum = tempStack.pop() + matchValue; - tempStack.push(sum); - } - else if (oldSym === this.config.writtenIntegerSeparatorTexts[0] || tempStack.length < 2) { - tempStack.push(matchValue); - } - else if (tempStack.length >= 2) { - let sum = tempStack.pop() + matchValue; - sum = tempStack.pop() + sum; - tempStack.push(sum); - } - } - } - else { - let complexValue = this.config.resolveCompositeNumber(matchStr); - if (complexValue !== 0) { - tempStack.push(complexValue); - } - } - oldSym = matchStr; - }); - - tempStack.forEach(stackValue => { - tempValue += stackValue; - }); - } - else { - let lastIndex = 0; - let mulValue = 1; - let partValue = 1; - for (let i = 0; i < isEnd.length; i++) { - if (isEnd[i]) { - mulValue = this.config.roundNumberMap.get(matchStrs[i]); - partValue = 1; - - if (i !== 0) { - partValue = this.getIntValue(matchStrs.slice(lastIndex, i)); - } - - tempValue += mulValue * partValue; - lastIndex = i + 1; - } - } - - // Calculate the part like "thirty-one" - mulValue = 1; - if (lastIndex !== isEnd.length) { - partValue = this.getIntValue(matchStrs.slice(lastIndex, isEnd.length)); - tempValue += mulValue * partValue; - } - } - - return tempValue; - } - - private getPointValue(matchStrs: string[]): number { - let ret = 0; - let firstMatch = matchStrs[0]; - - if (this.config.cardinalNumberMap.has(firstMatch) && this.config.cardinalNumberMap.get(firstMatch) >= 10) { - let prefix = "0."; - let tempInt = this.getIntValue(matchStrs); - let all = prefix + tempInt; - ret = parseFloat(all); - } - else { - let scale = new BigNumber(0.1); - for (let i = 0; i < matchStrs.length; i++) { - ret += scale.times(this.config.cardinalNumberMap.get(matchStrs[i])).toNumber(); - // scale *= 0.1; - scale = scale.times(0.1); - } - } - - return ret; - } - - private skipNonDecimalSeparator(ch: string, distance: number, culture: CultureInfo) { - let decimalLength = 3; - - // Special cases for multi-language countries where decimal separators can be used interchangeably. Mostly informally. - // Ex: South Africa, Namibia; Puerto Rico in ES; or in Canada for EN and FR. - // "me pidio $5.00 prestados" and "me pidio $5,00 prestados" -> currency $5 - let cultureRegex = RegExpUtility.getSafeRegExp(String.raw`^(en|es|fr)(-)?\b`, "is"); - - return (ch == this.config.nonDecimalSeparatorChar && !(distance <= decimalLength && (cultureRegex.exec(culture.code) !== null))); - } - - protected getDigitalValue(digitsStr: string, power: number): number { - let tmp = new BigNumber(0); - let scale = new BigNumber(10); - let decimalSeparator = false; - let strLength = digitsStr.length; - let isNegative = false; - let isFrac = digitsStr.includes('/'); - - let calStack = new Array(); - - for (let i = 0; i < digitsStr.length; i++) { - - let ch = digitsStr[i]; - let skippableNonDecimal = this.skipNonDecimalSeparator(ch, strLength - i, this.config.cultureInfo); - - if (!isFrac && (ch === ' ' || skippableNonDecimal)) { - continue; - } - - if (ch === ' ' || ch === '/') { - calStack.push(tmp); - tmp = new BigNumber(0); - } - else if (ch >= '0' && ch <= '9') { - if (decimalSeparator) { - // tmp = tmp + scale * (ch.charCodeAt(0) - 48); - // scale *= 0.1; - tmp = tmp.plus(scale.times(ch.charCodeAt(0) - 48)); - scale = scale.times(0.1); - } - else { - // tmp = tmp * scale + (ch.charCodeAt(0) - 48); - tmp = tmp.times(scale).plus(ch.charCodeAt(0) - 48); - } - } - else if (ch === this.config.decimalSeparatorChar || (!skippableNonDecimal && ch == this.config.nonDecimalSeparatorChar)) { - decimalSeparator = true; - scale = new BigNumber(0.1); - } - else if (ch === '-') { - isNegative = true; - } - } - calStack.push(tmp); - - // if the number is a fraction. - let calResult = new BigNumber(0); - if (isFrac) { - let deno = calStack.pop(); - let mole = calStack.pop(); - // calResult += mole / deno; - calResult = calResult.plus(mole.dividedBy(deno)); - } - - while (calStack.length > 0) { - calResult = calResult.plus(calStack.pop()); - } - - // calResult *= power; - calResult = calResult.times(power); - - if (isNegative) { - return calResult.negated().toNumber(); - } - - - return calResult.toNumber(); - } -} - -export class BasePercentageParser extends BaseNumberParser { - parse(extResult: ExtractResult): ParseResult | null { - - let originText = extResult.text; - - // do replace text & data from extended info - if (extResult.data && extResult.data instanceof Array) { - extResult.text = extResult.data[0]; - extResult.data = extResult.data[1].data; - } - - let ret = super.parse(extResult) as ParseResult; - - if (ret.resolutionStr && ret.resolutionStr.length > 0) { - if (!ret.resolutionStr.trim().endsWith("%")) { - ret.resolutionStr = ret.resolutionStr.trim() + "%"; - } - } - - ret.data = extResult.text; - ret.text = originText; - - return ret; - } -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-number/src/number/portuguese/extractors.ts b/JavaScript/packages/recognizers-number/src/number/portuguese/extractors.ts deleted file mode 100644 index c80269aae9..0000000000 --- a/JavaScript/packages/recognizers-number/src/number/portuguese/extractors.ts +++ /dev/null @@ -1,247 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { BaseNumberExtractor, RegExpValue, RegExpRegExp, BasePercentageExtractor } from "../extractors"; -import { Constants } from "../constants"; -import { NumberMode, LongFormatType } from "../models"; -import { PortugueseNumeric } from "../../resources/portugueseNumeric"; -import { BaseNumbers } from "../../resources/baseNumbers"; -import { RegExpUtility } from "@microsoft/recognizers-text"; - -export class PortugueseNumberExtractor extends BaseNumberExtractor { - protected extractType: string = Constants.SYS_NUM; - - constructor(mode: NumberMode = NumberMode.Default) { - super(); - let regexes = new Array(); - - // Add Cardinal - let cardExtract: PortugueseCardinalExtractor | null = null; - switch (mode) { - case NumberMode.PureNumber: - cardExtract = new PortugueseCardinalExtractor(PortugueseNumeric.PlaceHolderPureNumber); - break; - case NumberMode.Currency: - regexes.push({ regExp: RegExpUtility.getSafeRegExp(BaseNumbers.CurrencyRegex, "gs"), value: "IntegerNum" }); - break; - case NumberMode.Default: - break; - } - - if (cardExtract === null) { - cardExtract = new PortugueseCardinalExtractor(); - } - - cardExtract.regexes.forEach(r => regexes.push(r)); - - // Add Fraction - let fracExtract = new PortugueseFractionExtractor(mode); - fracExtract.regexes.forEach(r => regexes.push(r)); - - this.regexes = regexes; - - // Add filter - let ambiguityFiltersDict = new Array(); - - if (mode != NumberMode.Unit) { - for (let [ key, value ] of PortugueseNumeric.AmbiguityFiltersDict){ - ambiguityFiltersDict.push({ regExpKey: RegExpUtility.getSafeRegExp(key, "gs"), regExpValue: RegExpUtility.getSafeRegExp(value, "gs")}) - } - } - - this.ambiguityFiltersDict = ambiguityFiltersDict; - } -} - -export class PortugueseCardinalExtractor extends BaseNumberExtractor { - protected extractType: string = Constants.SYS_NUM_CARDINAL; - - constructor(placeholder: string = PortugueseNumeric.PlaceHolderDefault) { - super(); - let regexes = new Array(); - - // Add Integer Regexes - let intExtract = new PortugueseIntegerExtractor(placeholder); - intExtract.regexes.forEach(r => regexes.push(r)); - - // Add Double Regexes - let doubleExtract = new PortugueseDoubleExtractor(placeholder); - doubleExtract.regexes.forEach(r => regexes.push(r)); - - this.regexes = regexes; - } -} - -export class PortugueseIntegerExtractor extends BaseNumberExtractor { - protected extractType: string = Constants.SYS_NUM_INTEGER; - - constructor(placeholder: string = PortugueseNumeric.PlaceHolderDefault) { - super(); - - let regexes = new Array( - { - regExp: RegExpUtility.getSafeRegExp(PortugueseNumeric.NumbersWithPlaceHolder(placeholder), "gi"), - value: "IntegerNum" - }, - { - regExp: RegExpUtility.getSafeRegExp(PortugueseNumeric.NumbersWithSuffix, "gs"), - value: "IntegerNum" - }, - { - regExp: this.generateLongFormatNumberRegexes(LongFormatType.integerNumDot, placeholder), - value: "IntegerNum" - }, - { - regExp: this.generateLongFormatNumberRegexes(LongFormatType.integerNumBlank, placeholder), - value: "IntegerNum" - }, - { - regExp: this.generateLongFormatNumberRegexes(LongFormatType.integerNumNoBreakSpace, placeholder), - value: "IntegerNum" - }, - { - regExp: RegExpUtility.getSafeRegExp(PortugueseNumeric.RoundNumberIntegerRegexWithLocks), - value: "IntegerNum" - }, - { - regExp: RegExpUtility.getSafeRegExp(PortugueseNumeric.NumbersWithDozen2Suffix), - value: "IntegerNum" - }, - { - regExp: RegExpUtility.getSafeRegExp(PortugueseNumeric.NumbersWithDozenSuffix), - value: "IntegerNum" - }, - { - regExp: RegExpUtility.getSafeRegExp(PortugueseNumeric.AllIntRegexWithLocks), - value: "IntegerPor" - }, - { - regExp: RegExpUtility.getSafeRegExp(PortugueseNumeric.AllIntRegexWithDozenSuffixLocks), - value: "IntegerPor" - } - ); - - this.regexes = regexes; - } -} - -export class PortugueseDoubleExtractor extends BaseNumberExtractor { - protected extractType: string = Constants.SYS_NUM_DOUBLE; - - constructor(placeholder: string = PortugueseNumeric.PlaceHolderDefault) { - super(); - - let regexes = new Array( - { - regExp: RegExpUtility.getSafeRegExp(PortugueseNumeric.DoubleDecimalPointRegex(placeholder)), - value: "DoubleNum" - }, - { - regExp: RegExpUtility.getSafeRegExp(PortugueseNumeric.DoubleWithoutIntegralRegex(placeholder)), - value: "DoubleNum" - }, - { - regExp: RegExpUtility.getSafeRegExp(PortugueseNumeric.DoubleWithMultiplierRegex, "gs"), - value: "DoubleNum" - }, - { - regExp: RegExpUtility.getSafeRegExp(PortugueseNumeric.DoubleWithRoundNumber), - value: "DoubleNum" - }, - { - regExp: RegExpUtility.getSafeRegExp(PortugueseNumeric.DoubleAllFloatRegex), - value: "DoublePor" - }, - { - regExp: RegExpUtility.getSafeRegExp(PortugueseNumeric.DoubleExponentialNotationRegex), - value: "DoublePow" - }, - { - regExp: RegExpUtility.getSafeRegExp(PortugueseNumeric.DoubleCaretExponentialNotationRegex), - value: "DoublePow" - }, - { - regExp: this.generateLongFormatNumberRegexes(LongFormatType.doubleNumDotComma, placeholder), - value: "DoubleNum" - }, - { - regExp: this.generateLongFormatNumberRegexes(LongFormatType.doubleNumNoBreakSpaceComma, placeholder), - value: "DoubleNum" - } - ); - - this.regexes = regexes; - } -} - -export class PortugueseFractionExtractor extends BaseNumberExtractor { - - protected extractType: string = Constants.SYS_NUM_FRACTION; - - constructor(mode: NumberMode = NumberMode.Default) { - super(); - - let regexes = new Array( - { - regExp: RegExpUtility.getSafeRegExp(PortugueseNumeric.FractionNotationRegex), - value: "FracNum" - }, - { - regExp: RegExpUtility.getSafeRegExp(PortugueseNumeric.FractionNotationWithSpacesRegex), - value: "FracNum" - }, - { - regExp: RegExpUtility.getSafeRegExp(PortugueseNumeric.FractionNounRegex), - value: "FracPor" - }, - { - regExp: RegExpUtility.getSafeRegExp(PortugueseNumeric.FractionNounWithArticleRegex), - value: "FracPor" - } - ); - - // Not add FractionPrepositionRegex when the mode is Unit to avoid wrong recognize cases like "$1000 over 3" - if (mode != NumberMode.Unit) { - regexes.push({ - regExp: RegExpUtility.getSafeRegExp(PortugueseNumeric.FractionPrepositionRegex), - value: "FracPor" - }); - }; - - this.regexes = regexes; - } -} - -export class PortugueseOrdinalExtractor extends BaseNumberExtractor { - protected extractType: string = Constants.SYS_NUM_ORDINAL; - - constructor() { - super(); - let regexes = new Array( - { - regExp: RegExpUtility.getSafeRegExp(PortugueseNumeric.OrdinalSuffixRegex), - value: "OrdinalNum" - }, - { - regExp: RegExpUtility.getSafeRegExp(PortugueseNumeric.OrdinalEnglishRegex), - value: "OrdinalPor" - } - ); - - this.regexes = regexes; - } -} - -export class PortuguesePercentageExtractor extends BasePercentageExtractor { - constructor() { - super(new PortugueseNumberExtractor()); - } - - protected initRegexes(): RegExp[] { - let regexStrs = [ - PortugueseNumeric.NumberWithSuffixPercentage - ]; - - return this.buildRegexes(regexStrs); - } -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-number/src/number/portuguese/parserConfiguration.ts b/JavaScript/packages/recognizers-number/src/number/portuguese/parserConfiguration.ts deleted file mode 100644 index e7d355b4e1..0000000000 --- a/JavaScript/packages/recognizers-number/src/number/portuguese/parserConfiguration.ts +++ /dev/null @@ -1,134 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { ParseResult } from "@microsoft/recognizers-text"; -import { INumberParserConfiguration } from "../parsers"; -import { CultureInfo, Culture } from "../../culture"; -import { PortugueseNumeric } from "../../resources/portugueseNumeric"; -import { RegExpUtility } from "@microsoft/recognizers-text"; - -export class PortugueseNumberParserConfiguration implements INumberParserConfiguration { - - readonly cardinalNumberMap: ReadonlyMap; - readonly ordinalNumberMap: ReadonlyMap; - readonly roundNumberMap: ReadonlyMap; - readonly cultureInfo: CultureInfo; - readonly digitalNumberRegex: RegExp; - readonly fractionMarkerToken: string; - readonly negativeNumberSignRegex: RegExp; - readonly halfADozenRegex: RegExp; - readonly halfADozenText: string; - readonly langMarker: string; - readonly nonDecimalSeparatorChar: string; - readonly decimalSeparatorChar: string; - readonly wordSeparatorToken: string; - readonly writtenDecimalSeparatorTexts: readonly string[]; - readonly writtenGroupSeparatorTexts: readonly string[]; - readonly writtenIntegerSeparatorTexts: readonly string[]; - readonly writtenFractionSeparatorTexts: readonly string[]; - - constructor(ci?: CultureInfo) { - if (!ci) { - ci = new CultureInfo(Culture.Portuguese); - } - - this.cultureInfo = ci; - - this.langMarker = PortugueseNumeric.LangMarker; - this.decimalSeparatorChar = PortugueseNumeric.DecimalSeparatorChar; - this.fractionMarkerToken = PortugueseNumeric.FractionMarkerToken; - this.nonDecimalSeparatorChar = PortugueseNumeric.NonDecimalSeparatorChar; - this.halfADozenText = PortugueseNumeric.HalfADozenText; - this.wordSeparatorToken = PortugueseNumeric.WordSeparatorToken; - - this.writtenDecimalSeparatorTexts = PortugueseNumeric.WrittenDecimalSeparatorTexts; - this.writtenGroupSeparatorTexts = PortugueseNumeric.WrittenGroupSeparatorTexts; - this.writtenIntegerSeparatorTexts = PortugueseNumeric.WrittenIntegerSeparatorTexts; - this.writtenFractionSeparatorTexts = PortugueseNumeric.WrittenFractionSeparatorTexts; - - let ordinalNumberMap = new Map(PortugueseNumeric.OrdinalNumberMap); - - PortugueseNumeric.PrefixCardinalMap.forEach((prefixValue: number, prefixKey: string) => { - PortugueseNumeric.SuffixOrdinalMap.forEach((suffixValue: number, suffixKey: string) => { - if (!ordinalNumberMap.has(prefixKey + suffixKey)) { - ordinalNumberMap.set(prefixKey + suffixKey, prefixValue * suffixValue); - } - }); - }); - - this.cardinalNumberMap = PortugueseNumeric.CardinalNumberMap; - this.ordinalNumberMap = ordinalNumberMap; - this.roundNumberMap = PortugueseNumeric.RoundNumberMap; - this.negativeNumberSignRegex = RegExpUtility.getSafeRegExp(PortugueseNumeric.NegativeNumberSignRegex, "is"); - this.halfADozenRegex = RegExpUtility.getSafeRegExp(PortugueseNumeric.HalfADozenRegex); - this.digitalNumberRegex = RegExpUtility.getSafeRegExp(PortugueseNumeric.DigitalNumberRegex); - } - - normalizeTokenSet(tokens: readonly string[], context: ParseResult): readonly string[] { - let result = new Array(); - - tokens.forEach((token: string) => { - let tempWord = token.replace(/^s+/, '').replace(/s+$/, ''); - if (this.ordinalNumberMap.has(tempWord)) { - result.push(tempWord); - return; - } - - // ends with 'avo' or 'ava' - if (PortugueseNumeric.WrittenFractionSuffix.some(suffix => tempWord.endsWith(suffix))) { - let origTempWord = tempWord; - let newLength = origTempWord.length; - tempWord = origTempWord.substring(0, newLength - 3); - if (!tempWord) { - return; - } - else if (this.cardinalNumberMap.has(tempWord)) { - result.push(tempWord); - return; - } - else { - tempWord = origTempWord.substring(0, newLength - 2); - if (this.cardinalNumberMap.has(tempWord)) { - result.push(tempWord); - return; - } - } - } - - result.push(token); - }); - - return result; - } - - resolveCompositeNumber(numberStr: string): number { - if (this.ordinalNumberMap.has(numberStr)) { - return this.ordinalNumberMap.get(numberStr); - } - - if (this.cardinalNumberMap.has(numberStr)) { - return this.cardinalNumberMap.get(numberStr); - } - - let value = 0; - let finalValue = 0; - let strBuilder = ""; - let lastGoodChar = 0; - for (let i = 0; i < numberStr.length; i++) { - strBuilder = strBuilder.concat(numberStr[i]); - if (this.cardinalNumberMap.has(strBuilder) && this.cardinalNumberMap.get(strBuilder) > value) { - lastGoodChar = i; - value = this.cardinalNumberMap.get(strBuilder); - } - - if ((i + 1) === numberStr.length) { - finalValue += value; - strBuilder = ""; - i = lastGoodChar++; - value = 0; - } - } - - return finalValue; - } -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-number/src/number/spanish/extractors.ts b/JavaScript/packages/recognizers-number/src/number/spanish/extractors.ts deleted file mode 100644 index b4217dfec7..0000000000 --- a/JavaScript/packages/recognizers-number/src/number/spanish/extractors.ts +++ /dev/null @@ -1,243 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { BaseNumberExtractor, RegExpValue, RegExpRegExp, BasePercentageExtractor } from "../extractors"; -import { Constants } from "../constants"; -import { NumberMode, LongFormatType } from "../models"; -import { SpanishNumeric } from "../../resources/spanishNumeric"; -import { BaseNumbers } from "../../resources/baseNumbers"; -import { RegExpUtility } from "@microsoft/recognizers-text"; - -export class SpanishNumberExtractor extends BaseNumberExtractor { - protected extractType: string = Constants.SYS_NUM; - - constructor(mode: NumberMode = NumberMode.Default) { - super(); - let regexes = new Array(); - - // Add Cardinal - let cardExtract: SpanishCardinalExtractor | null = null; - switch (mode) { - case NumberMode.PureNumber: - cardExtract = new SpanishCardinalExtractor(SpanishNumeric.PlaceHolderPureNumber); - break; - case NumberMode.Currency: - regexes.push({ regExp: RegExpUtility.getSafeRegExp(BaseNumbers.CurrencyRegex, "gs"), value: "IntegerNum" }); - break; - case NumberMode.Default: - break; - } - - if (cardExtract === null) { - cardExtract = new SpanishCardinalExtractor(); - } - - cardExtract.regexes.forEach(r => regexes.push(r)); - - // Add Fraction - let fracExtract = new SpanishFractionExtractor(mode); - fracExtract.regexes.forEach(r => regexes.push(r)); - - this.regexes = regexes; - - // Add filter - let ambiguityFiltersDict = new Array(); - - if (mode != NumberMode.Unit) { - for (let [ key, value ] of SpanishNumeric.AmbiguityFiltersDict){ - ambiguityFiltersDict.push({ regExpKey: RegExpUtility.getSafeRegExp(key, "gs"), regExpValue: RegExpUtility.getSafeRegExp(value, "gs")}) - } - } - - this.ambiguityFiltersDict = ambiguityFiltersDict; - } -} - -export class SpanishCardinalExtractor extends BaseNumberExtractor { - protected extractType: string = Constants.SYS_NUM_CARDINAL; - - constructor(placeholder: string = SpanishNumeric.PlaceHolderDefault) { - super(); - let regexes = new Array(); - - // Add Integer Regexes - let intExtract = new SpanishIntegerExtractor(placeholder); - intExtract.regexes.forEach(r => regexes.push(r)); - - // Add Double Regexes - let doubleExtract = new SpanishDoubleExtractor(placeholder); - doubleExtract.regexes.forEach(r => regexes.push(r)); - - this.regexes = regexes; - } -} - -export class SpanishIntegerExtractor extends BaseNumberExtractor { - protected extractType: string = Constants.SYS_NUM_INTEGER; - - constructor(placeholder: string = SpanishNumeric.PlaceHolderDefault) { - super(); - - let regexes = new Array( - { - regExp: RegExpUtility.getSafeRegExp(SpanishNumeric.NumbersWithPlaceHolder(placeholder), "gi"), - value: "IntegerNum" - }, - { - regExp: RegExpUtility.getSafeRegExp(SpanishNumeric.NumbersWithSuffix, "gs"), - value: "IntegerNum" - }, - { - regExp: this.generateLongFormatNumberRegexes(LongFormatType.integerNumDot, placeholder), - value: "IntegerNum" - }, - { - regExp: this.generateLongFormatNumberRegexes(LongFormatType.integerNumBlank, placeholder), - value: "IntegerNum" - }, - { - regExp: this.generateLongFormatNumberRegexes(LongFormatType.integerNumNoBreakSpace, placeholder), - value: "IntegerNum" - }, - { - regExp: RegExpUtility.getSafeRegExp(SpanishNumeric.RoundNumberIntegerRegexWithLocks), - value: "IntegerNum" - }, - { - regExp: RegExpUtility.getSafeRegExp(SpanishNumeric.NumbersWithDozenSuffix), - value: "IntegerNum" - }, - { - regExp: RegExpUtility.getSafeRegExp(SpanishNumeric.AllIntRegexWithLocks), - value: "IntegerSpa" - }, - { - regExp: RegExpUtility.getSafeRegExp(SpanishNumeric.AllIntRegexWithDozenSuffixLocks), - value: "IntegerSpa" - } - ); - - this.regexes = regexes; - } -} - -export class SpanishDoubleExtractor extends BaseNumberExtractor { - protected extractType: string = Constants.SYS_NUM_DOUBLE; - - constructor(placeholder: string = SpanishNumeric.PlaceHolderDefault) { - super(); - - let regexes = new Array( - { - regExp: RegExpUtility.getSafeRegExp(SpanishNumeric.DoubleDecimalPointRegex(placeholder)), - value: "DoubleNum" - }, - { - regExp: RegExpUtility.getSafeRegExp(SpanishNumeric.DoubleWithoutIntegralRegex(placeholder)), - value: "DoubleNum" - }, - { - regExp: RegExpUtility.getSafeRegExp(SpanishNumeric.DoubleWithMultiplierRegex, "gs"), - value: "DoubleNum" - }, - { - regExp: RegExpUtility.getSafeRegExp(SpanishNumeric.DoubleWithRoundNumber), - value: "DoubleNum" - }, - { - regExp: RegExpUtility.getSafeRegExp(SpanishNumeric.DoubleAllFloatRegex), - value: "DoubleSpa" - }, - { - regExp: RegExpUtility.getSafeRegExp(SpanishNumeric.DoubleExponentialNotationRegex), - value: "DoublePow" - }, - { - regExp: RegExpUtility.getSafeRegExp(SpanishNumeric.DoubleCaretExponentialNotationRegex), - value: "DoublePow" - }, - { - regExp: this.generateLongFormatNumberRegexes(LongFormatType.doubleNumDotComma, placeholder), - value: "DoubleNum" - }, - { - regExp: this.generateLongFormatNumberRegexes(LongFormatType.doubleNumNoBreakSpaceComma, placeholder), - value: "DoubleNum" - } - ); - - this.regexes = regexes; - } -} - -export class SpanishFractionExtractor extends BaseNumberExtractor { - - protected extractType: string = Constants.SYS_NUM_FRACTION; - - constructor(mode: NumberMode = NumberMode.Default) { - super(); - - let regexes = new Array( - { - regExp: RegExpUtility.getSafeRegExp(SpanishNumeric.FractionNotationRegex), - value: "FracNum" - }, - { - regExp: RegExpUtility.getSafeRegExp(SpanishNumeric.FractionNotationWithSpacesRegex), - value: "FracNum" - }, - { - regExp: RegExpUtility.getSafeRegExp(SpanishNumeric.FractionNounRegex), - value: "FracSpa" - }, - { - regExp: RegExpUtility.getSafeRegExp(SpanishNumeric.FractionNounWithArticleRegex), - value: "FracSpa" - } - ); - - // Not add FractionPrepositionRegex when the mode is Unit to avoid wrong recognize cases like "$1000 over 3" - if (mode != NumberMode.Unit) { - regexes.push({ - regExp: RegExpUtility.getSafeRegExp(SpanishNumeric.FractionPrepositionRegex), - value: "FracSpa" - }); - }; - - this.regexes = regexes; - } -} - -export class SpanishOrdinalExtractor extends BaseNumberExtractor { - protected extractType: string = Constants.SYS_NUM_ORDINAL; - - constructor() { - super(); - let regexes = new Array( - { - regExp: RegExpUtility.getSafeRegExp(SpanishNumeric.OrdinalSuffixRegex), - value: "OrdinalNum" - }, - { - regExp: RegExpUtility.getSafeRegExp(SpanishNumeric.OrdinalNounRegex), - value: "OrdSpa" - } - ); - - this.regexes = regexes; - } -} - -export class SpanishPercentageExtractor extends BasePercentageExtractor { - constructor() { - super(new SpanishNumberExtractor()); - } - - protected initRegexes(): RegExp[] { - let regexStrs = [ - SpanishNumeric.NumberWithPrefixPercentage - ]; - - return this.buildRegexes(regexStrs); - } -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-number/src/number/spanish/parserConfiguration.ts b/JavaScript/packages/recognizers-number/src/number/spanish/parserConfiguration.ts deleted file mode 100644 index dfce70fc58..0000000000 --- a/JavaScript/packages/recognizers-number/src/number/spanish/parserConfiguration.ts +++ /dev/null @@ -1,128 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { ParseResult } from "@microsoft/recognizers-text"; -import { INumberParserConfiguration } from "../parsers"; -import { CultureInfo, Culture } from "../../culture"; -import { SpanishNumeric } from "../../resources/spanishNumeric"; -import { RegExpUtility } from "@microsoft/recognizers-text"; - -export class SpanishNumberParserConfiguration implements INumberParserConfiguration { - - readonly cardinalNumberMap: ReadonlyMap; - readonly ordinalNumberMap: ReadonlyMap; - readonly roundNumberMap: ReadonlyMap; - readonly cultureInfo: CultureInfo; - readonly digitalNumberRegex: RegExp; - readonly fractionMarkerToken: string; - readonly negativeNumberSignRegex: RegExp; - readonly halfADozenRegex: RegExp; - readonly halfADozenText: string; - readonly langMarker: string; - readonly nonDecimalSeparatorChar: string; - readonly decimalSeparatorChar: string; - readonly wordSeparatorToken: string; - readonly writtenDecimalSeparatorTexts: readonly string[]; - readonly writtenGroupSeparatorTexts: readonly string[]; - readonly writtenIntegerSeparatorTexts: readonly string[]; - readonly writtenFractionSeparatorTexts: readonly string[]; - - constructor(ci?: CultureInfo) { - if (!ci) { - ci = new CultureInfo(Culture.Spanish); - } - - this.cultureInfo = ci; - - this.langMarker = SpanishNumeric.LangMarker; - this.decimalSeparatorChar = SpanishNumeric.DecimalSeparatorChar; - this.fractionMarkerToken = SpanishNumeric.FractionMarkerToken; - this.nonDecimalSeparatorChar = SpanishNumeric.NonDecimalSeparatorChar; - this.halfADozenText = SpanishNumeric.HalfADozenText; - this.wordSeparatorToken = SpanishNumeric.WordSeparatorToken; - - this.writtenDecimalSeparatorTexts = SpanishNumeric.WrittenDecimalSeparatorTexts; - this.writtenGroupSeparatorTexts = SpanishNumeric.WrittenGroupSeparatorTexts; - this.writtenIntegerSeparatorTexts = SpanishNumeric.WrittenIntegerSeparatorTexts; - this.writtenFractionSeparatorTexts = SpanishNumeric.WrittenFractionSeparatorTexts; - - let ordinalNumberMap = new Map(SpanishNumeric.OrdinalNumberMap); - - SpanishNumeric.PrefixCardinalMap.forEach((prefixValue: number, prefixKey: string) => { - SpanishNumeric.SuffixOrdinalMap.forEach((suffixValue: number, suffixKey: string) => { - if (!ordinalNumberMap.has(prefixKey + suffixKey)) { - ordinalNumberMap.set(prefixKey + suffixKey, prefixValue * suffixValue); - } - }); - }); - - this.cardinalNumberMap = SpanishNumeric.CardinalNumberMap; - this.ordinalNumberMap = ordinalNumberMap; - this.roundNumberMap = SpanishNumeric.RoundNumberMap; - this.negativeNumberSignRegex = RegExpUtility.getSafeRegExp(SpanishNumeric.NegativeNumberSignRegex, "is"); - this.halfADozenRegex = RegExpUtility.getSafeRegExp(SpanishNumeric.HalfADozenRegex); - this.digitalNumberRegex = RegExpUtility.getSafeRegExp(SpanishNumeric.DigitalNumberRegex); - } - - normalizeTokenSet(tokens: readonly string[], context: ParseResult): readonly string[] { - let result = new Array(); - - tokens.forEach((token: string) => { - let tempWord = token.replace(/^s+/, '').replace(/s+$/, ''); - if (this.ordinalNumberMap.has(tempWord)) { - result.push(tempWord); - return; - } - - if (tempWord.endsWith("avo") || tempWord.endsWith("ava")) { - let origTempWord = tempWord; - let newLength = origTempWord.length; - tempWord = origTempWord.substring(0, newLength - 3); - if (this.cardinalNumberMap.has(tempWord)) { - result.push(tempWord); - return; - } - else { - tempWord = origTempWord.substring(0, newLength - 2); - if (this.cardinalNumberMap.has(tempWord)) { - result.push(tempWord); - return; - } - } - } - - result.push(token); - }); - - return result; - } - - resolveCompositeNumber(numberStr: string): number { - if (this.ordinalNumberMap.has(numberStr)) { - return this.ordinalNumberMap.get(numberStr); - } - - if (this.cardinalNumberMap.has(numberStr)) { - return this.cardinalNumberMap.get(numberStr); - } - - let value = 0; - let finalValue = 0; - let strBuilder = ""; - let lastGoodChar = 0; - for (let i = 0; i < numberStr.length; i++) { - strBuilder = strBuilder.concat(numberStr[i]); - if (this.cardinalNumberMap.has(strBuilder) && this.cardinalNumberMap.get(strBuilder) > value) { - lastGoodChar = i; - value = this.cardinalNumberMap.get(strBuilder); - } - if ((i + 1) === numberStr.length) { - finalValue += value; - strBuilder = ""; - i = lastGoodChar++; - value = 0; - } - } - return finalValue; - } -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-number/src/recognizers-text-number.ts b/JavaScript/packages/recognizers-number/src/recognizers-text-number.ts deleted file mode 100644 index 6b71fa5dd3..0000000000 --- a/JavaScript/packages/recognizers-number/src/recognizers-text-number.ts +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -export { default as NumberRecognizer, NumberOptions, recognizeNumber, recognizeOrdinal, recognizePercentage } from "./number/numberRecognizer"; -export { Culture, CultureInfo } from "./culture"; -export { QueryProcessor, StringUtility, Match, RegExpUtility } from "@microsoft/recognizers-text"; -export { BaseNumbers } from "./resources/baseNumbers"; -export { EnglishNumeric } from "./resources/englishNumeric"; -export { SpanishNumeric } from "./resources/spanishNumeric"; -export { FrenchNumeric } from "./resources/frenchNumeric"; -export { ChineseNumeric } from "./resources/chineseNumeric"; -export { JapaneseNumeric } from "./resources/japaneseNumeric"; -export { Constants } from "./number/constants"; -export { RegExpValue, BaseNumberExtractor, BasePercentageExtractor } from "./number/extractors"; -export { NumberMode, LongFormatType, AbstractNumberModel, NumberModel, OrdinalModel, PercentModel } from "./number/models"; -export { AgnosticNumberParserType, AgnosticNumberParserFactory } from "./number/agnosticNumberParser"; -export { INumberParserConfiguration, BaseNumberParser, BasePercentageParser } from "./number/parsers"; -export { EnglishCardinalExtractor, EnglishDoubleExtractor, EnglishFractionExtractor, EnglishIntegerExtractor, EnglishNumberExtractor, EnglishOrdinalExtractor, EnglishPercentageExtractor } from "./number/english/extractors"; -export { EnglishNumberParserConfiguration } from "./number/english/parserConfiguration"; -export { SpanishCardinalExtractor, SpanishDoubleExtractor, SpanishFractionExtractor, SpanishIntegerExtractor, SpanishNumberExtractor, SpanishOrdinalExtractor, SpanishPercentageExtractor } from "./number/spanish/extractors"; -export { SpanishNumberParserConfiguration } from "./number/spanish/parserConfiguration"; -export { PortugueseCardinalExtractor, PortugueseDoubleExtractor, PortugueseFractionExtractor, PortugueseIntegerExtractor, PortugueseNumberExtractor, PortugueseOrdinalExtractor, PortuguesePercentageExtractor } from "./number/portuguese/extractors"; -export { PortugueseNumberParserConfiguration } from "./number/portuguese/parserConfiguration"; -export { FrenchCardinalExtractor, FrenchDoubleExtractor, FrenchFractionExtractor, FrenchIntegerExtractor, FrenchNumberExtractor, FrenchOrdinalExtractor, FrenchPercentageExtractor } from "./number/french/extractors"; -export { FrenchNumberParserConfiguration } from "./number/french/parserConfiguration"; -export { ChineseCardinalExtractor, ChineseDoubleExtractor, ChineseFractionExtractor, ChineseIntegerExtractor, ChineseNumberExtractor, ChineseOrdinalExtractor, ChinesePercentageExtractor, ChineseNumberExtractorMode } from "./number/chinese/extractors"; -export { ChineseNumberParserConfiguration } from "./number/chinese/parserConfiguration"; -export { JapaneseCardinalExtractor, JapaneseDoubleExtractor, JapaneseFractionExtractor, JapaneseIntegerExtractor, JapaneseNumberExtractor, JapaneseOrdinalExtractor, JapanesePercentageExtractor, JapaneseNumberExtractorMode } from "./number/japanese/extractors"; -export { JapaneseNumberParserConfiguration } from "./number/japanese/parserConfiguration"; \ No newline at end of file diff --git a/JavaScript/packages/recognizers-number/src/resources/baseNumbers.ts b/JavaScript/packages/recognizers-number/src/resources/baseNumbers.ts deleted file mode 100644 index 543c2ab786..0000000000 --- a/JavaScript/packages/recognizers-number/src/resources/baseNumbers.ts +++ /dev/null @@ -1,25 +0,0 @@ -// ------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// ------------------------------------------------------------------------------ - -export namespace BaseNumbers { - export const NumberReplaceToken = `@builtin.num`; - export const FractionNumberReplaceToken = `@builtin.num.fraction`; - export const IntegerRegexDefinition = (placeholder: string, thousandsmark: string) => { return `(((? { return `(((? -// This code was generated by a tool. -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// ------------------------------------------------------------------------------ - -import { BaseNumbers } from "./baseNumbers"; -export namespace ChineseNumeric { - export const LangMarker = `Chi`; - export const CompoundNumberLanguage = true; - export const MultiDecimalSeparatorCulture = false; - export const DecimalSeparatorChar = `.`; - export const FractionMarkerToken = ``; - export const NonDecimalSeparatorChar = ` `; - export const HalfADozenText = ``; - export const WordSeparatorToken = ``; - export const ZeroChar = `零`; - export const PairChar = `对`; - export const RoundNumberMap: ReadonlyMap = new Map([["k", 1000],["m", 1000000],["g", 1000000000],["t", 1000000000000]]); - export const RoundNumberMapChar: ReadonlyMap = new Map([["十", 10],["百", 100],["千", 1000],["万", 10000],["亿", 100000000],["兆", 1000000000000],["拾", 10],["佰", 100],["仟", 1000],["萬", 10000],["億", 100000000]]); - export const ZeroToNineMap: ReadonlyMap = new Map([["0", 0],["1", 1],["2", 2],["3", 3],["4", 4],["5", 5],["6", 6],["7", 7],["8", 8],["9", 9],["零", 0],["一", 1],["二", 2],["三", 3],["四", 4],["五", 5],["六", 6],["七", 7],["八", 8],["九", 9],["〇", 0],["壹", 1],["贰", 2],["貳", 2],["叁", 3],["肆", 4],["伍", 5],["陆", 6],["陸", 6],["柒", 7],["捌", 8],["玖", 9],["0", 0],["1", 1],["2", 2],["3", 3],["4", 4],["5", 5],["6", 6],["7", 7],["8", 8],["9", 9],["半", 0.5],["两", 2],["兩", 2],["俩", 2],["倆", 2],["仨", 3]]); - export const FullToHalfMap: ReadonlyMap = new Map([["0", "0"],["1", "1"],["2", "2"],["3", "3"],["4", "4"],["5", "5"],["6", "6"],["7", "7"],["8", "8"],["9", "9"],["/", "/"],["-", "-"],[",", "'"],["G", "G"],["M", "M"],["T", "T"],["K", "K"],["k", "k"],[".", "."]]); - export const TratoSimMap: ReadonlyMap = new Map([["佰", "百"],["點", "点"],["個", "个"],["幾", "几"],["對", "对"],["雙", "双"]]); - export const UnitMap: ReadonlyMap = new Map([["萬萬", "億"],["億萬", "兆"],["萬億", "兆"],["万万", "亿"],["万亿", "兆"],["亿万", "兆"],[" ", ""],["多", ""],["余", ""],["几", ""]]); - export const RoundDirectList = [ "亿","兆","億" ]; - export const TenChars = [ "十","拾" ]; - export const DigitalNumberRegex = `((?<=(\\d|\\b))${BaseNumbers.MultiplierLookupRegex}(?=\\b))`; - export const ZeroToNineFullHalfRegex = `[\\d]`; - export const DigitNumRegex = `${ZeroToNineFullHalfRegex}+`; - export const DozenRegex = `.*打$`; - export const PercentageRegex = `(?<=(((?)`; - export const LessRegex = `(小于|少于|低于|小於|少於|低於|不到|不足|<)`; - export const EqualRegex = `(等于|等於|=)`; - export const MoreOrEqual = `((${MoreRegex}\\s*(或|或者)?\\s*${EqualRegex})|(至少|最少)${SpeicalCharBeforeNumber}?|不${LessRegex}|≥)`; - export const MoreOrEqualSuffix = `(或|或者)\\s*(次?以上|之上|更[大多高])`; - export const LessOrEqual = `((${LessRegex}\\s*(或|或者)?\\s*${EqualRegex})|(至多|最多)${SpeicalCharBeforeNumber}?|不${MoreRegex}|≤)`; - export const LessOrEqualSuffix = `(或|或者)\\s*(以下|之下|更[小少低])`; - export const OneNumberRangeMoreRegex1 = `(${MoreOrEqual}|${MoreRegex})\\s*(?((?!([并且而並的同時时]|([,,](?!\\d+))|。)).)+)`; - export const OneNumberRangeMoreRegex2 = `比\\s*(?((?!(([,,](?!\\d+))|。)).)+)\\s*更?[大多高]`; - export const OneNumberRangeMoreRegex3 = `(?((?!(([,,](?!\\d+))|。|[或者])).)+)\\s*(或|或者)?\\s*([多几余幾餘]|次?以上|之上|更[大多高])([万亿萬億]{0,2})`; - export const OneNumberRangeLessRegex1 = `(${LessOrEqual}|${LessRegex})\\s*(?((?!([并且而並的同時时]|([,,](?!\\d+))|。)).)+)`; - export const OneNumberRangeLessRegex2 = `比\\s*(?((?!(([,,](?!\\d+))|。)).)+)\\s*更?[小少低]`; - export const OneNumberRangeLessRegex3 = `(?((?!(([,,](?!\\d+))|。|[或者])).)+)\\s*(或|或者)?\\s*(以下|之下|更[小少低])`; - export const OneNumberRangeMoreSeparateRegex = `^[.]`; - export const OneNumberRangeLessSeparateRegex = `^[.]`; - export const OneNumberRangeEqualRegex = `${EqualRegex}\\s*(?((?!(([,,](?!\\d+))|。)).)+)`; - export const TwoNumberRangeRegex1 = `((位于|在|位於)|(?=(\\d|\\+|\\-)))\\s*(?((?!(([,,](?!\\d+))|。)).)+)\\s*(和|与|與|${TillRegex})\\s*(?((?!(([,,](?!\\d+))|。))[^之])+)\\s*(之)?(间|間)`; - export const TwoNumberRangeRegex2 = `(${OneNumberRangeMoreRegex1}|${OneNumberRangeMoreRegex2}|${OneNumberRangeMoreRegex3})\\s*(且|(并|並)且?|而且|((的)?同時)|((的)?同时)|[,,])?\\s*(${OneNumberRangeLessRegex1}|${OneNumberRangeLessRegex2}|${OneNumberRangeLessRegex3})`; - export const TwoNumberRangeRegex3 = `(${OneNumberRangeLessRegex1}|${OneNumberRangeLessRegex2}|${OneNumberRangeLessRegex3})\\s*(且|(并|並)且?|而且|((的)?同時)|((的)?同时)|[,,])?\\s*(${OneNumberRangeMoreRegex1}|${OneNumberRangeMoreRegex2}|${OneNumberRangeMoreRegex3})`; - export const TwoNumberRangeRegex4 = `(?((?!(([,,](?!\\d+))|。)).)+)\\s*${TillRegex}\\s*(?((?!(([,,](?!\\d+))|。)).)+)`; - export const AmbiguityFiltersDict: ReadonlyMap = new Map([["十", "十足"],["伍", "队伍"],["肆", "放肆|肆意|肆无忌惮"],["陆", "大陆|陆地|登陆|海陆"],["拾", "拾取|拾起|收拾|拾到|朝花夕拾"]]); - export const AmbiguousFractionConnectorsRegex = `^[.]`; - export const RelativeReferenceOffsetMap: ReadonlyMap = new Map([["", ""]]); - export const RelativeReferenceRelativeToMap: ReadonlyMap = new Map([["", ""]]); -} diff --git a/JavaScript/packages/recognizers-number/src/resources/englishNumeric.ts b/JavaScript/packages/recognizers-number/src/resources/englishNumeric.ts deleted file mode 100644 index b6b37dd350..0000000000 --- a/JavaScript/packages/recognizers-number/src/resources/englishNumeric.ts +++ /dev/null @@ -1,118 +0,0 @@ -// ------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// ------------------------------------------------------------------------------ - -import { BaseNumbers } from "./baseNumbers"; -export namespace EnglishNumeric { - export const LangMarker = `Eng`; - export const CompoundNumberLanguage = false; - export const MultiDecimalSeparatorCulture = true; - export const NonStandardSeparatorVariants = [ "en-za","en-na","en-zw" ]; - export const RoundNumberIntegerRegex = `(?:hundred|thousand|million|mln|billion|bln|trillion|tln|lakh|crore)s?`; - export const ZeroToNineIntegerRegex = `(?:three|seven|eight|four|five|zero|n[ao]ught|nine|one|two|six)`; - export const TwoToNineIntegerRegex = `(?:three|seven|eight|four|five|nine|two|six)`; - export const NegativeNumberTermsRegex = `(?(minus|negative)\\s+)`; - export const NegativeNumberSignRegex = `^${NegativeNumberTermsRegex}.*`; - export const AnIntRegex = `(an?)(?=\\s)`; - export const TenToNineteenIntegerRegex = `(?:seventeen|thirteen|fourteen|eighteen|nineteen|fifteen|sixteen|eleven|twelve|ten)`; - export const TensNumberIntegerRegex = `(?:seventy|twenty|thirty|eighty|ninety|forty|fifty|sixty)`; - export const SeparaIntRegex = `(?:((${TenToNineteenIntegerRegex}|(${TensNumberIntegerRegex}(\\s+(and\\s+)?|\\s*-\\s*)${ZeroToNineIntegerRegex})|${TensNumberIntegerRegex}|${ZeroToNineIntegerRegex})(\\s+${RoundNumberIntegerRegex})*))|((${AnIntRegex}(\\s+${RoundNumberIntegerRegex})+))`; - export const AllIntRegex = `(?:(((${TenToNineteenIntegerRegex}|(${TensNumberIntegerRegex}(\\s+(and\\s+)?|\\s*-\\s*)${ZeroToNineIntegerRegex})|${TensNumberIntegerRegex}|${ZeroToNineIntegerRegex}|${AnIntRegex})(\\s+${RoundNumberIntegerRegex})+)\\s+(and\\s+)?)*${SeparaIntRegex})`; - export const PlaceHolderPureNumber = `\\b`; - export const PlaceHolderDefault = `(?=\\D)|\\b`; - export const PlaceHolderMixed = `\\D|\\b`; - export const NumbersWithPlaceHolder = (placeholder: string) => { return `(((?(next|previous|current)\\s+one|(the\\s+second|next)\\s+to\\s+last|the\\s+one\\s+before\\s+the\\s+last(\\s+one)?|the\\s+last\\s+but\\s+one|(ante)?penultimate|last|next|previous|current)`; - export const SuffixBasicOrdinalRegex = `(?:((((${TensNumberIntegerRegex}(\\s+(and\\s+)?|\\s*-\\s*)${ZeroToNineIntegerRegex})|${TensNumberIntegerRegex}|${ZeroToNineIntegerRegex}|${AnIntRegex})(\\s+${RoundNumberIntegerRegex})+)\\s+(and\\s+)?)*(${TensNumberIntegerRegex}(\\s+|\\s*-\\s*))?${NumberOrdinalRegex})`; - export const SuffixRoundNumberOrdinalRegex = `(?:(${AllIntRegex}\\s+)${RoundNumberOrdinalRegex})`; - export const AllOrdinalNumberRegex = `(?:${SuffixBasicOrdinalRegex}|${SuffixRoundNumberOrdinalRegex})`; - export const AllOrdinalRegex = `(?:${AllOrdinalNumberRegex}|${RelativeOrdinalRegex})`; - export const OrdinalSuffixRegex = `(?<=\\b)(?:(\\d*(1st|2nd|3rd|[4-90]th))|(1[1-2]th))(?=\\b)`; - export const OrdinalNumericRegex = `(?<=\\b)(?:\\d{1,3}(\\s*,\\s*\\d{3})*\\s*th)(?=\\b)`; - export const OrdinalRoundNumberRegex = `(?\\s+and\\s+(a|one|${TwoToNineIntegerRegex})\\s+(half|quarter|third|fourth|fifth|sixth|seventh|eighth|nine?th|tenth)s?)`; - export const RoundMultiplierWithFraction = `(?<=(?(?:million|mln|billion|bln|trillion|tln)s?)(?=${FractionMultiplierRegex}?$)`; - export const RoundMultiplierRegex = `\\b\\s*((of\\s+)?a\\s+)?(${RoundMultiplierWithFraction}|(?(?:hundred|thousand|lakh|crore)s?)$)`; - export const FractionNounRegex = `(?<=\\b)(${AllIntRegex}\\s+(and\\s+)?)?((${AllIntRegex})(\\s+|\\s*-\\s*)(((${AllOrdinalNumberRegex})|(${RoundNumberOrdinalRegex}))s|halves|quarters)((\\s+of\\s+a)?\\s+${RoundNumberIntegerRegex})?|(half(\\s+a)?|quarter(\\s+of\\s+a)?)\\s+${RoundNumberIntegerRegex})(?=\\b)`; - export const FractionNounWithArticleRegex = `(?<=\\b)((((${AllIntRegex}|${RoundNumberIntegerRegexWithLocks})\\s+(and\\s+)?)?(an?|one)(\\s+|\\s*-\\s*)(?!\\bfirst\\b|\\bsecond\\b)((${AllOrdinalNumberRegex})|(${RoundNumberOrdinalRegex})|(half|quarter)(((\\s+of)?\\s+a)?\\s+${RoundNumberIntegerRegex})?))|(half))(?=\\b)`; - export const FractionPrepositionRegex = `(?(${AllIntRegex})|((?in|out\\s+of))\\s+(?(${AllIntRegex})|(\\d+)(?![\\.,]))(?=\\b)`; - export const FractionPrepositionWithinPercentModeRegex = `(?(${AllIntRegex})|((?(${AllIntRegex})|(\\d+)(?![\\.,]))(?=\\b)`; - export const AllPointRegex = `((\\s+${ZeroToNineIntegerRegex})+|(\\s+${SeparaIntRegex}))`; - export const AllFloatRegex = `${AllIntRegex}(\\s+point)${AllPointRegex}`; - export const DoubleWithMultiplierRegex = `(((? { return `(((? { return `(?<=\\s|^)(?and)`; - export const NumberWithSuffixPercentage = `(?)`; - export const LessRegex = `(?:(less|lower|smaller|fewer)(\\s+than)?|below|under|(?|=)<)`; - export const EqualRegex = `(equal(s|ing)?(\\s+(to|than))?|(?)=)`; - export const MoreOrEqualPrefix = `((no\\s+${LessRegex})|(at\\s+least))`; - export const MoreOrEqual = `(?:(${MoreRegex}\\s+(or)?\\s+${EqualRegex})|(${EqualRegex}\\s+(or)?\\s+${MoreRegex})|${MoreOrEqualPrefix}(\\s+(or)?\\s+${EqualRegex})?|(${EqualRegex}\\s+(or)?\\s+)?${MoreOrEqualPrefix}|>\\s*=|≥)`; - export const MoreOrEqualSuffix = `((and|or)\\s+(((more|greater|higher|larger|bigger)((?!\\s+than)|(\\s+than(?!((\\s+or\\s+equal\\s+to)?\\s*\\d+)))))|((over|above)(?!\\s+than))))`; - export const LessOrEqualPrefix = `((no\\s+${MoreRegex})|(at\\s+most)|(up\\s+to))`; - export const LessOrEqual = `((${LessRegex}\\s+(or)?\\s+${EqualRegex})|(${EqualRegex}\\s+(or)?\\s+${LessRegex})|${LessOrEqualPrefix}(\\s+(or)?\\s+${EqualRegex})?|(${EqualRegex}\\s+(or)?\\s+)?${LessOrEqualPrefix}|<\\s*=|≤)`; - export const LessOrEqualSuffix = `((and|or)\\s+(less|lower|smaller|fewer)((?!\\s+than)|(\\s+than(?!(\\s*\\d+)))))`; - export const NumberSplitMark = `(?![,.](?!\\d+))(?!\\s*\\b(and\\s+(${LessRegex}|${MoreRegex})|but|or|to)\\b)`; - export const MoreRegexNoNumberSucceed = `((bigger|greater|more|higher|larger)((?!\\s+than)|\\s+(than(?!(\\s*\\d+))))|(above|over)(?!(\\s*\\d+)))`; - export const LessRegexNoNumberSucceed = `((less|lower|smaller|fewer)((?!\\s+than)|\\s+(than(?!(\\s*\\d+))))|(below|under)(?!(\\s*\\d+)))`; - export const EqualRegexNoNumberSucceed = `(equal(s|ing)?((?!\\s+(to|than))|(\\s+(to|than)(?!(\\s*\\d+)))))`; - export const OneNumberRangeMoreRegex1 = `(${MoreOrEqual}|${MoreRegex})\\s*(the\\s+)?(?(${NumberSplitMark}.)+)`; - export const OneNumberRangeMoreRegex1LB = `(?(${NumberSplitMark}.)+)\\s*${MoreOrEqualSuffix}`; - export const OneNumberRangeMoreSeparateRegex = `(${EqualRegex}\\s+(?(${NumberSplitMark}.)+)(\\s+or\\s+)${MoreRegexNoNumberSucceed})|(${MoreRegex}\\s+(?(${NumberSplitMark}.)+)(\\s+or\\s+)${EqualRegexNoNumberSucceed})`; - export const OneNumberRangeLessRegex1 = `(${LessOrEqual}|${LessRegex})\\s*(the\\s+)?(?(${NumberSplitMark}.)+)`; - export const OneNumberRangeLessRegex1LB = `(?(${NumberSplitMark}.)+)\\s*${LessOrEqualSuffix}`; - export const OneNumberRangeLessSeparateRegex = `(${EqualRegex}\\s+(?(${NumberSplitMark}.)+)(\\s+or\\s+)${LessRegexNoNumberSucceed})|(${LessRegex}\\s+(?(${NumberSplitMark}.)+)(\\s+or\\s+)${EqualRegexNoNumberSucceed})`; - export const OneNumberRangeEqualRegex = `(?(${NumberSplitMark}.)+)`; - export const TwoNumberRangeRegex1 = `between\\s*(the\\s+)?(?(${NumberSplitMark}.)+)\\s*and\\s*(the\\s+)?(?(${NumberSplitMark}.)+)`; - export const TwoNumberRangeRegex2 = `(${OneNumberRangeMoreRegex1}|${OneNumberRangeMoreRegex2})\\s*(and|but|,)\\s*(${OneNumberRangeLessRegex1}|${OneNumberRangeLessRegex2})`; - export const TwoNumberRangeRegex3 = `(${OneNumberRangeLessRegex1}|${OneNumberRangeLessRegex2})\\s*(and|but|,)\\s*(${OneNumberRangeMoreRegex1}|${OneNumberRangeMoreRegex2})`; - export const TwoNumberRangeRegex4 = `(from\\s+)?(?(${NumberSplitMark}(?!\\bfrom\\b).)+)\\s*${TillRegex}\\s*(the\\s+)?(?(${NumberSplitMark}.)+)`; - export const AmbiguousFractionConnectorsRegex = `(\\bin\\b)`; - export const DecimalSeparatorChar = `.`; - export const FractionMarkerToken = `over`; - export const NonDecimalSeparatorChar = `,`; - export const HalfADozenText = `six`; - export const WordSeparatorToken = `and`; - export const WrittenDecimalSeparatorTexts = [ "point" ]; - export const WrittenGroupSeparatorTexts = [ "punto" ]; - export const WrittenIntegerSeparatorTexts = [ "and" ]; - export const WrittenFractionSeparatorTexts = [ "and" ]; - export const HalfADozenRegex = `half\\s+a\\s+dozen`; - export const DigitalNumberRegex = `((?<=\\b)(hundred|thousand|[mb]illion|trillion|[mbt]ln|lakh|crore|(doz(en)?|dz)s?)(?=\\b))|((?<=(\\d|\\b))${BaseNumbers.MultiplierLookupRegex}(?=\\b))`; - export const CardinalNumberMap: ReadonlyMap = new Map([["a", 1],["zero", 0],["naught", 0],["nought", 0],["an", 1],["one", 1],["two", 2],["three", 3],["four", 4],["five", 5],["six", 6],["seven", 7],["eight", 8],["nine", 9],["ten", 10],["eleven", 11],["twelve", 12],["dozen", 12],["dozens", 12],["dz", 12],["doz", 12],["dzs", 12],["dozs", 12],["thirteen", 13],["fourteen", 14],["fifteen", 15],["sixteen", 16],["seventeen", 17],["eighteen", 18],["nineteen", 19],["twenty", 20],["thirty", 30],["forty", 40],["fifty", 50],["sixty", 60],["seventy", 70],["eighty", 80],["ninety", 90],["hundred", 100],["thousand", 1000],["million", 1000000],["mln", 1000000],["billion", 1000000000],["bln", 1000000000],["trillion", 1000000000000],["tln", 1000000000000],["lakh", 100000],["crore", 10000000],["hundreds", 100],["thousands", 1000],["millions", 1000000],["billions", 1000000000],["trillions", 1000000000000],["lakhs", 100000],["crores", 10000000]]); - export const OrdinalNumberMap: ReadonlyMap = new Map([["first", 1],["second", 2],["secondary", 2],["half", 2],["third", 3],["fourth", 4],["quarter", 4],["fifth", 5],["sixth", 6],["seventh", 7],["eighth", 8],["ninth", 9],["nineth", 9],["tenth", 10],["eleventh", 11],["twelfth", 12],["thirteenth", 13],["fourteenth", 14],["fifteenth", 15],["sixteenth", 16],["seventeenth", 17],["eighteenth", 18],["nineteenth", 19],["twentieth", 20],["thirtieth", 30],["fortieth", 40],["fiftieth", 50],["sixtieth", 60],["seventieth", 70],["eightieth", 80],["ninetieth", 90],["hundredth", 100],["thousandth", 1000],["millionth", 1000000],["billionth", 1000000000],["trillionth", 1000000000000],["firsts", 1],["halves", 2],["thirds", 3],["fourths", 4],["quarters", 4],["fifths", 5],["sixths", 6],["sevenths", 7],["eighths", 8],["ninths", 9],["nineths", 9],["tenths", 10],["elevenths", 11],["twelfths", 12],["thirteenths", 13],["fourteenths", 14],["fifteenths", 15],["sixteenths", 16],["seventeenths", 17],["eighteenths", 18],["nineteenths", 19],["twentieths", 20],["thirtieths", 30],["fortieths", 40],["fiftieths", 50],["sixtieths", 60],["seventieths", 70],["eightieths", 80],["ninetieths", 90],["hundredths", 100],["thousandths", 1000],["millionths", 1000000],["billionths", 1000000000],["trillionths", 1000000000000]]); - export const RoundNumberMap: ReadonlyMap = new Map([["hundred", 100],["thousand", 1000],["million", 1000000],["mln", 1000000],["billion", 1000000000],["bln", 1000000000],["trillion", 1000000000000],["tln", 1000000000000],["lakh", 100000],["crore", 10000000],["hundreds", 100],["thousands", 1000],["millions", 1000000],["billions", 1000000000],["trillions", 1000000000000],["lakhs", 100000],["crores", 10000000],["hundredth", 100],["thousandth", 1000],["millionth", 1000000],["billionth", 1000000000],["trillionth", 1000000000000],["hundredths", 100],["thousandths", 1000],["millionths", 1000000],["billionths", 1000000000],["trillionths", 1000000000000],["dozen", 12],["dozens", 12],["dz", 12],["doz", 12],["dzs", 12],["dozs", 12],["k", 1000],["m", 1000000],["mm", 1000000],["mil", 1000000],["g", 1000000000],["b", 1000000000],["t", 1000000000000]]); - export const AmbiguityFiltersDict: ReadonlyMap = new Map([["\\bone\\b", "\\b(the|this|that|which)\\s+(one)\\b"]]); - export const RelativeReferenceOffsetMap: ReadonlyMap = new Map([["last", ""],["next one", ""],["current", ""],["current one", ""],["previous one", ""],["the second to last", ""],["the one before the last one", ""],["the one before the last", ""],["next to last", ""],["penultimate", ""],["the last but one", ""],["antepenultimate", ""],["next", ""],["previous", ""]]); - export const RelativeReferenceRelativeToMap: ReadonlyMap = new Map([["last", "end"],["next one", "current"],["previous one", "current"],["current", "current"],["current one", "current"],["the second to last", "end"],["the one before the last one", "end"],["the one before the last", "end"],["next to last", "end"],["penultimate", "end"],["the last but one", "end"],["antepenultimate", "end"],["next", "current"],["previous", "current"]]); -} diff --git a/JavaScript/packages/recognizers-number/src/resources/frenchNumeric.ts b/JavaScript/packages/recognizers-number/src/resources/frenchNumeric.ts deleted file mode 100644 index 5ddc4569ff..0000000000 --- a/JavaScript/packages/recognizers-number/src/resources/frenchNumeric.ts +++ /dev/null @@ -1,122 +0,0 @@ -// ------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// ------------------------------------------------------------------------------ - -import { BaseNumbers } from "./baseNumbers"; -export namespace FrenchNumeric { - export const LangMarker = `Fre`; - export const CompoundNumberLanguage = false; - export const MultiDecimalSeparatorCulture = true; - export const RoundNumberIntegerRegex = `(cent|mille|millions?|milliards?|billions?)`; - export const ZeroToNineIntegerRegex = `(une?|deux|trois|quatre|cinq|six|sept|huit|neuf|z[ée]ro)`; - export const TwoToNineIntegerRegex = `(deux|trois|quatre|cinq|six|sept|huit|neuf)`; - export const TenToNineteenIntegerRegex = `((seize|quinze|quatorze|treize|douze|onze)|dix(\\Wneuf|\\Whuit|\\Wsept)?)`; - export const TensNumberIntegerRegex = `(quatre\\Wvingt(s|\\Wdix)?|soixante(\\Wdix)?|vingt|trente|quarante|cinquante|septante|octante|huitante|nonante)`; - export const DigitsNumberRegex = `\\d|\\d{1,3}(\\.\\d{3})`; - export const NegativeNumberTermsRegex = `^[.]`; - export const NegativeNumberSignRegex = `^(${NegativeNumberTermsRegex}\\s+).*`; - export const HundredsNumberIntegerRegex = `((${ZeroToNineIntegerRegex}(\\s+cent))|cent|((\\s+cent\\s)+${TensNumberIntegerRegex}))`; - export const BelowHundredsRegex = `((${TenToNineteenIntegerRegex}|(${TensNumberIntegerRegex}((-|(\\s+et)?\\s+)(${TenToNineteenIntegerRegex}|${ZeroToNineIntegerRegex}))?))|${ZeroToNineIntegerRegex})`; - export const BelowThousandsRegex = `((${HundredsNumberIntegerRegex}(\\s+${BelowHundredsRegex})?|${BelowHundredsRegex}|${TenToNineteenIntegerRegex})|cent\\s+${TenToNineteenIntegerRegex})`; - export const SupportThousandsRegex = `((${BelowThousandsRegex}|${BelowHundredsRegex})\\s+${RoundNumberIntegerRegex}(\\s+${RoundNumberIntegerRegex})?)`; - export const SeparaIntRegex = `(${SupportThousandsRegex}(\\s+${SupportThousandsRegex})*(\\s+${BelowThousandsRegex})?|${BelowThousandsRegex})`; - export const AllIntRegex = `(${SeparaIntRegex}|mille(\\s+${BelowThousandsRegex})?)`; - export const NumbersWithPlaceHolder = (placeholder: string) => { return `(((?prochain[es]?|pr[eé]c[eé]dent[es]?|(l[’'])?actuel(le)?(\\s+une?)?|(l[’'])?avant(\\s+|-)derniere?|(ant[eé])?p[eé]nulti[eè]me|derni[eè]r[es]?|suivant[es]?|courant[es]?|cel(le|ui)\\s+d['’]avant\\s+l[ae]\\s+derni[èe]re?)`; - export const ComplexOrdinalRegex = `((${OverThousandOrdinalRegex}(\\s)?)?${UnderThousandOrdinalRegex}|${OverThousandOrdinalRegex}|${UnderHundredOrdinalRegex})`; - export const SuffixOrdinalRegex = `((${AllIntRegex})(${SimpleRoundOrdinalRegex}))`; - export const ComplexRoundOrdinalRegex = `(((${SuffixOrdinalRegex}(\\s)?)?${ComplexOrdinalRegex})|${SuffixOrdinalRegex})`; - export const AllOrdinalNumberRegex = `(${ComplexOrdinalRegex}|${SimpleRoundOrdinalRegex}|${ComplexRoundOrdinalRegex})`; - export const AllOrdinalRegex = `(?:${AllOrdinalNumberRegex}|${RelativeOrdinalRegex})`; - export const PlaceHolderPureNumber = `\\b`; - export const PlaceHolderDefault = `\\D|\\b`; - export const OrdinalSuffixRegex = `(?<=\\b)((\\d*(11e(me)?|1[eè]re?|[02-9]e(me)?)))(?=\\b)`; - export const OrdinalFrenchRegex = `(?<=\\b)${AllOrdinalRegex}(?=\\b)`; - export const FractionNotationWithSpacesRegex = `(((?<=\\W|^)-\\s*)|(?<=\\b))\\d+\\s+\\d+[/]\\d+(?=(\\b[^/]|$))`; - export const FractionNotationRegex = `${BaseNumbers.FractionNotationRegex}`; - export const FractionMultiplierRegex = `(?\\s+et\\s+(demi[es]?|(une?|${TwoToNineIntegerRegex})\\s+(demie?|tier|quart|(cinqui|sixi|septi|hui[tr]i|neuvi|dixi)[eè]me)s?))`; - export const RoundMultiplierWithFraction = `(?(millions?|milliards?|billions?))(?=${FractionMultiplierRegex}?$)`; - export const RoundMultiplierRegex = `\\b\\s*(${RoundMultiplierWithFraction}|(?(cent|mille))$)`; - export const FractionNounRegex = `(?<=\\b)(${AllIntRegex}\\s+((et)\\s+)?)?(${AllIntRegex}(\\s+((et)\\s)?)((${AllOrdinalNumberRegex}s?|${SuffixOrdinalRegex}s?)|(demi[es]?|tiers?|quarts?))|(un\\s+)?(demi|tier|quart)(\\s+(de\\s+)?|\\s*-\\s*)${RoundNumberIntegerRegex})(?=\\b)`; - export const FractionNounWithArticleRegex = `(?<=\\b)((${AllIntRegex}|${RoundNumberIntegerRegexWithLocks})\\s+(et\\s+)?)?((une?)(\\s+)((${AllOrdinalNumberRegex})|(${SuffixOrdinalRegex})|(et\\s+)?demi[es]?)|demi[es]?)(?=\\b)`; - export const FractionPrepositionRegex = `(?(${AllIntRegex})|((?(${AllIntRegex})|((\\d+)(?!\\.)))(?=\\b)`; - export const AllPointRegex = `((\\s+${ZeroToNineIntegerRegex})+|(\\s+${SeparaIntRegex}))`; - export const AllFloatRegex = `(${AllIntRegex}(\\s+(virgule|point))${AllPointRegex})`; - export const DoubleDecimalPointRegex = (placeholder: string) => { return `(((? { return `(?<=\\s|^)(?)`; - export const LessRegex = `(?:(less|plus\\s+(bas|petit|jeune)|moins|inf[ée]rieure?s?)(\\s+([àa]|d[e'’]|que))?|((en )?dessous)\\s+de|under|(?|=)<)`; - export const EqualRegex = `(([ée]ga(l(es)?|ux)|au\\s+nombre)(\\s+([àa]|d[e'’]))?|(?)=)`; - export const MoreOrEqualPrefix = `((pas\\s+${LessRegex})|(au\\s+moins|[àa] partir d[e'’]))`; - export const MoreOrEqual = `(?:(${MoreRegex}\\s+(ou)?\\s+${EqualRegex})|(${EqualRegex}\\s+(ou)?\\s+${MoreRegex})|${MoreOrEqualPrefix}(\\s+(ou)?\\s+${EqualRegex})?|(${EqualRegex}\\s+(ou)?\\s+)?${MoreOrEqualPrefix}|>\\s*=|≥)`; - export const MoreOrEqualSuffix = `((et|ou)\\s+(((more|greater|higher|plus(\\s+grand)?|sup[ée]rieure?s?)((?!\\s+([àa]|que))|(\\s+([àa]|que)(?!((\\s+ou\\s+[èe]ga(l(es)?|ux)\\s+[àa])?\\s*\\d+)))))|((a plus|au-dessus)\\s+d[e'’](?!\\s+than))))`; - export const LessOrEqualPrefix = `((pas\\s+${MoreRegex})|(au\\s+plus)|(jusqu'[àa]))`; - export const LessOrEqual = `((${LessRegex}\\s+(ou)?\\s+${EqualRegex})|(${EqualRegex}\\s+(ou)?\\s+${LessRegex})|${LessOrEqualPrefix}(\\s+(ou)?\\s+${EqualRegex})?|(${EqualRegex}\\s+(ou)?\\s+)?${LessOrEqualPrefix}|<\\s*=|≤)`; - export const LessOrEqualSuffix = `((et|ou)\\s+(less|lower|plus petit|moins|inf[ée]rieure?s?)((?!\\s+([àa]|de|que))|(\\s+([àa]|d[e'’]|que)(?!(\\s*\\d+)))))`; - export const NumberSplitMark = `(?![,.](?!\\d+))(?!\\s*\\b(et\\s+(${LessRegex}|${MoreRegex})|mais|ou|to)\\b)`; - export const MoreRegexNoNumberSucceed = `((bigger|greater|more|plus(\\s+grand)?|sup[ée]rieure?s?)((?!\\s+([àa]|que))|\\s+(([àa]|que)(?!(\\s*\\d+))))|((au-dessus|a plus)\\s+d[e'’])(?!(\\s*\\d+)))`; - export const LessRegexNoNumberSucceed = `((less|lower|plus petit|moins|inf[ée]rieure?s?)((?!\\s+([àa]|d[e'’]|que))|\\s+(([àa]|d[e'’]|que)(?!(\\s*\\d+))))|(((en )?dessous)\\s+d[e'’]|under)(?!(\\s*\\d+)))`; - export const EqualRegexNoNumberSucceed = `([èe]ga(l(es)?|ux)((?!\\s+([àa]))|(\\s+([àa]|que)(?!(\\s*\\d+)))))`; - export const OneNumberRangeMoreRegex1 = `(${MoreOrEqual}|${MoreRegex})\\s*(l[ae]\\s+)?(?(${NumberSplitMark}.)+)`; - export const OneNumberRangeMoreRegex1LB = `(?(${NumberSplitMark}.)+)\\s*${MoreOrEqualSuffix}`; - export const OneNumberRangeMoreSeparateRegex = `(${EqualRegex}\\s+(?(${NumberSplitMark}.)+)(\\s+ou\\s+)${MoreRegexNoNumberSucceed})|(${MoreRegex}\\s+(?(${NumberSplitMark}.)+)(\\s+ou\\s+)${EqualRegexNoNumberSucceed})`; - export const OneNumberRangeLessRegex1 = `(${LessOrEqual}|${LessRegex})\\s*(l[ae]\\s+)?(?(${NumberSplitMark}.)+)`; - export const OneNumberRangeLessRegex1LB = `(?(${NumberSplitMark}.)+)\\s*${LessOrEqualSuffix}`; - export const OneNumberRangeLessSeparateRegex = `(${EqualRegex}\\s+(?(${NumberSplitMark}.)+)(\\s+ou\\s+)${LessRegexNoNumberSucceed})|(${LessRegex}\\s+(?(${NumberSplitMark}.)+)(\\s+ou\\s+)${EqualRegexNoNumberSucceed})`; - export const OneNumberRangeEqualRegex = `(?(${NumberSplitMark}.)+)`; - export const TwoNumberRangeRegex1 = `entre\\s*(l[ae]\\s+)?(?(${NumberSplitMark}.)+)\\s*et\\s*(l[ae]\\s+)?(?(${NumberSplitMark}.)+)`; - export const TwoNumberRangeRegex2 = `(${OneNumberRangeMoreRegex1}|${OneNumberRangeMoreRegex2})\\s*(et|mais|,)\\s*(${OneNumberRangeLessRegex1}|${OneNumberRangeLessRegex2})`; - export const TwoNumberRangeRegex3 = `(${OneNumberRangeLessRegex1}|${OneNumberRangeLessRegex2})\\s*(et|mais|,)\\s*(${OneNumberRangeMoreRegex1}|${OneNumberRangeMoreRegex2})`; - export const TwoNumberRangeRegex4 = `(de\\s+)?(?(${NumberSplitMark}(?!\\bde\\b).)+)\\s*${TillRegex}\\s*(l[ae]\\s+)?(?(${NumberSplitMark}.)+)`; - export const DecimalSeparatorChar = `,`; - export const FractionMarkerToken = `sur`; - export const NonDecimalSeparatorChar = `.`; - export const HalfADozenText = `six`; - export const WordSeparatorToken = `et`; - export const WrittenDecimalSeparatorTexts = [ "virgule" ]; - export const WrittenGroupSeparatorTexts = [ "point","points" ]; - export const WrittenIntegerSeparatorTexts = [ "et","-" ]; - export const WrittenFractionSeparatorTexts = [ "et","sur" ]; - export const OneHalfTokens = [ "un","demi" ]; - export const HalfADozenRegex = `(?<=\\b)demie?\\s+douzaine`; - export const DigitalNumberRegex = `((?<=\\b)(cent|mille|millions?|milliards?|billions?|douzaines?)(?=\\b))|((?<=(\\d|\\b))${BaseNumbers.MultiplierLookupRegex}(?=\\b))`; - export const AmbiguousFractionConnectorsRegex = `^[.]`; - export const CardinalNumberMap: ReadonlyMap = new Map([["zéro", 0],["zero", 0],["un", 1],["une", 1],["deux", 2],["trois", 3],["quatre", 4],["cinq", 5],["six", 6],["sept", 7],["huit", 8],["neuf", 9],["dix", 10],["onze", 11],["douze", 12],["douzaine", 12],["douzaines", 12],["treize", 13],["quatorze", 14],["quinze", 15],["seize", 16],["dix-sept", 17],["dix-huit", 18],["dix-huir", 18],["dix-neuf", 19],["vingt", 20],["trente", 30],["quarante", 40],["cinquante", 50],["soixante", 60],["soixante-dix", 70],["septante", 70],["quatre-vingts", 80],["quatre-vingt", 80],["quatre vingts", 80],["quatre vingt", 80],["quatre-vingt-dix", 90],["quatre-vingt dix", 90],["quatre vingt dix", 90],["quatre-vingts-dix", 90],["quatre-vingts-onze", 91],["quatre-vingt-onze", 91],["quatre-vingts-douze", 92],["quatre-vingt-douze", 92],["quatre-vingts-treize", 93],["quatre-vingt-treize", 93],["quatre-vingts-quatorze", 94],["quatre-vingt-quatorze", 94],["quatre-vingts-quinze", 95],["quatre-vingt-quinze", 95],["quatre-vingts-seize", 96],["quatre-vingt-seize", 96],["huitante", 80],["octante", 80],["nonante", 90],["cent", 100],["mille", 1000],["un million", 1000000],["million", 1000000],["millions", 1000000],["un milliard", 1000000000],["milliard", 1000000000],["milliards", 1000000000],["un mille milliards", 1000000000000],["un billion", 1000000000000]]); - export const OrdinalNumberMap: ReadonlyMap = new Map([["premier", 1],["première", 1],["premiere", 1],["unième", 1],["unieme", 1],["deuxième", 2],["deuxieme", 2],["second", 2],["seconde", 2],["troisième", 3],["demi", 2],["demie", 2],["tiers", 3],["tierce", 3],["quart", 4],["quarts", 4],["troisieme", 3],["quatrième", 4],["quatrieme", 4],["cinquième", 5],["cinquieme", 5],["sixième", 6],["sixieme", 6],["septième", 7],["septieme", 7],["huitième", 8],["huitieme", 8],["huirième", 8],["huirieme", 8],["neuvième", 9],["neuvieme", 9],["dixième", 10],["dixieme", 10],["dizième", 10],["dizieme", 10],["onzième", 11],["onzieme", 11],["douzième", 12],["douzieme", 12],["treizième", 13],["treizieme", 13],["quatorzième", 14],["quatorzieme", 14],["quinzième", 15],["quinzieme", 15],["seizième", 16],["seizieme", 16],["dix-septième", 17],["dix-septieme", 17],["dix-huitième", 18],["dix-huitieme", 18],["dix-huirième", 18],["dix-huirieme", 18],["dix-neuvième", 19],["dix-neuvieme", 19],["vingtième", 20],["vingtieme", 20],["trentième", 30],["trentieme", 30],["quarantième", 40],["quarantieme", 40],["cinquantième", 50],["cinquantieme", 50],["soixantième", 60],["soixantieme", 60],["soixante-dixième", 70],["soixante-dixieme", 70],["septantième", 70],["septantieme", 70],["quatre-vingtième", 80],["quatre-vingtieme", 80],["huitantième", 80],["huitantieme", 80],["octantième", 80],["octantieme", 80],["quatre-vingt-dixième", 90],["quatre-vingt-dixieme", 90],["nonantième", 90],["nonantieme", 90],["centième", 100],["centieme", 100],["millième", 1000],["millieme", 1000],["millionième", 1000000],["millionieme", 1000000],["milliardième", 1000000000],["milliardieme", 1000000000],["billionieme", 1000000000000],["billionième", 1000000000000],["trillionième", 1000000000000000000],["trillionieme", 1000000000000000000]]); - export const PrefixCardinalMap: ReadonlyMap = new Map([["deux", 2],["trois", 3],["quatre", 4],["cinq", 5],["six", 6],["sept", 7],["huit", 8],["neuf", 9],["dix", 10],["onze", 11],["douze", 12],["treize", 13],["quatorze", 14],["quinze", 15],["seize", 16],["dix sept", 17],["dix-sept", 17],["dix-huit", 18],["dix huit", 18],["dix-neuf", 19],["dix neuf", 19],["vingt", 20],["vingt-et-un", 21],["vingt et un", 21],["vingt-deux", 21],["vingt deux", 22],["vingt-trois", 23],["vingt trois", 23],["vingt-quatre", 24],["vingt quatre", 24],["vingt-cinq", 25],["vingt cinq", 25],["vingt-six", 26],["vingt six", 26],["vingt-sept", 27],["vingt sept", 27],["vingt-huit", 28],["vingt huit", 28],["vingt-neuf", 29],["vingt neuf", 29],["trente", 30],["quarante", 40],["cinquante", 50],["soixante", 60],["soixante-dix", 70],["soixante dix", 70],["septante", 70],["quatre-vingt", 80],["quatre vingt", 80],["huitante", 80],["octante", 80],["nonante", 90],["quatre vingt dix", 90],["quatre-vingt-dix", 90],["cent", 100],["deux cent", 200],["trois cents", 300],["quatre cents", 400],["cinq cent", 500],["six cent", 600],["sept cent", 700],["huit cent", 800],["neuf cent", 900]]); - export const SuffixOrdinalMap: ReadonlyMap = new Map([["millième", 1000],["million", 1000000],["milliardième", 1000000000000]]); - export const RoundNumberMap: ReadonlyMap = new Map([["cent", 100],["mille", 1000],["million", 1000000],["millions", 1000000],["milliard", 1000000000],["milliards", 1000000000],["billion", 1000000000000],["billions", 1000000000000],["centieme", 100],["centième", 100],["millieme", 1000],["millième", 1000],["millionième", 1000000],["millionieme", 1000000],["milliardième", 1000000000],["milliardieme", 1000000000],["billionième", 1000000000000],["billionieme", 1000000000000],["centiemes", 100],["centièmes", 100],["millièmes", 1000],["milliemes", 1000],["millionièmes", 1000000],["millioniemes", 1000000],["milliardièmes", 1000000000],["milliardiemes", 1000000000],["billionièmes", 1000000000000],["billioniemes", 1000000000000],["douzaine", 12],["douzaines", 12],["k", 1000],["m", 1000000],["g", 1000000000],["b", 1000000000],["t", 1000000000000]]); - export const AmbiguityFiltersDict: ReadonlyMap = new Map([["^[.]", ""]]); - export const RelativeReferenceOffsetMap: ReadonlyMap = new Map([["prochain", ""],["prochaine", ""],["prochains", ""],["precedent", ""],["precedente", ""],["precédent", ""],["precédente", ""],["précedent", ""],["précedente", ""],["précédent", ""],["précédente", ""],["actuel", ""],["actuelle", ""],["actuel un", ""],["actuelle une", ""],["l'actuel", ""],["l'actuelle", ""],["l’actuel", ""],["l’actuelle", ""],["l'actuel un", ""],["l'actuelle une", ""],["l’actuel un", ""],["l’actuelle une", ""],["avant dernier", ""],["avant derniere", ""],["avant-dernier", ""],["avant-derniere", ""],["l'avant dernier", ""],["l'avant derniere", ""],["l'avant-dernier", ""],["l'avant-derniere", ""],["l’avant dernier", ""],["l’avant derniere", ""],["l’avant-dernier", ""],["l’avant-derniere", ""],["celle d'avant la dernière", ""],["celui d'avant le dernièr", ""],["celle d'avant la derniere", ""],["celui d'avant le dernier", ""],["celle d’avant la dernière", ""],["celui d’avant le dernièr", ""],["celle d’avant la derniere", ""],["celui d’avant le dernier", ""],["penultieme", ""],["penultième", ""],["pénultieme", ""],["pénultième", ""],["antepenultieme", ""],["antépenultieme", ""],["antepenultième", ""],["antépenultième", ""],["antepénultieme", ""],["antépénultieme", ""],["antepénultième", ""],["antépénultième", ""],["dernier", ""],["dernièr", ""],["derniere", ""],["derniers", ""],["dernière", ""],["dernièrs", ""],["suivant", ""],["suivante", ""],["suivants", ""],["courant", ""],["courante", ""],["courants", ""]]); - export const RelativeReferenceRelativeToMap: ReadonlyMap = new Map([["prochain", "current"],["prochaine", "current"],["prochains", "current"],["precedent", "current"],["precedente", "current"],["precédent", "current"],["precédente", "current"],["précedent", "current"],["précedente", "current"],["précédent", "current"],["précédente", "current"],["actuel", "current"],["actuelle", "current"],["actuel un", "current"],["actuelle une", "current"],["l'actuel", "current"],["l'actuelle", "current"],["l’actuel", "current"],["l’actuelle", "current"],["l'actuel un", "current"],["l'actuelle une", "current"],["l’actuel un", "current"],["l’actuelle une", "current"],["avant dernier", "end"],["avant-dernier", "end"],["avant derniere", "end"],["avant-derniere", "end"],["l'avant dernier", "end"],["l'avant-dernier", "end"],["l'avant derniere", "end"],["l'avant-derniere", "end"],["l’avant dernier", "end"],["l’avant-dernier", "end"],["l’avant derniere", "end"],["l’avant-derniere", "end"],["celle d'avant la dernière", "end"],["celui d'avant le dernièr", "end"],["celle d'avant la derniere", "end"],["celui d'avant le dernier", "end"],["celle d’avant la dernière", "end"],["celui d’avant le dernièr", "end"],["celle d’avant la derniere", "end"],["celui d’avant le dernier", "end"],["penultieme", "end"],["penultième", "end"],["pénultieme", "end"],["pénultième", "end"],["antepenultieme", "end"],["antépenultieme", "end"],["antepenultième", "end"],["antépenultième", "end"],["antepénultieme", "end"],["antépénultieme", "end"],["antepénultième", "end"],["antépénultième", "end"],["dernier", "end"],["dernièr", "end"],["derniere", "end"],["derniers", "end"],["dernière", "end"],["dernièrs", "end"],["suivant", "current"],["suivante", "current"],["suivants", "current"],["courant", "current"],["courante", "current"],["courants", "current"]]); -} diff --git a/JavaScript/packages/recognizers-number/src/resources/japaneseNumeric.ts b/JavaScript/packages/recognizers-number/src/resources/japaneseNumeric.ts deleted file mode 100644 index 98111b60cf..0000000000 --- a/JavaScript/packages/recognizers-number/src/resources/japaneseNumeric.ts +++ /dev/null @@ -1,141 +0,0 @@ -// ------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// ------------------------------------------------------------------------------ - -import { BaseNumbers } from "./baseNumbers"; -export namespace JapaneseNumeric { - export const LangMarker = `Jpn`; - export const CompoundNumberLanguage = true; - export const MultiDecimalSeparatorCulture = false; - export const DecimalSeparatorChar = `.`; - export const FractionMarkerToken = ``; - export const NonDecimalSeparatorChar = `,`; - export const HalfADozenText = ``; - export const WordSeparatorToken = ``; - export const ZeroChar = `零`; - export const PairChar = `対`; - export const RoundNumberMap: ReadonlyMap = new Map([["k", 1000],["m", 1000000],["g", 1000000000],["t", 1000000000000],["b", 1000000000]]); - export const RoundNumberMapChar: ReadonlyMap = new Map([["十", 10],["百", 100],["千", 1000],["万", 10000],["億", 100000000],["兆", 1000000000000]]); - export const ZeroToNineMap: ReadonlyMap = new Map([["0", 0],["1", 1],["2", 2],["3", 3],["4", 4],["5", 5],["6", 6],["7", 7],["8", 8],["9", 9],["零", 0],["〇", 0],["一", 1],["二", 2],["三", 3],["四", 4],["五", 5],["六", 6],["七", 7],["八", 8],["九", 9],["半", 0.5]]); - export const FullToHalfMap: ReadonlyMap = new Map([["0", "0"],["1", "1"],["2", "2"],["3", "3"],["4", "4"],["5", "5"],["6", "6"],["7", "7"],["8", "8"],["9", "9"],["/", "/"],["-", "-"],[",", "'"],["、", "'"],["G", "G"],["M", "M"],["T", "T"],["K", "K"],["k", "k"],[".", "."]]); - export const UnitMap: ReadonlyMap = new Map([["万万", "億"],["億万", "兆"],["万億", "兆"],[" ", ""],["れい", "〇"],["ゼロ", "〇"],["マル", "〇"],["いち", "一"],["いっ", "一"],["に", "二"],["さん", "三"],["し", "四"],["よん", "四"],["ご", "五"],["ろく", "六"],["ろっ", "六"],["しち", "七"],["なな", "七"],["はち", "八"],["はっ", "八"],["きゅう", "九"],["く", "九"],["じゅう", "十"],["ひゃく", "百"],["ぴゃく", "百"],["びゃく", "百"],["せん", "千"],["ぜん", "千"],["まん", "万"],["ひゃくまん", "百万"],["ぴゃくまん", "百万"],["びゃくまん", "百万"],["せんまん", "千万"],["ぜんまん", "千万"]]); - export const RoundDirectList = [ "万","億","兆" ]; - export const TenChars = [ "十" ]; - export const RoundNumberIntegerRegex = `(十|百|千|万(?!万)|億|兆)`; - export const RoundNumberIntegerHiraganaRegex = `(じゅう|[ひぴび]ゃく|[せぜ]ん|まん|[ひぴび]ゃくまん|[せぜ]んまん)`; - export const AllMultiplierLookupRegex = `(${BaseNumbers.MultiplierLookupRegex}|ミリリットル(入れら)?|キロメートル|メートル|ミリメート)`; - export const DigitalNumberRegex = `((?<=(\\d|\\b))${BaseNumbers.MultiplierLookupRegex}(?=\\b))`; - export const ZeroToNineFullHalfRegex = `[\\d]`; - export const DigitNumRegex = `${ZeroToNineFullHalfRegex}+`; - export const DozenRegex = `.*ダース$`; - export const PercentageSymbol = `(パ\\s*ー\\s*セ\\s*ン\\s*ト|[%%])`; - export const PercentageRegex = `.+(?=パ\\s*ー\\s*セ\\s*ン\\s*ト)|.*(?=[%%])`; - export const DoubleAndRoundRegex = `${ZeroToNineFullHalfRegex}+(\\.${ZeroToNineFullHalfRegex}+)?\\s*${RoundNumberIntegerRegex}{1,2}(\\s*(以上))?`; - export const FracSplitRegex = `[はと]|分\\s*の`; - export const ZeroToNineIntegerRegex = `[零〇一二三四五六七八九]`; - export const ZeroToNineIntegerHiraganaRegex = `(れい|ゼロ|マル|い[ちっ]|に|さん|し|よん|ご|ろ[くっ]|しち|なな|は[ちっ]|きゅう|く)`; - export const HalfUnitRegex = `半`; - export const NegativeNumberTermsRegex = `(マ\\s*イ\\s*ナ\\s*ス)`; - export const NegativeNumberTermsRegexNum = `((?((最後)(から1つ前のこと|から(3|2|1)番目|(から1つ前)(のもの)|から三番目|から二番目|(から(一|1)つ前)(のもの|のこと)?|(から1つ)?(前))?|(次のもの)(前)?|(前(?=の))(のもの)?|(現在)(のこと)?|次|二位))`; - export const AllOrdinalRegex = `(${OrdinalRegex}|${RelativeOrdinalRegex})`; - export const AllFractionNumber = `(((${NegativeNumberTermsRegex}{0,1})|${NegativeNumberTermsRegexNum})((${ZeroToNineFullHalfRegex}+|${AllIntRegex})\\s*[はと]{0,1}\\s*)?${NegativeNumberTermsRegex}{0,1}(${ZeroToNineFullHalfRegex}+|${AllIntRegex})\\s*分\\s*の\\s*${NegativeNumberTermsRegex}{0,1}(${ZeroToNineFullHalfRegex}+|${AllIntRegex})+)|半(分|数)`; - export const FractionNotationSpecialsCharsRegex = `(${NegativeNumberTermsRegexNum}\\s*)?${ZeroToNineFullHalfRegex}+\\s+${ZeroToNineFullHalfRegex}+[//]${ZeroToNineFullHalfRegex}+`; - export const FractionNotationRegex = `(${NegativeNumberTermsRegexNum}\\s*)?${ZeroToNineFullHalfRegex}+[//]${ZeroToNineFullHalfRegex}+`; - export const PercentagePointRegex = `(?)`; - export const LessRegex = `(小なり|小さい|低い|(?|=)<)`; - export const EqualRegex = `(等しい|イコール|(?)=)`; - export const MoreOrEqualPrefixRegex = `(少なくとも)`; - export const LessOrEqualPrefixRegex = `(多くて)`; - export const MoreOrEqual = `((${MoreRegex}(か)${EqualRegex})|小さくない|以上|最低)`; - export const MoreOrEqualSuffix = `(より(大なりイコール|小さくない))`; - export const LessOrEqual = `((${LessRegex}\\s*(或|或者)?\\s*${EqualRegex})|(${LessRegex}(か)${EqualRegex})|大さくない|以下|最大)`; - export const LessOrEqualSuffix = `(小なりイコール|大さくない)`; - export const OneNumberRangeMoreRegex1 = `(?(((?!((,(?!\\d+))|。|は)).)+))\\s*((より)\\s*((${MoreOrEqual}|${MoreRegex})))|(?((?!((,(?!\\d+))|。|は)).)+)\\s*(${MoreRegex})`; - export const OneNumberRangeMoreRegex3 = `(?((?!((,(?!\\d+))|。)).)+)\\s*(以上|最低)(?![万億]{1,2})`; - export const OneNumberRangeMoreRegex4 = `(${MoreOrEqualPrefixRegex})\\s*(?((?!(と|は|((と)?同時に)|((と)?そして)|が|,|(,(?!\\d+))|。)).)*)`; - export const OneNumberRangeMoreRegex5 = `(?((?!((,(?!\\d+))|。)).)+)\\s*((もしくはそれ)(以上)(?![万億]{1,2}))`; - export const OneNumberRangeMoreSeparateRegex = `^[.]`; - export const OneNumberRangeLessSeparateRegex = `^[.]`; - export const OneNumberRangeLessRegex1 = `(?(((?!(((,)(?!\\d+))|。|(\\D)))|(?:[-]|(分の))).)+)\\s*(より)\\s*(${LessOrEqual}|${LessRegex})|(?((?!((,(?!\\d+))|。)).)+)\\s*(小な)`; - export const OneNumberRangeLessRegex3 = `(?(((?!((,(?!\\d+))|。)).)+))\\s*(以下|未満)(の間)?(?![万億]{1,2})`; - export const OneNumberRangeLessRegex4 = `(${LessOrEqual}|${LessRegex}|${LessOrEqualPrefixRegex})\\s*(?((?!(と|は|((と)?同時に)|((と)?そして)|が|の|,|(,(?!\\d+))|。)).)+)`; - export const OneNumberRangeEqualRegex = `(((?((?!((,(?!\\d+))|。)).)+)\\s*(に)\\s*${EqualRegex})|(${EqualRegex}\\s*(?((?!((,(?!\\d+))|。)).)+)))`; - export const TwoNumberRangeMoreSuffix = `(${MoreOrEqualPrefixRegex}\\s*(?((?!(と|は|((と)?同時に)|((と)?そして)|が|,|(,(?!\\d+))|。)).)*))(,${LessOrEqualPrefixRegex})`; - export const TwoNumberRangeRegex1 = `(?((?!((,(?!\\d+))|。)).)+)\\s*(と|${TillRegex})\\s*(?((?!((,(?!\\d+))|。)).)+)\\s*(の間|未満)`; - export const TwoNumberRangeRegex2 = `(${OneNumberRangeMoreRegex1}|${OneNumberRangeMoreRegex3}|${OneNumberRangeMoreRegex4})\\s*(と|((と)?同時に)|((と)?そして)|が|,)?\\s*(${OneNumberRangeLessRegex1}|${OneNumberRangeLessRegex3}|${OneNumberRangeLessRegex4})`; - export const TwoNumberRangeRegex3 = `(${OneNumberRangeLessRegex1}|${OneNumberRangeLessRegex3}|${OneNumberRangeLessRegex4})\\s*(と|((と)?同時に)|((と)?そして)|が|,)?\\s*(${OneNumberRangeMoreRegex1}|${OneNumberRangeMoreRegex3}|${OneNumberRangeMoreRegex4})`; - export const TwoNumberRangeRegex4 = `(?((?!((,(?!\\d+))|。)).)+)\\s*${TillRegex}\\s*(?((?!((,(?!\\d+))|。)).)+)`; - export const AmbiguousFractionConnectorsRegex = `^[.]`; - export const RelativeReferenceOffsetMap: ReadonlyMap = new Map([["前", ""],["現在", ""],["次", ""],["最後", ""],["最後から三番目", ""],["最後から二番目", ""],["最後から一つ前", ""],["最後から一つ前のもの", ""],["最後から一つ前のこと", ""],["最後から1つ前のこと", ""],["最後から1つ前のもの", ""],["最後から1つ前", ""],["現在のこと", ""],["前のもの", ""],["次のもの", ""],["最後から3番目", ""],["最後から2番目", ""]]); - export const RelativeReferenceRelativeToMap: ReadonlyMap = new Map([["前", "current"],["現在", "current"],["次", "current"],["最後", "end"],["最後から三番目", "end"],["最後から二番目", "end"],["最後から一つ前", "end"],["最後から一つ前のもの", "end"],["最後から一つ前のこと", "end"],["現在のこと", "current"],["最後から1つ前のこと", "end"],["最後から1つ前のもの", "end"],["最後から1つ前", "end"],["前のもの", "current"],["次のもの", "current"],["最後から3番目", "end"],["最後から2番目", "end"]]); - export const AmbiguityFiltersDict: ReadonlyMap = new Map([["^に$", "に"]]); -} diff --git a/JavaScript/packages/recognizers-number/src/resources/portugueseNumeric.ts b/JavaScript/packages/recognizers-number/src/resources/portugueseNumeric.ts deleted file mode 100644 index 787cc63bd6..0000000000 --- a/JavaScript/packages/recognizers-number/src/resources/portugueseNumeric.ts +++ /dev/null @@ -1,125 +0,0 @@ -// ------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// ------------------------------------------------------------------------------ - -import { BaseNumbers } from "./baseNumbers"; -export namespace PortugueseNumeric { - export const LangMarker = `Por`; - export const CompoundNumberLanguage = false; - export const MultiDecimalSeparatorCulture = false; - export const HundredsNumberIntegerRegex = `(quatrocent[ao]s|trezent[ao]s|seiscent[ao]s|setecent[ao]s|oitocent[ao]s|novecent[ao]s|duzent[ao]s|quinhent[ao]s|cem|(? { return `(((?pr[oó]xim[ao]s?|[uú]ltim[ao]\\s+mas\\s+um|anterior\\s+ao\\s+últim[ao]|(pen)?[uú]ltim[ao]s?|antepen[uú]ltim[ao]s?|seguintes?|anterior(es)?|atua(l|is))`; - export const ComplexOrdinalRegex = `((${OverThousandOrdinalRegex}(\\s)?)?${UnderThousandOrdinalRegex}|${OverThousandOrdinalRegex})`; - export const SuffixRoundOrdinalRegex = `((${AllIntRegex})(${SimpleRoundOrdinalRegex}))`; - export const ComplexRoundOrdinalRegex = `(((${SuffixRoundOrdinalRegex}(\\s)?)?${ComplexOrdinalRegex})|${SuffixRoundOrdinalRegex})`; - export const AllOrdinalNumberRegex = `${ComplexOrdinalRegex}|${SimpleRoundOrdinalRegex}|${ComplexRoundOrdinalRegex}`; - export const AllOrdinalRegex = `(?:${AllOrdinalNumberRegex}|${RelativeOrdinalRegex})`; - export const OrdinalSuffixRegex = `(?<=\\b)(\\d*((1|2|3|4|5|6|7|8|9|0)[oaºª]|(1|2|3|4|5|6|7|8|9)(\\.[ºª])))(?=\\b)`; - export const OrdinalEnglishRegex = `(?<=\\b)${AllOrdinalRegex}(?=\\b)`; - export const FractionNotationRegex = `${BaseNumbers.FractionNotationRegex}`; - export const FractionNotationWithSpacesRegex = `(((?<=\\W|^)-\\s*)|(?<=\\b))\\d+\\s+\\d+[/]\\d+(?=(\\b[^/]|$))`; - export const FractionMultiplierRegex = `(?\\s+(e|com)\\s+(meio|(um|${TwoToNineIntegerRegex})\\s+(meio|terç[oa]|quart[oa]|quint[oa]|sext[oa]|s[eé]tim[oa]|oitav[oa]|non[oa]|d[eé]cim[oa])s?))`; - export const RoundMultiplierWithFraction = `(?(?:(mil(h([ãa]o|[õo]es))|bilh([ãa]o|[õo]es)|trilh([ãa]o|[õo]es)|qua[td]rilh([ãa]o|[õo]es)|quintilh([ãa]o|[õo]es))))(?=${FractionMultiplierRegex}?$)`; - export const RoundMultiplierRegex = `\\b\\s*(${RoundMultiplierWithFraction}|(?(mil))$)`; - export const FractionNounRegex = `(?<=\\b)(${AllIntRegex}\\s+((e|com)\\s+)?)?((${AllIntRegex})(\\s+((e|com)\\s)?)(((${AllOrdinalNumberRegex})s?|(${SpecialFractionInteger})|(${SuffixRoundOrdinalRegex})s?)|mei[oa]?|ter[çc]o?)|(meio|um\\s+quarto\\s+de)\\s+${RoundNumberIntegerRegex})(?=\\b)`; - export const FractionNounWithArticleRegex = `(?<=\\b)((${AllIntRegex}|${RoundNumberIntegerRegexWithLocks})\\s+(e\\s+)?)?((um|um[as])(\\s+)((${AllOrdinalNumberRegex})|(${SuffixRoundOrdinalRegex})|(e\\s+)?mei[oa]?)|mei[oa]?)(?=\\b)`; - export const FractionPrepositionRegex = `(?(${AllIntRegex})|((?(${AllIntRegex})|((\\d+)(?!\\.)))(?=\\b)`; - export const AllFloatRegex = `(? { return `(((? { return `(?<=\\s|^)(?)`; - export const LessRegex = `(mais\\s+baix[oa]\\s+que|(meno(s|r(es)?)|inferior(es)?|abaixo)(\\s+(que|de|a)|(?=\\s+ou\\b))|(?|=)<)`; - export const EqualRegex = `((igua(l|is)|equivalente(s)?|equivale(ndo)?)(\\s+(ao?|que|d[eao]))?|(?)=)`; - export const MoreOrEqualPrefix = `((n[ãa]o\\s+${LessRegex})|((pelo|ao)\\s+menos|(como(\\s+o)?|no)\\s+m[íi]nimo))`; - export const MoreOrEqual = `((${MoreRegex}\\s+(ou)?\\s+${EqualRegex})|(${EqualRegex}\\s+(ou|e)\\s+${MoreRegex})|${MoreOrEqualPrefix}(\\s+(ou)\\s+${EqualRegex})?|(${EqualRegex}\\s+(ou)\\s+)?${MoreOrEqualPrefix}|>\\s*=)`; - export const MoreOrEqualSuffix = `((\\b(e|ou)\\b\\s+(mais|maior(es)?|superior(es)?)((?!\\s+(alt[oa]|baix[oa]|que|d[eao]|ao?))|(\\s+(que|d[eao]|ao?)(?!(\\s*\\d+)))))|(como(\\s+o)?|no)\\s+m[íi]nimo|(pelo|ao)\\s+menos)\\b`; - export const LessOrEqualPrefix = `((n[ãa]o\\s+${MoreRegex})|((como(\\s+o)?|no)\\s+m[aá]ximo))`; - export const LessOrEqual = `((${LessRegex}\\s+(ou)?\\s+${EqualRegex})|(${EqualRegex}\\s+(ou)?\\s+${LessRegex})|${LessOrEqualPrefix}(\\s+(ou)?\\s+${EqualRegex})?|(${EqualRegex}\\s+(ou)?\\s+)?${LessOrEqualPrefix}|<\\s*=)`; - export const LessOrEqualSuffix = `((\\b(e|ou)\\b\\s+(meno(s|r(es)?|inferior(es)?))((?!\\s+(alt[oa]|baix[oa]|que|d[eao]|ao?))|(\\s+(que|d[eao]|ao?)(?!(\\s*\\d+)))))|(como(\\s+o)?|no)\\s+m[áa]ximo)\\b`; - export const NumberSplitMark = `(?![,.](?!\\d+))(?!\\s*\\b(((e)\\s+)?(${LessRegex}|${MoreRegex}|${EqualRegex}|n[ãa]o|d[eao])|mas|[ao])\\b)`; - export const MoreRegexNoNumberSucceed = `(\\b(mais|maior(es)?|superior(es)?)((?!\\s+(que|d[eao]|ao?))|\\s+((que|d[eao])(?!(\\s*\\d+))))|((por\\s+|a)cima)(?!(\\s*\\d+)))\\b`; - export const LessRegexNoNumberSucceed = `(\\b(meno(s|r(es)?)|inferior(es)?)((?!\\s+(que|d[eao]|ao?))|\\s+((que|d[eao]|ao?)(?!(\\s*\\d+))))|((por\\s+|a)baixo)(?!(\\s*\\d+)))\\b`; - export const EqualRegexNoNumberSucceed = `(\\b(igua(l|is)|equivalentes?|equivale(ndo)?)((?!\\s+(ao?|que|d[eao]))|(\\s+(ao?|que|d[eao])(?!(\\s*\\d+)))))\\b`; - export const OneNumberRangeMoreRegex1 = `(${MoreOrEqual}|${MoreRegex})\\s*(([ao]s?)\\s+)?(?(${NumberSplitMark}.)+)`; - export const OneNumberRangeMoreRegex1LB = `(?(${NumberSplitMark}.)+)\\s*${MoreOrEqualSuffix}`; - export const OneNumberRangeMoreSeparateRegex = `(${EqualRegex}\\s+(?(${NumberSplitMark}.)+)(\\s+ou\\s+)${MoreRegexNoNumberSucceed})|(${MoreRegex}\\s+(?(${NumberSplitMark}.)+)(\\s+ou\\s+)${EqualRegexNoNumberSucceed})`; - export const OneNumberRangeLessRegex1 = `(${LessOrEqual}|${LessRegex})\\s*([ao]s?\\s+)?(?(${NumberSplitMark}.)+)`; - export const OneNumberRangeLessRegex1LB = `(?(${NumberSplitMark}.)+)\\s*${LessOrEqualSuffix}`; - export const OneNumberRangeLessSeparateRegex = `(${EqualRegex}\\s+(?(${NumberSplitMark}.)+)(\\s+ou\\s+)${LessRegexNoNumberSucceed})|(${LessRegex}\\s+(?(${NumberSplitMark}.)+)(\\s+ou\\s+)${EqualRegexNoNumberSucceed})`; - export const OneNumberRangeEqualRegex = `${EqualRegex}\\s*([ao]s?\\s+)?(?(${NumberSplitMark}.)+)`; - export const TwoNumberRangeRegex1 = `\\bentre\\s*([ao]s?\\s+)?(?(${NumberSplitMark}.)+)\\s*e\\s*([ao]s?\\s+)?(?(${NumberSplitMark}.)+)`; - export const TwoNumberRangeRegex2 = `(${OneNumberRangeMoreRegex1}|${OneNumberRangeMoreRegex2})\\s*(\\be\\b|mas|,)\\s*(${OneNumberRangeLessRegex1}|${OneNumberRangeLessRegex2})`; - export const TwoNumberRangeRegex3 = `(${OneNumberRangeLessRegex1}|${OneNumberRangeLessRegex2})\\s*(\\be\\b|mas|,)\\s*(${OneNumberRangeMoreRegex1}|${OneNumberRangeMoreRegex2})`; - export const TwoNumberRangeRegex4 = `(\\bde(sde)?\\s+)?(\\b[ao]s?\\s+)?\\b(?!\\s+)(?(${NumberSplitMark}(?!\\b(entre|de(sde)?|es)\\b).)+)\\b\\s*${TillRegex}\\s*([ao]s?\\s+)?\\b(?!\\s+)(?(${NumberSplitMark}.)+)\\b`; - export const AmbiguousFractionConnectorsRegex = `(\\b(em|de)\\b)`; - export const DecimalSeparatorChar = `,`; - export const FractionMarkerToken = `sobre`; - export const NonDecimalSeparatorChar = `.`; - export const HalfADozenText = `seis`; - export const WordSeparatorToken = `e`; - export const WrittenDecimalSeparatorTexts = [ "virgula","vírgula" ]; - export const WrittenGroupSeparatorTexts = [ "ponto" ]; - export const WrittenIntegerSeparatorTexts = [ "e" ]; - export const WrittenFractionSeparatorTexts = [ "com" ]; - export const WrittenFractionSuffix = [ "avo","ava" ]; - export const OneHalfTokens = [ "um","meio" ]; - export const PluralSuffix = `s`; - export const HalfADozenRegex = `meia\\s+d[uú]zia`; - export const DigitalNumberRegex = `((?<=\\b)(mil(hares)?|ce(m|ntenas?)|[bmt]ilh([aã]o|[oõ]es)|dezenas?)(?=\\b))|((?<=(\\d|\\b))${BaseNumbers.MultiplierLookupRegex}(?=\\b))`; - export const CardinalNumberMap: ReadonlyMap = new Map([["zero", 0],["hum", 1],["um", 1],["uma", 1],["dois", 2],["duas", 2],["meia", 2],["meio", 2],["tres", 3],["três", 3],["quatro", 4],["cinco", 5],["seis", 6],["sete", 7],["oito", 8],["nove", 9],["dez", 10],["dezena", 10],["déz", 10],["onze", 11],["doze", 12],["dúzia", 12],["duzia", 12],["dúzias", 12],["duzias", 12],["treze", 13],["catorze", 14],["quatorze", 14],["quinze", 15],["dezesseis", 16],["dezasseis", 16],["dezessete", 17],["dezassete", 17],["dezoito", 18],["dezenove", 19],["dezanove", 19],["vinte", 20],["trinta", 30],["quarenta", 40],["cinquenta", 50],["cincoenta", 50],["sessenta", 60],["setenta", 70],["oitenta", 80],["noventa", 90],["cem", 100],["cento", 100],["duzentos", 200],["duzentas", 200],["trezentos", 300],["trezentas", 300],["quatrocentos", 400],["quatrocentas", 400],["quinhentos", 500],["quinhentas", 500],["seiscentos", 600],["seiscentas", 600],["setecentos", 700],["setecentas", 700],["oitocentos", 800],["oitocentas", 800],["novecentos", 900],["novecentas", 900],["mil", 1000],["milhão", 1000000],["milhao", 1000000],["milhões", 1000000],["milhoes", 1000000],["bilhão", 1000000000],["bilhao", 1000000000],["bilhões", 1000000000],["bilhoes", 1000000000],["trilhão", 1000000000000],["trilhao", 1000000000000],["trilhões", 1000000000000],["trilhoes", 1000000000000]]); - export const OrdinalNumberMap: ReadonlyMap = new Map([["primeiro", 1],["primeira", 1],["segundo", 2],["segunda", 2],["terceiro", 3],["terceira", 3],["terço", 3],["terça", 3],["quarto", 4],["quarta", 4],["quinto", 5],["quinta", 5],["sexto", 6],["sexta", 6],["sétimo", 7],["setimo", 7],["sétima", 7],["setima", 7],["oitavo", 8],["oitava", 8],["nono", 9],["nona", 9],["décimo", 10],["decimo", 10],["décima", 10],["decima", 10],["undécimo", 11],["undecimo", 11],["undécima", 11],["undecima", 11],["duodécimo", 11],["duodecimo", 11],["duodécima", 11],["duodecima", 11],["vigésimo", 20],["vigesimo", 20],["vigésima", 20],["vigesima", 20],["trigésimo", 30],["trigesimo", 30],["trigésima", 30],["trigesima", 30],["quadragésimo", 40],["quadragesimo", 40],["quadragésima", 40],["quadragesima", 40],["quinquagésimo", 50],["quinquagesimo", 50],["quinquagésima", 50],["quinquagesima", 50],["sexagésimo", 60],["sexagesimo", 60],["sexagésima", 60],["sexagesima", 60],["septuagésimo", 70],["septuagesimo", 70],["septuagésima", 70],["septuagesima", 70],["setuagésimo", 70],["setuagesimo", 70],["setuagésima", 70],["setuagesima", 70],["octogésimo", 80],["octogesimo", 80],["octogésima", 80],["octogesima", 80],["nonagésimo", 90],["nonagesimo", 90],["nonagésima", 90],["nonagesima", 90],["centesimo", 100],["centésimo", 100],["centesima", 100],["centésima", 100],["ducentésimo", 200],["ducentesimo", 200],["ducentésima", 200],["ducentesima", 200],["tricentésimo", 300],["tricentesimo", 300],["tricentésima", 300],["tricentesima", 300],["trecentésimo", 300],["trecentesimo", 300],["trecentésima", 300],["trecentesima", 300],["quadringentésimo", 400],["quadringentesimo", 400],["quadringentésima", 400],["quadringentesima", 400],["quadrigentésimo", 400],["quadrigentesimo", 400],["quadrigentésima", 400],["quadrigentesima", 400],["quingentésimo", 500],["quingentesimo", 500],["quingentésima", 500],["quingentesima", 500],["sexcentésimo", 600],["sexcentesimo", 600],["sexcentésima", 600],["sexcentesima", 600],["seiscentésimo", 600],["seiscentesimo", 600],["seiscentésima", 600],["seiscentesima", 600],["septingentésimo", 700],["septingentesimo", 700],["septingentésima", 700],["septingentesima", 700],["setingentésimo", 700],["setingentesimo", 700],["setingentésima", 700],["setingentesima", 700],["octingentésimo", 800],["octingentesimo", 800],["octingentésima", 800],["octingentesima", 800],["noningentésimo", 900],["noningentesimo", 900],["noningentésima", 900],["noningentesima", 900],["nongentésimo", 900],["nongentesimo", 900],["nongentésima", 900],["nongentesima", 900],["milésimo", 1000],["milesimo", 1000],["milésima", 1000],["milesima", 1000],["milionésimo", 1000000],["milionesimo", 1000000],["milionésima", 1000000],["milionesima", 1000000],["bilionésimo", 1000000000],["bilionesimo", 1000000000],["bilionésima", 1000000000],["bilionesima", 1000000000]]); - export const PrefixCardinalMap: ReadonlyMap = new Map([["hum", 1],["um", 1],["dois", 2],["tres", 3],["três", 3],["quatro", 4],["cinco", 5],["seis", 6],["sete", 7],["oito", 8],["nove", 9],["dez", 10],["onze", 11],["doze", 12],["treze", 13],["catorze", 14],["quatorze", 14],["quinze", 15],["dezesseis", 16],["dezasseis", 16],["dezessete", 17],["dezassete", 17],["dezoito", 18],["dezenove", 19],["dezanove", 19],["vinte", 20],["trinta", 30],["quarenta", 40],["cinquenta", 50],["cincoenta", 50],["sessenta", 60],["setenta", 70],["oitenta", 80],["noventa", 90],["cem", 100],["duzentos", 200],["trezentos", 300],["quatrocentos", 400],["quinhentos", 500],["seiscentos", 600],["setecentos", 700],["oitocentos", 800],["novecentos", 900]]); - export const SuffixOrdinalMap: ReadonlyMap = new Map([["milesimo", 1000],["milionesimo", 1000000],["bilionesimo", 1000000000],["trilionesimo", 1000000000000]]); - export const RoundNumberMap: ReadonlyMap = new Map([["mil", 1000],["milesimo", 1000],["milhão", 1000000],["milhao", 1000000],["milhões", 1000000],["milhoes", 1000000],["milionésimo", 1000000],["milionesimo", 1000000],["bilhão", 1000000000],["bilhao", 1000000000],["bilhões", 1000000000],["bilhoes", 1000000000],["bilionésimo", 1000000000],["bilionesimo", 1000000000],["trilhão", 1000000000000],["trilhao", 1000000000000],["trilhões", 1000000000000],["trilhoes", 1000000000000],["trilionésimo", 1000000000000],["trilionesimo", 1000000000000],["dezena", 10],["dezenas", 10],["dúzia", 12],["duzia", 12],["dúzias", 12],["duzias", 12],["k", 1000],["m", 1000000],["g", 1000000000],["b", 1000000000],["t", 1000000000000]]); - export const AmbiguityFiltersDict: ReadonlyMap = new Map([["^[.]", ""]]); - export const RelativeReferenceOffsetMap: ReadonlyMap = new Map([["proxima", ""],["proximo", ""],["próxima", ""],["próximo", ""],["proximas", ""],["proximos", ""],["próximas", ""],["próximos", ""],["ultima", ""],["ultimo", ""],["última", ""],["último", ""],["ultimas", ""],["ultimos", ""],["últimas", ""],["últimos", ""],["penultima", ""],["penultimo", ""],["penúltima", ""],["penúltimo", ""],["penultimas", ""],["penultimos", ""],["penúltimas", ""],["penúltimos", ""],["ultima mas um", ""],["ultimo mas um", ""],["última mas um", ""],["último mas um", ""],["anterior ao último", ""],["anterior ao última", ""],["antepenultima", ""],["antepenultimo", ""],["antepenúltima", ""],["antepenúltimo", ""],["antepenultimas", ""],["antepenultimos", ""],["antepenúltimas", ""],["antepenúltimos", ""],["seguinte", ""],["seguintes", ""],["anterior", ""],["anteriores", ""],["atual", ""],["atuais", ""]]); - export const RelativeReferenceRelativeToMap: ReadonlyMap = new Map([["proxima", "current"],["proximo", "current"],["próxima", "current"],["próximo", "current"],["proximas", "current"],["proximos", "current"],["próximas", "current"],["próximos", "current"],["ultima", "end"],["ultimo", "end"],["última", "end"],["último", "end"],["ultimas", "end"],["ultimos", "end"],["últimas", "end"],["últimos", "end"],["penultima", "end"],["penultimo", "end"],["penúltima", "end"],["penúltimo", "end"],["penultimas", "end"],["penultimos", "end"],["penúltimas", "end"],["penúltimos", "end"],["ultima mas um", "end"],["ultimo mas um", "end"],["última mas um", "end"],["último mas um", "end"],["anterior ao último", "end"],["anterior ao última", "end"],["antepenultima", "end"],["antepenultimo", "end"],["antepenúltima", "end"],["antepenúltimo", "end"],["antepenultimas", "end"],["antepenultimos", "end"],["antepenúltimas", "end"],["antepenúltimos", "end"],["seguinte", "current"],["seguintes", "current"],["anterior", "current"],["anteriores", "current"],["atual", "current"],["atuais", "current"]]); -} diff --git a/JavaScript/packages/recognizers-number/src/resources/spanishNumeric.ts b/JavaScript/packages/recognizers-number/src/resources/spanishNumeric.ts deleted file mode 100644 index 35ac9d7e02..0000000000 --- a/JavaScript/packages/recognizers-number/src/resources/spanishNumeric.ts +++ /dev/null @@ -1,125 +0,0 @@ -// ------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// ------------------------------------------------------------------------------ - -import { BaseNumbers } from "./baseNumbers"; -export namespace SpanishNumeric { - export const LangMarker = `Spa`; - export const CompoundNumberLanguage = false; - export const MultiDecimalSeparatorCulture = true; - export const NonStandardSeparatorVariants = [ "es-mx","es-do","es-sv","es-gt","es-hn","es-ni","es-pa","es-pr" ]; - export const HundredsNumberIntegerRegex = `(cuatrocient[ao]s|trescient[ao]s|seiscient[ao]s|setecient[ao]s|ochocient[ao]s|novecient[ao]s|doscient[ao]s|quinient[ao]s|(?(? { return `(((?(antes\\s+de|anterior\\s+a)(l|\\s+la)\\s+[uú]ltim[ao]|((ante)?pen)?[uú]ltim[ao]s?|pr[oó]xim[ao]s?|anterior(es)?|actual(es)?|siguientes?)`; - export const ComplexOrdinalRegex = `((${OverThousandOrdinalRegex}(\\s)?)?${UnderThousandOrdinalRegex}|${OverThousandOrdinalRegex})`; - export const SufixRoundOrdinalRegex = `((${AllIntRegex})(${SimpleRoundOrdinalRegex}))`; - export const ComplexRoundOrdinalRegex = `(((${SufixRoundOrdinalRegex}(\\s)?)?${ComplexOrdinalRegex})|${SufixRoundOrdinalRegex})`; - export const AllOrdinalNumberRegex = `${ComplexOrdinalRegex}|${SimpleRoundOrdinalRegex}|${ComplexRoundOrdinalRegex}`; - export const AllOrdinalRegex = `(?:${AllOrdinalNumberRegex}s?|${RelativeOrdinalRegex})`; - export const OrdinalSuffixRegex = `(?<=\\b)(\\d*((1(er|r[oa])|2d[oa]|3r[oa]|4t[oa]|5t[oa]|6t[oa]|7m[oa]|8v[oa]|9n[oa]|0m[oa]|11[vm][oa]|12[vm][oa])|\\d\\.?[ºª]))(?=\\b)`; - export const OrdinalNounRegex = `(?<=\\b)${AllOrdinalRegex}(?=\\b)`; - export const SpecialFractionInteger = `(((${AllIntRegex})i?(${ZeroToNineIntegerRegex})|(${AllIntRegex}))a?v[oa]s?)`; - export const FractionNotationRegex = `${BaseNumbers.FractionNotationRegex}`; - export const FractionNotationWithSpacesRegex = `(((?<=\\W|^)-\\s*)|(?<=\\b))\\d+\\s+\\d+[/]\\d+(?=(\\b[^/]|$))`; - export const FractionMultiplierRegex = `(?\\s+(y|con)\\s+(medio|(un|${TwoToNineIntegerRegex})\\s+(medio|terci[oa]?|cuart[oa]|quint[oa]|sext[oa]|s[eé]ptim[oa]|octav[oa]|noven[oa]|d[eé]cim[oa])s?))`; - export const RoundMultiplierWithFraction = `(?(?:(mil\\s+millones|mill[oó]n(es)?|bill[oó]n(es)?|trill[oó]n(es)?|cuatrill[oó]n(es)?|quintill[oó]n(es)?|sextill[oó]n(es)?|septill[oó]n(es)?)))(?=${FractionMultiplierRegex}?$)`; - export const RoundMultiplierRegex = `\\b\\s*(${RoundMultiplierWithFraction}|(?(mil))$)`; - export const FractionNounRegex = `(?<=\\b)(${AllIntRegex}\\s+((y|con)\\s+)?)?(${AllIntRegex}\\s+(((${AllOrdinalNumberRegex}|${SufixRoundOrdinalRegex})s|${SpecialFractionInteger})|((y|con)\\s+)?(medi[oa]s?|tercios?))|(medio|un\\s+cuarto\\s+de)\\s+${RoundNumberIntegerRegex})(?=\\b)`; - export const FractionNounWithArticleRegex = `(?<=\\b)((${AllIntRegex}|${RoundNumberIntegerRegexWithLocks})\\s+((y|con)\\s+)?)?((un|un[oa])(\\s+)((${AllOrdinalNumberRegex})|(${SufixRoundOrdinalRegex}))|(un[ao]?\\s+)?medi[oa]s?|mitad)(?=\\b)`; - export const FractionPrepositionRegex = `(?(${AllIntRegex})|((?(${AllIntRegex})|((\\d+)(?!\\.)))(?=\\b)`; - export const AllPointRegex = `((\\s+${ZeroToNineIntegerRegex})+|(\\s+${AllIntRegex}))`; - export const AllFloatRegex = `${AllIntRegex}(\\s+(coma|con))${AllPointRegex}`; - export const DoubleDecimalPointRegex = (placeholder: string) => { return `(((? { return `(?<=\\s|^)(?)`; - export const LessRegex = `((meno(s|r(es)?)|inferior(es)?|por\\s+debajo)((\\s+(que|del?|al?)|(?=\\s+o\\b)))|más\\s+baj[oa]\\s+que|(?|=)<)`; - export const EqualRegex = `((igual(es)?|equivalente(s)?|equivalen?)(\\s+(al?|que|del?))?|(?)=)`; - export const MoreOrEqualPrefix = `((no\\s+${LessRegex})|(por\\s+lo\\s+menos|como\\s+m[íi]nimo|al\\s+menos))`; - export const MoreOrEqual = `((${MoreRegex}\\s+(o)?\\s+${EqualRegex})|(${EqualRegex}\\s+(o|y)\\s+${MoreRegex})|${MoreOrEqualPrefix}(\\s+(o)\\s+${EqualRegex})?|(${EqualRegex}\\s+(o)\\s+)?${MoreOrEqualPrefix}|>\\s*=)`; - export const MoreOrEqualSuffix = `((\\b(y|o)\\b\\s+(m[áa]s|mayor(es)?|superior(es)?)((?!\\s+(alt[oa]|baj[oa]|que|del?|al?))|(\\s+(que|del?|al?)(?!(\\s*\\d+)))))|como\\s+m[íi]nimo|por\\s+lo\\s+menos|al\\s+menos)\\b`; - export const LessOrEqualPrefix = `((no\\s+${MoreRegex})|(como\\s+(m[aá]ximo|mucho)))`; - export const LessOrEqual = `((${LessRegex}\\s+(o)?\\s+${EqualRegex})|(${EqualRegex}\\s+(o)?\\s+${LessRegex})|${LessOrEqualPrefix}(\\s+(o)?\\s+${EqualRegex})?|(${EqualRegex}\\s+(o)?\\s+)?${LessOrEqualPrefix}|<\\s*=)`; - export const LessOrEqualSuffix = `((\\b(y|o)\\b\\s+(meno(s|r(es)?|inferior(es)?))((?!\\s+(alt[oa]|baj[oa]|que|del?|al?))|(\\s+(que|del?|al?)(?!(\\s*\\d+)))))|como\\s+m[áa]ximo)\\b`; - export const NumberSplitMark = `(?![,.](?!\\d+))(?!\\s*\\b(((y|e)\\s+)?(${LessRegex}|${MoreRegex}|${EqualRegex}|no|de)|pero|o|a)\\b)`; - export const MoreRegexNoNumberSucceed = `(\\b(m[áa]s|mayor(es)?|superior(es)?)((?!\\s+(que|del?|al?))|\\s+((que|del?)(?!(\\s*\\d+))))|(por encima)(?!(\\s*\\d+)))\\b`; - export const LessRegexNoNumberSucceed = `(\\b(meno(s|r(es)?)|inferior(es)?)((?!\\s+(que|del?|al?))|\\s+((que|del?|al?)(?!(\\s*\\d+))))|(por debajo)(?!(\\s*\\d+)))\\b`; - export const EqualRegexNoNumberSucceed = `(\\b(igual(es)?|equivalentes?|equivalen?)((?!\\s+(al?|que|del?))|(\\s+(al?|que|del?)(?!(\\s*\\d+)))))\\b`; - export const OneNumberRangeMoreRegex1 = `(${MoreOrEqual}|${MoreRegex})\\s*((el|las?|los)\\s+)?(?(${NumberSplitMark}.)+)`; - export const OneNumberRangeMoreRegex1LB = `(?(${NumberSplitMark}.)+)\\s*${MoreOrEqualSuffix}`; - export const OneNumberRangeMoreSeparateRegex = `(${EqualRegex}\\s+(?(${NumberSplitMark}.)+)(\\s+o\\s+)${MoreRegexNoNumberSucceed})|(${MoreRegex}\\s+(?(${NumberSplitMark}.)+)(\\s+o\\s+)${EqualRegexNoNumberSucceed})`; - export const OneNumberRangeLessRegex1 = `(${LessOrEqual}|${LessRegex})\\s*((el|las?|los)\\s+)?(?(${NumberSplitMark}.)+)`; - export const OneNumberRangeLessRegex1LB = `(?(${NumberSplitMark}.)+)\\s*${LessOrEqualSuffix}`; - export const OneNumberRangeLessSeparateRegex = `(${EqualRegex}\\s+(?(${NumberSplitMark}.)+)(\\s+o\\s+)${LessRegexNoNumberSucceed})|(${LessRegex}\\s+(?(${NumberSplitMark}.)+)(\\s+o\\s+)${EqualRegexNoNumberSucceed})`; - export const OneNumberRangeEqualRegex = `${EqualRegex}\\s*((el|las?|los)\\s+)?(?(${NumberSplitMark}.)+)`; - export const TwoNumberRangeRegex1 = `\\bentre\\s*((el|las?|los)\\s+)?(?(${NumberSplitMark}.)+)\\s*y\\s*((el|las?|los)\\s+)?(?(${NumberSplitMark}.)+)`; - export const TwoNumberRangeRegex2 = `(${OneNumberRangeMoreRegex1}|${OneNumberRangeMoreRegex2})\\s*(\\by\\b|\\be\\b|pero|,)\\s*(${OneNumberRangeLessRegex1}|${OneNumberRangeLessRegex2})`; - export const TwoNumberRangeRegex3 = `(${OneNumberRangeLessRegex1}|${OneNumberRangeLessRegex2})\\s*(\\by\\b|\\be\\b|pero|,)\\s*(${OneNumberRangeMoreRegex1}|${OneNumberRangeMoreRegex2})`; - export const TwoNumberRangeRegex4 = `(\\bde(sde)?\\s+)?(\\b(el|las?|los)\\s+)?\\b(?!\\s+)(?(${NumberSplitMark}(?!\\b(entre|de(sde)?|es)\\b).)+)\\b\\s*${TillRegex}\\s*((el|las?|los)\\s+)?\\b(?!\\s+)(?(${NumberSplitMark}.)+)\\b`; - export const AmbiguousFractionConnectorsRegex = `(\\b(en|de)\\b)`; - export const DecimalSeparatorChar = `,`; - export const FractionMarkerToken = `sobre`; - export const NonDecimalSeparatorChar = `.`; - export const HalfADozenText = `seis`; - export const WordSeparatorToken = `y`; - export const WrittenDecimalSeparatorTexts = [ "coma","con" ]; - export const WrittenGroupSeparatorTexts = [ "punto" ]; - export const WrittenIntegerSeparatorTexts = [ "y" ]; - export const WrittenFractionSeparatorTexts = [ "con" ]; - export const OneHalfTokens = [ "un","medio" ]; - export const HalfADozenRegex = `media\\s+docena`; - export const DigitalNumberRegex = `((?<=\\b)(mil(l[oó]n(es)?)?|bill[oó]n(es)?|trill[oó]n(es)?|(docena|dz|doz)s?)(?=\\b))|((?<=(\\d|\\b))${BaseNumbers.MultiplierLookupRegex}(?=\\b))`; - export const CardinalNumberMap: ReadonlyMap = new Map([["cero", 0],["un", 1],["una", 1],["uno", 1],["dos", 2],["tres", 3],["cuatro", 4],["cinco", 5],["seis", 6],["siete", 7],["ocho", 8],["nueve", 9],["diez", 10],["once", 11],["doce", 12],["docena", 12],["docenas", 12],["dz", 12],["doz", 12],["dzs", 12],["dozs", 12],["trece", 13],["catorce", 14],["quince", 15],["dieciseis", 16],["dieciséis", 16],["diecisiete", 17],["dieciocho", 18],["diecinueve", 19],["veinte", 20],["ventiuna", 21],["ventiuno", 21],["veintiun", 21],["veintiún", 21],["veintiuno", 21],["veintiuna", 21],["veintidos", 22],["veintidós", 22],["veintitres", 23],["veintitrés", 23],["veinticuatro", 24],["veinticinco", 25],["veintiseis", 26],["veintiséis", 26],["veintisiete", 27],["veintiocho", 28],["veintinueve", 29],["treinta", 30],["cuarenta", 40],["cincuenta", 50],["sesenta", 60],["setenta", 70],["ochenta", 80],["noventa", 90],["cien", 100],["ciento", 100],["doscientas", 200],["doscientos", 200],["trescientas", 300],["trescientos", 300],["cuatrocientas", 400],["cuatrocientos", 400],["quinientas", 500],["quinientos", 500],["seiscientas", 600],["seiscientos", 600],["setecientas", 700],["setecientos", 700],["ochocientas", 800],["ochocientos", 800],["novecientas", 900],["novecientos", 900],["mil", 1000],["millon", 1000000],["millón", 1000000],["millones", 1000000],["billon", 1000000000000],["billón", 1000000000000],["billones", 1000000000000],["trillon", 1000000000000000000],["trillón", 1000000000000000000],["trillones", 1000000000000000000]]); - export const OrdinalNumberMap: ReadonlyMap = new Map([["primero", 1],["primera", 1],["primer", 1],["segundo", 2],["segunda", 2],["medio", 2],["media", 2],["mitad", 2],["tercero", 3],["tercera", 3],["tercer", 3],["tercio", 3],["cuarto", 4],["cuarta", 4],["quinto", 5],["quinta", 5],["sexto", 6],["sexta", 6],["septimo", 7],["septima", 7],["séptimo", 7],["séptima", 7],["octavo", 8],["octava", 8],["noveno", 9],["novena", 9],["decimo", 10],["décimo", 10],["decima", 10],["décima", 10],["undecimo", 11],["undecima", 11],["undécimo", 11],["undécima", 11],["duodecimo", 12],["duodecima", 12],["duodécimo", 12],["duodécima", 12],["decimotercero", 13],["decimotercera", 13],["decimocuarto", 14],["decimocuarta", 14],["decimoquinto", 15],["decimoquinta", 15],["decimosexto", 16],["decimosexta", 16],["decimoseptimo", 17],["decimoseptima", 17],["decimoctavo", 18],["decimoctava", 18],["decimonoveno", 19],["decimonovena", 19],["vigesimo", 20],["vigesima", 20],["vigésimo", 20],["vigésima", 20],["trigesimo", 30],["trigesima", 30],["trigésimo", 30],["trigésima", 30],["cuadragesimo", 40],["cuadragesima", 40],["cuadragésimo", 40],["cuadragésima", 40],["quincuagesimo", 50],["quincuagesima", 50],["quincuagésimo", 50],["quincuagésima", 50],["sexagesimo", 60],["sexagesima", 60],["sexagésimo", 60],["sexagésima", 60],["septuagesimo", 70],["septuagesima", 70],["septuagésimo", 70],["septuagésima", 70],["octogesimo", 80],["octogesima", 80],["octogésimo", 80],["octogésima", 80],["nonagesimo", 90],["nonagesima", 90],["nonagésimo", 90],["nonagésima", 90],["centesimo", 100],["centesima", 100],["centésimo", 100],["centésima", 100],["ducentesimo", 200],["ducentesima", 200],["ducentésimo", 200],["ducentésima", 200],["tricentesimo", 300],["tricentesima", 300],["tricentésimo", 300],["tricentésima", 300],["cuadringentesimo", 400],["cuadringentesima", 400],["cuadringentésimo", 400],["cuadringentésima", 400],["quingentesimo", 500],["quingentesima", 500],["quingentésimo", 500],["quingentésima", 500],["sexcentesimo", 600],["sexcentesima", 600],["sexcentésimo", 600],["sexcentésima", 600],["septingentesimo", 700],["septingentesima", 700],["septingentésimo", 700],["septingentésima", 700],["octingentesimo", 800],["octingentesima", 800],["octingentésimo", 800],["octingentésima", 800],["noningentesimo", 900],["noningentesima", 900],["noningentésimo", 900],["noningentésima", 900],["milesimo", 1000],["milesima", 1000],["milésimo", 1000],["milésima", 1000],["millonesimo", 1000000],["millonesima", 1000000],["millonésimo", 1000000],["millonésima", 1000000],["billonesimo", 1000000000000],["billonesima", 1000000000000],["billonésimo", 1000000000000],["billonésima", 1000000000000],["primeros", 1],["primeras", 1],["segundos", 2],["segundas", 2],["terceros", 3],["terceras", 3],["tercios", 3],["cuartos", 4],["cuartas", 4],["quintos", 5],["quintas", 5],["sextos", 6],["sextas", 6],["septimos", 7],["septimas", 7],["séptimos", 7],["séptimas", 7],["octavos", 8],["octavas", 8],["novenos", 9],["novenas", 9],["decimos", 10],["décimos", 10],["decimas", 10],["décimas", 10],["undecimos", 11],["undecimas", 11],["undécimos", 11],["undécimas", 11],["duodecimos", 12],["duodecimas", 12],["duodécimos", 12],["duodécimas", 12],["decimoterceros", 13],["decimoterceras", 13],["decimocuartos", 14],["decimocuartas", 14],["decimoquintos", 15],["decimoquintas", 15],["decimosextos", 16],["decimosextas", 16],["decimoseptimos", 17],["decimoseptimas", 17],["decimoctavos", 18],["decimoctavas", 18],["decimonovenos", 19],["decimonovenas", 19],["vigesimos", 20],["vigesimas", 20],["vigésimos", 20],["vigésimas", 20],["trigesimos", 30],["trigesimas", 30],["trigésimos", 30],["trigésimas", 30],["cuadragesimos", 40],["cuadragesimas", 40],["cuadragésimos", 40],["cuadragésimas", 40],["quincuagesimos", 50],["quincuagesimas", 50],["quincuagésimos", 50],["quincuagésimas", 50],["sexagesimos", 60],["sexagesimas", 60],["sexagésimos", 60],["sexagésimas", 60],["septuagesimos", 70],["septuagesimas", 70],["septuagésimos", 70],["septuagésimas", 70],["octogesimos", 80],["octogesimas", 80],["octogésimos", 80],["octogésimas", 80],["nonagesimos", 90],["nonagesimas", 90],["nonagésimos", 90],["nonagésimas", 90],["centesimos", 100],["centesimas", 100],["centésimos", 100],["centésimas", 100],["ducentesimos", 200],["ducentesimas", 200],["ducentésimos", 200],["ducentésimas", 200],["tricentesimos", 300],["tricentesimas", 300],["tricentésimos", 300],["tricentésimas", 300],["cuadringentesimos", 400],["cuadringentesimas", 400],["cuadringentésimos", 400],["cuadringentésimas", 400],["quingentesimos", 500],["quingentesimas", 500],["quingentésimos", 500],["quingentésimas", 500],["sexcentesimos", 600],["sexcentesimas", 600],["sexcentésimos", 600],["sexcentésimas", 600],["septingentesimos", 700],["septingentesimas", 700],["septingentésimos", 700],["septingentésimas", 700],["octingentesimos", 800],["octingentesimas", 800],["octingentésimos", 800],["octingentésimas", 800],["noningentesimos", 900],["noningentesimas", 900],["noningentésimos", 900],["noningentésimas", 900],["milesimos", 1000],["milesimas", 1000],["milésimos", 1000],["milésimas", 1000],["millonesimos", 1000000],["millonesimas", 1000000],["millonésimos", 1000000],["millonésimas", 1000000],["billonesimos", 1000000000000],["billonesimas", 1000000000000],["billonésimos", 1000000000000],["billonésimas", 1000000000000]]); - export const PrefixCardinalMap: ReadonlyMap = new Map([["dos", 2],["tres", 3],["cuatro", 4],["cinco", 5],["seis", 6],["siete", 7],["ocho", 8],["nueve", 9],["diez", 10],["once", 11],["doce", 12],["trece", 13],["catorce", 14],["quince", 15],["dieciseis", 16],["dieciséis", 16],["diecisiete", 17],["dieciocho", 18],["diecinueve", 19],["veinte", 20],["ventiuna", 21],["veintiun", 21],["veintiún", 21],["veintidos", 22],["veintitres", 23],["veinticuatro", 24],["veinticinco", 25],["veintiseis", 26],["veintisiete", 27],["veintiocho", 28],["veintinueve", 29],["treinta", 30],["cuarenta", 40],["cincuenta", 50],["sesenta", 60],["setenta", 70],["ochenta", 80],["noventa", 90],["cien", 100],["doscientos", 200],["trescientos", 300],["cuatrocientos", 400],["quinientos", 500],["seiscientos", 600],["setecientos", 700],["ochocientos", 800],["novecientos", 900]]); - export const SuffixOrdinalMap: ReadonlyMap = new Map([["milesimo", 1000],["millonesimo", 1000000],["billonesimo", 1000000000000]]); - export const RoundNumberMap: ReadonlyMap = new Map([["mil", 1000],["milesimo", 1000],["millon", 1000000],["millón", 1000000],["millones", 1000000],["millonesimo", 1000000],["billon", 1000000000000],["billón", 1000000000000],["billones", 1000000000000],["billonesimo", 1000000000000],["trillon", 1000000000000000000],["trillón", 1000000000000000000],["trillones", 1000000000000000000],["trillonesimo", 1000000000000000000],["docena", 12],["docenas", 12],["dz", 12],["doz", 12],["dzs", 12],["dozs", 12],["k", 1000],["m", 1000000],["g", 1000000000],["b", 1000000000],["t", 1000000000000]]); - export const AmbiguityFiltersDict: ReadonlyMap = new Map([["^[.]", ""]]); - export const RelativeReferenceOffsetMap: ReadonlyMap = new Map([["proxima", ""],["proximo", ""],["proximas", ""],["proximos", ""],["próxima", ""],["próximo", ""],["próximas", ""],["próximos", ""],["anterior", ""],["anteriores", ""],["actual", ""],["actuales", ""],["siguiente", ""],["siguientes", ""],["ultima", ""],["ultimo", ""],["última", ""],["último", ""],["ultimas", ""],["ultimos", ""],["últimas", ""],["últimos", ""],["penultima", ""],["penultimo", ""],["penúltima", ""],["penúltimo", ""],["penultimas", ""],["penultimos", ""],["penúltimas", ""],["penúltimos", ""],["antepenultima", ""],["antepenultimo", ""],["antepenúltima", ""],["antepenúltimo", ""],["antepenultimas", ""],["antepenultimos", ""],["antepenúltimas", ""],["antepenúltimos", ""],["antes de la ultima", ""],["antes del ultimo", ""],["antes de la última", ""],["antes del último", ""],["anterior al ultimo", ""],["anterior a la ultima", ""],["anterior al último", ""],["anterior a la última", ""]]); - export const RelativeReferenceRelativeToMap: ReadonlyMap = new Map([["proxima", "current"],["proximo", "current"],["proximas", "current"],["proximos", "current"],["próxima", "current"],["próximo", "current"],["próximas", "current"],["próximos", "current"],["anterior", "current"],["anteriores", "current"],["actual", "current"],["actuales", "current"],["siguiente", "current"],["siguientes", "current"],["ultima", "end"],["ultimo", "end"],["última", "end"],["último", "end"],["ultimas", "end"],["ultimos", "end"],["últimas", "end"],["últimos", "end"],["penultima", "end"],["penultimo", "end"],["penúltima", "end"],["penúltimo", "end"],["penultimas", "end"],["penultimos", "end"],["penúltimas", "end"],["penúltimos", "end"],["antepenultima", "end"],["antepenultimo", "end"],["antepenúltima", "end"],["antepenúltimo", "end"],["antepenultimas", "end"],["antepenultimos", "end"],["antepenúltimas", "end"],["antepenúltimos", "end"],["antes de la ultima", "end"],["antes del ultimo", "end"],["antes de la última", "end"],["antes del último", "end"],["anterior al ultimo", "end"],["anterior a la ultima", "end"],["anterior al último", "end"],["anterior a la última", "end"]]); -} diff --git a/JavaScript/packages/recognizers-number/tsconfig.json b/JavaScript/packages/recognizers-number/tsconfig.json deleted file mode 100644 index 35ad0e3efa..0000000000 --- a/JavaScript/packages/recognizers-number/tsconfig.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "target": "es2015", - "outDir": "compiled", - "sourceMap": true, - "rootDir": "src", - "moduleResolution": "node", - "declaration": true, - "declarationDir": "dist/types", - "allowSyntheticDefaultImports": true, - "typeRoots": [ - "node_modules/@types" - ] - }, - "include": [ - "src" - ] -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-sequence/.npmignore b/JavaScript/packages/recognizers-sequence/.npmignore deleted file mode 100644 index 757fb9517d..0000000000 --- a/JavaScript/packages/recognizers-sequence/.npmignore +++ /dev/null @@ -1,4 +0,0 @@ -* -!dist/*.js -!dist/types/**/* -!README.md \ No newline at end of file diff --git a/JavaScript/packages/recognizers-sequence/README.md b/JavaScript/packages/recognizers-sequence/README.md deleted file mode 100644 index a25fca7e03..0000000000 --- a/JavaScript/packages/recognizers-sequence/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# Microsoft.Recognizers.Text for JavaScript - -This module (`recognizers-text-sequence`) is a sub-module of `recognizers-text-suite`. - -Please check the [main README](https://github.com/Microsoft/Recognizers-Text/tree/master/JavaScript/packages/recognizers-text-suite) for more details. \ No newline at end of file diff --git a/JavaScript/packages/recognizers-sequence/package-lock.json b/JavaScript/packages/recognizers-sequence/package-lock.json deleted file mode 100644 index 4dc7aade79..0000000000 --- a/JavaScript/packages/recognizers-sequence/package-lock.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "requires": true, - "lockfileVersion": 1, - "dependencies": { - "grapheme-splitter": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/grapheme-splitter/-/grapheme-splitter-1.0.2.tgz", - "integrity": "sha1-Y56dwb8GWJLGQ94x2qJ89YsQaOI=" - } - }, - "version": "1.3.0" -} diff --git a/JavaScript/packages/recognizers-sequence/package.json b/JavaScript/packages/recognizers-sequence/package.json deleted file mode 100644 index ce8174313c..0000000000 --- a/JavaScript/packages/recognizers-sequence/package.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "name": "@microsoft/recognizers-text-sequence", - "version": "1.3.0", - "description": "recognizers-text-sequence provides robust recognition and resolution of series entities like phone numbers, URLs, and e-mail and IP addresses.", - "author": "Microsoft Corp.", - "license": "MIT", - "keywords": [ - "nlp", - "nlp-entity-extraction", - "entity-extraction", - "phonenumber", - "ipaddress", - "parser-library" - ], - "main": "dist/recognizers-text-sequence.umd.js", - "module": "dist/recognizers-text-sequence.es5.js", - "typings": "dist/types/recognizers-text-sequence.d.ts", - "browser": "dist/recognizers-text-sequence.browser.js", - "repository": { - "type": "git", - "url": "https://github.com/Microsoft/Recognizers-Text" - }, - "bugs": { - "url": "https://github.com/Microsoft/Recognizers-Text/issues" - }, - "engines": { - "node": ">=10.3.0" - }, - "scripts": { - "build-resources": "ts-node --project ../resource-generator/tsconfig.json ../resource-generator/ ../recognizers-sequence/resource-definitions.json", - "clean-build": "rimraf dist && rimraf compiled", - "prepare": "npm run build-resources && npm run clean-build && tsc && rollup -c" - }, - "dependencies": { - "@microsoft/recognizers-text": "~1.3.0", - "grapheme-splitter": "^1.0.2" - } -} diff --git a/JavaScript/packages/recognizers-sequence/resource-definitions.json b/JavaScript/packages/recognizers-sequence/resource-definitions.json deleted file mode 100644 index 5538eba53a..0000000000 --- a/JavaScript/packages/recognizers-sequence/resource-definitions.json +++ /dev/null @@ -1,106 +0,0 @@ -{ - "outputPath": "./src/resources/", - "configFiles": [ - { - "input": [ "Base-PhoneNumbers" ], - "output": "basePhoneNumbers", - "header": [ - "export namespace BasePhoneNumbers {" - ], - "footer": [ "}" ] - }, - { - "input": [ "Base-Ip" ], - "output": "baseIp", - "header": [ - "export namespace BaseIp {" - ], - "footer": [ "}" ] - }, - { - "input": [ "Base-Mention" ], - "output": "baseMention", - "header": [ - "export namespace BaseMention {" - ], - "footer": [ "}" ] - }, - { - "input": [ "Base-Hashtag" ], - "output": "baseHashtag", - "header": [ - "export namespace BaseHashtag {" - ], - "footer": [ "}" ] - }, - { - "input": [ "Base-URL" ], - "output": "baseURL", - "header": [ - "import { BaseIp } from \"./baseIp\";", - "export namespace BaseURL {" - ], - "footer": [ "}" ] - }, - { - "input": [ "Base-Email" ], - "output": "baseEmail", - "header": [ - "export namespace BaseEmail {" - ], - "footer": [ "}" ] - }, - { - "input": [ "Base-GUID" ], - "output": "baseGUID", - "header": [ - "export namespace BaseGUID {" - ], - "footer": [ "}" ] - }, - { - "input": [ "English", "English-PhoneNumbers" ], - "output": "englishPhoneNumbers", - "header": [ - "export namespace EnglishPhoneNumbers {" - ], - "footer": [ "}" ] - }, - { - "input": [ "Chinese", "Chinese-URL" ], - "output": "chineseURL", - "header": [ - "import { BaseIp } from \"./baseIp\";", - "import { BaseURL } from \"./baseURL\";", - "export namespace ChineseURL {" - ], - "footer": [ "}" ] - }, - { - "input": [ "Chinese", "Chinese-PhoneNumbers" ], - "output": "chinesePhoneNumbers", - "header": [ - "export namespace ChinesePhoneNumbers {" - ], - "footer": [ "}" ] - }, - { - "input": [ "Chinese", "Chinese-Ip" ], - "output": "chineseIp", - "header": [ - "import { BaseIp } from \"./baseIp\";", - "import { ChinesePhoneNumbers as PhoneNumbersDefinitions } from \"./chinesePhoneNumbers\";", - "export namespace ChineseIp {" - ], - "footer": [ "}" ] - }, - { - "input": [ "Portuguese", "Portuguese-PhoneNumbers" ], - "output": "PortuguesePhoneNumbers", - "header": [ - "export namespace PortuguesePhoneNumbers {" - ], - "footer": [ "}" ] - } - ] -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-sequence/rollup.config.js b/JavaScript/packages/recognizers-sequence/rollup.config.js deleted file mode 100644 index 59f05f9726..0000000000 --- a/JavaScript/packages/recognizers-sequence/rollup.config.js +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import resolve from 'rollup-plugin-node-resolve'; -import commonjs from 'rollup-plugin-commonjs'; -import sourceMaps from 'rollup-plugin-sourcemaps'; -import pkg from './package.json'; -import camelCase from 'lodash.camelcase'; -import alias from 'rollup-plugin-alias'; -import path from 'path'; - -export default { - input: `compiled/recognizers-text-sequence.js`, - output: [ - { file: pkg.module, format: 'es' }, - { file: pkg.main, name: camelCase(pkg.name), format: 'umd', exports: 'named' }, - { file: pkg.browser, format: 'iife', name: camelCase(pkg.name), exports: 'named' } - ], - exports: 'named', - sourcemap: true, - plugins: [ - alias({ - '@microsoft/recognizers-text': path.resolve(__dirname, '../recognizers-text/compiled/recognizers-text.js') - }), - // Allow bundling cjs modules (unlike webpack, rollup doesn't understand cjs) - commonjs(), - // Allow node_modules resolution, so you can use 'external' to control - // which external modules to include in the bundle - // https://github.com/rollup/rollup-plugin-node-resolve#usage - resolve(), - - // Resolve source maps to the original source - sourceMaps() - ] -}; \ No newline at end of file diff --git a/JavaScript/packages/recognizers-sequence/src/recognizers-text-sequence.ts b/JavaScript/packages/recognizers-sequence/src/recognizers-text-sequence.ts deleted file mode 100644 index 8f255d8b3e..0000000000 --- a/JavaScript/packages/recognizers-sequence/src/recognizers-text-sequence.ts +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -export { default as SequenceRecognizer, SequenceOptions, recognizePhoneNumber, recognizeIpAddress, recognizeMention, recognizeHashtag, recognizeEmail, recognizeURL, recognizeGUID } from "./sequence/sequenceRecognizer"; -export { Culture } from "@microsoft/recognizers-text"; -export { AbstractSequenceModel, PhoneNumberModel, IpAddressModel, MentionModel, HashtagModel, EmailModel, URLModel, GUIDModel } from "./sequence/models"; -export { BaseSequenceExtractor, BasePhoneNumberExtractor, BaseIpExtractor, BaseMentionExtractor, BaseHashtagExtractor, BaseEmailExtractor, BaseURLExtractor, BaseGUIDExtractor } from "./sequence/extractors"; -export { EnglishPhoneNumberExtractorConfiguration, EnglishIpExtractorConfiguration, MentionExtractor, HashtagExtractor, EmailExtractor, EnglishURLExtractorConfiguration, GUIDExtractor } from "./sequence/english/extractors"; -export { ChineseURLExtractorConfiguration, ChinesePhoneNumberExtractorConfiguration, ChineseIpExtractorConfiguration } from "./sequence/chinese/extractors"; -export { PortuguesePhoneNumberExtractorConfiguration } from "./sequence/portuguese/extractors"; -export { BaseSequenceParser, BaseIpParser } from "./sequence/parsers"; -export { PhoneNumberParser, IpParser, MentionParser, HashtagParser, EmailParser, URLParser, GUIDParser } from "./sequence/english/parsers"; -export { BasePhoneNumbers } from "./resources/basePhoneNumbers"; -export { BaseIp } from "./resources/baseIp"; -export { BaseMention } from "./resources/baseMention"; -export { BaseHashtag } from "./resources/baseHashtag"; -export { BaseEmail } from "./resources/baseEmail"; -export { BaseURL } from "./resources/baseURL"; -export { BaseGUID } from "./resources/baseGUID"; \ No newline at end of file diff --git a/JavaScript/packages/recognizers-sequence/src/resources/baseEmail.ts b/JavaScript/packages/recognizers-sequence/src/resources/baseEmail.ts deleted file mode 100644 index 59e9b60b12..0000000000 --- a/JavaScript/packages/recognizers-sequence/src/resources/baseEmail.ts +++ /dev/null @@ -1,20 +0,0 @@ -// ------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// ------------------------------------------------------------------------------ - -export namespace BaseEmail { - export const EmailRegex = `(([-a-z0-9_\\+\\.]+)@([-a-z\\d\\.]+)\\.([a-z\\.]{2,6}))`; - export const IPv4Regex = `(?(\\d{1,3}\\.){3}\\d{1,3})`; - export const NormalSuffixRegex = `(([0-9a-z][-]*[0-9a-z]*\\.)+(?[a-z][\\-a-z]{0,22}[a-z]))`; - export const EmailPrefix = `(?(\"\")(\"\".+?(? -// This code was generated by a tool. -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// ------------------------------------------------------------------------------ - -export namespace BaseGUID { - export const GUIDRegexElement = `(([a-f0-9]{8}(-[a-f0-9]{4}){3}-[a-f0-9]{12})|([a-f0-9]{32}))`; - export const GUIDRegex = `(\\b${GUIDRegexElement}\\b|\\{${GUIDRegexElement}\\}|urn:uuid:${GUIDRegexElement}\\b|%7[b]${GUIDRegexElement}%7[d]|[x]\\'${GUIDRegexElement}\\')`; -} diff --git a/JavaScript/packages/recognizers-sequence/src/resources/baseHashtag.ts b/JavaScript/packages/recognizers-sequence/src/resources/baseHashtag.ts deleted file mode 100644 index 57d691ede6..0000000000 --- a/JavaScript/packages/recognizers-sequence/src/resources/baseHashtag.ts +++ /dev/null @@ -1,14 +0,0 @@ -// ------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// ------------------------------------------------------------------------------ - -export namespace BaseHashtag { - export const HashtagRegex = `((?<=\\s|^)#([a-zA-Z0-9_]+))`; -} diff --git a/JavaScript/packages/recognizers-sequence/src/resources/baseIp.ts b/JavaScript/packages/recognizers-sequence/src/resources/baseIp.ts deleted file mode 100644 index c84c3e002f..0000000000 --- a/JavaScript/packages/recognizers-sequence/src/resources/baseIp.ts +++ /dev/null @@ -1,27 +0,0 @@ -// ------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// ------------------------------------------------------------------------------ - -export namespace BaseIp { - export const Ipv4Regex = `\\b(1\\d{2}|2[0-4]\\d|25[0-5]|0?[1-9]\\d|0{0,2}\\d)((\\.(1\\d{2}|2[0-4]\\d|25[0-5]|0?[1-9]\\d|0{0,2}\\d)){3})\\b`; - export const BasicIpv6Element = `([\\da-fA-F]{1,4})`; - export const BasicIpv6Regex = `((${BasicIpv6Element}:){7}${BasicIpv6Element})`; - export const Ipv6EllipsisRegex1 = `(:(:${BasicIpv6Element}){1,7})`; - export const Ipv6EllipsisRegex2 = `((${BasicIpv6Element}:){1}((:${BasicIpv6Element}){1,6}))`; - export const Ipv6EllipsisRegex3 = `((${BasicIpv6Element}:){2}((:${BasicIpv6Element}){1,5}))`; - export const Ipv6EllipsisRegex4 = `((${BasicIpv6Element}:){3}((:${BasicIpv6Element}){1,4}))`; - export const Ipv6EllipsisRegex5 = `((${BasicIpv6Element}:){4}((:${BasicIpv6Element}){1,3}))`; - export const Ipv6EllipsisRegex6 = `((${BasicIpv6Element}:){5}((:${BasicIpv6Element}){1,2}))`; - export const Ipv6EllipsisRegex7 = `((${BasicIpv6Element}:){6}((:${BasicIpv6Element}){1}))`; - export const Ipv6EllipsisRegex8 = `((${BasicIpv6Element}:){7}(:))`; - export const Ipv6EllipsisRegexOther = `\\B::\\B|\\B:(:${BasicIpv6Element}){1,7}\\b|\\b(${BasicIpv6Element}:){1,7}:\\B`; - export const MergedIpv6Regex = `(${BasicIpv6Regex}|${Ipv6EllipsisRegex1}|${Ipv6EllipsisRegex2}|${Ipv6EllipsisRegex3}|${Ipv6EllipsisRegex4}|${Ipv6EllipsisRegex5}|${Ipv6EllipsisRegex6}|${Ipv6EllipsisRegex7}|${Ipv6EllipsisRegex8})`; - export const Ipv6Regex = `(\\b${MergedIpv6Regex}\\b)|(${Ipv6EllipsisRegexOther})`; -} diff --git a/JavaScript/packages/recognizers-sequence/src/resources/baseMention.ts b/JavaScript/packages/recognizers-sequence/src/resources/baseMention.ts deleted file mode 100644 index 3a3f2a4c7f..0000000000 --- a/JavaScript/packages/recognizers-sequence/src/resources/baseMention.ts +++ /dev/null @@ -1,14 +0,0 @@ -// ------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// ------------------------------------------------------------------------------ - -export namespace BaseMention { - export const MentionRegex = `@([a-zA-Z0-9_]+)(?![.]\\w)\\b`; -} diff --git a/JavaScript/packages/recognizers-sequence/src/resources/basePhoneNumbers.ts b/JavaScript/packages/recognizers-sequence/src/resources/basePhoneNumbers.ts deleted file mode 100644 index 7b375bdcdb..0000000000 --- a/JavaScript/packages/recognizers-sequence/src/resources/basePhoneNumbers.ts +++ /dev/null @@ -1,43 +0,0 @@ -// ------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// ------------------------------------------------------------------------------ - -export namespace BasePhoneNumbers { - export const NumberReplaceToken = `@builtin.phonenumber`; - export const WordBoundariesRegex = `\\b`; - export const NonWordBoundariesRegex = `\\B`; - export const EndWordBoundariesRegex = `\\b`; - export const PreCheckPhoneNumberRegex = `(\\d{1,4}.){2,4}\\s?\\d{2,3}`; - export const GeneralPhoneNumberRegex = (WordBoundariesRegex: string, EndWordBoundariesRegex: string) => { return `(${WordBoundariesRegex}(((\\d[\\s]?){4,12}))(-?[\\d\\s?]{3}\\d)(?!-)${EndWordBoundariesRegex})|(\\(\\d{5}\\)\\s?\\d{5,6})|\\+\\d{2}\\(\\d\\)\\d{10}`; } - export const BRPhoneNumberRegex = (WordBoundariesRegex: string, NonWordBoundariesRegex: string, EndWordBoundariesRegex: string) => { return `((\\(\\s?(\\+\\s?|00)55\\s?\\)\\s?)|(((? { return `(((${WordBoundariesRegex}(00)|${NonWordBoundariesRegex}\\+)\\s?)?(${WordBoundariesRegex}\\d{2}\\s?)?((\\s?\\(0\\)[-\\s]?|${WordBoundariesRegex}|(?<=(\\b^#)\\d{2}))\\d{2,5}|\\(0\\d{3,4}\\))[/-]?\\s?(\\d{5,8}|\\d{3,4}[-\\s]?\\d{3,4})(?!-)${EndWordBoundariesRegex})`; } - export const DEPhoneNumberRegex = (WordBoundariesRegex: string, EndWordBoundariesRegex: string) => { return `((\\+\\d{2}\\s?((\\(0\\))?\\d\\s?)?|${WordBoundariesRegex})(\\d{2,4}\\s?[-/]?[\\s\\d]{7,10}\\d)(?!-)${EndWordBoundariesRegex})`; } - export const USPhoneNumberRegex = (WordBoundariesRegex: string, NonWordBoundariesRegex: string, EndWordBoundariesRegex: string) => { return `(((((${NonWordBoundariesRegex}\\+)|${WordBoundariesRegex})1(\\s|-)?)|${WordBoundariesRegex})?(\\d{3}\\)[-\\s]?|\\(\\d{3}\\)[-\\.\\s]?|${WordBoundariesRegex}\\d{3}\\s?[-\\.]?\\s?)|${WordBoundariesRegex})[2-9]\\d{2}\\s?[-\\.]?\\s?\\d{4}(\\s?(x|X|ext)\\s?\\d{3,5})?(?!(-\\s?\\d))${EndWordBoundariesRegex}`; } - export const CNPhoneNumberRegex = (WordBoundariesRegex: string, EndWordBoundariesRegex: string) => { return `((${WordBoundariesRegex}00\\s?)?\\+?(86|82|81)\\s?-?\\s?)?(((${WordBoundariesRegex}|(?<=(86|82|81)))\\d{2,5}\\s?-?\\s?|\\(\\d{2,5}\\)\\s?)\\d{4}\\s?-?\\s?\\d{4}(\\s?-?\\s?\\d{4})?|(\\b|(?<=(86|82|81)))\\d{3}\\s?-?\\s?\\d{4}\\s?-?\\s?\\d{4})(?!-)${EndWordBoundariesRegex}`; } - export const DKPhoneNumberRegex = (WordBoundariesRegex: string, EndWordBoundariesRegex: string) => { return `((\\(\\s?(\\+\\s?|00)45\\s?\\)\\s?)|(((? { return `((\\(\\s?(\\+\\s?|00)39\\s?\\)\\s?)|(((? { return `((((\\(\\s?(\\+\\s?|00)31\\s?\\)\\s?)|(((? { return `(${WordBoundariesRegex}(\\d{3,4}[/-]\\d{1,4}[/-]\\d{3,4})${EndWordBoundariesRegex})`; } - export const NoAreaCodeUSPhoneNumberRegex = `(? = new Map([["^\\d{4}-\\d{4}$", "omb(\\s*(no(\\.)?|number|#))?:?\\s+\\d{4}-?\\d{4}"]]); - export const SpecialBoundaryMarkers = [ "-"," " ]; - export const BoundaryMarkers = [ "-",".","/","+","#","*" ]; - export const ForbiddenPrefixMarkers = [ ",",":","%" ]; - export const ForbiddenSuffixMarkers = [ "/","+","#","*",":","%" ]; - export const SSNFilterRegex = `^\\d{3}-\\d{2}-\\d{4}$`; -} diff --git a/JavaScript/packages/recognizers-sequence/src/resources/baseURL.ts b/JavaScript/packages/recognizers-sequence/src/resources/baseURL.ts deleted file mode 100644 index f423eeacf7..0000000000 --- a/JavaScript/packages/recognizers-sequence/src/resources/baseURL.ts +++ /dev/null @@ -1,24 +0,0 @@ -// ------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// ------------------------------------------------------------------------------ - -import { BaseIp } from "./baseIp"; -export namespace BaseURL { - export const ProtocolRegex = `((https?|ftp):\\/\\/)`; - export const PortRegex = `(:\\d{1,5})`; - export const ExtractionRestrictionRegex = `(?<=\\s|[\\'\"\"\\(\\[:]|^)`; - export const UrlPrefixRegex = `(${ExtractionRestrictionRegex}${ProtocolRegex}?|${ProtocolRegex})[a-zA-Z0-9][-a-zA-Z0-9._]{0,256}(?[a-zA-Z]{2,18})${UrlSuffixRegex}`; - export const UrlRegex2 = `((ht|f)tp(s?)\\:\\/\\/|www\\.)[-a-zA-Z0-9@:%._\\+~#=]{1,256}\\.(?[a-zA-Z0-9()]{1,6})\\b([-a-zA-Z0-9()@:%_\\+.~#?&//=]*)`; - export const IpUrlRegex = `(?(${ExtractionRestrictionRegex}${ProtocolRegex}(${BaseIp.Ipv4Regex}|localhost)${UrlSuffixRegex}))`; - export const AmbiguousTimeTerm = `^(1?[0-9]|2[0-3]).[ap]m$`; - export const TldList = [ "com","org","net","int","edu","gov","mil","academy","app","aws","bot","buy","cafe","city","cloud","company","eco","education","game","games","gmbh","law","limited","live","llc","ltd","ltda","map","med","news","ngo","ong","phd","place","radio","science","search","shopping","sport","store","tvs","wiki","work","ac","ad","ae","af","ag","ai","al","am","an","ao","aq","ar","as","at","au","aw","ax","az","ba","bb","bd","be","bf","bg","bh","bi","bj","bl","bm","bn","bo","bq","br","bs","bt","bv","bw","by","bz","ca","cc","cd","cf","cg","ch","ci","ck","cl","cm","cn","co","cr","cu","cv","cw","cx","cy","cz","de","dj","dk","dm","do","dz","ec","ee","eg","eh","er","es","et","eu","fi","fj","fk","fm","fo","fr","ga","gb","gd","ge","gf","gg","gh","gi","gl","gm","gn","gp","gq","gr","gs","gt","gu","gw","gy","hk","hm","hn","hr","ht","hu","id","ie","il","im","in","io","iq","ir","is","it","je","jm","jo","jp","ke","kg","kh","ki","km","kn","kp","kr","kw","ky","kz","la","lb","lc","li","lk","lr","ls","lt","lu","lv","ly","ma","mc","md","me","mf","mg","mh","mk","ml","mm","mn","mo","mp","mq","mr","ms","mt","mu","mv","mw","mx","my","mz","na","nc","ne","nf","ng","ni","nl","no","np","nr","nu","nz","om","pa","pe","pf","pg","ph","pk","pl","pm","pn","pr","ps","pt","pw","py","qa","re","ro","rs","ru","rw","sa","sb","sc","sd","se","sg","sh","si","sj","sk","sl","sm","sn","so","sr","ss","st","su","sv","sx","sy","sz","tc","td","tf","tg","th","tj","tk","tl","tm","tn","to","tp","tr","tt","tv","tw","tz","ua","ug","uk","um","us","uy","uz","va","vc","ve","vg","vi","vn","vu","wf","ws","ye","yt","za","zm","zw" ]; -} diff --git a/JavaScript/packages/recognizers-sequence/src/resources/chineseIp.ts b/JavaScript/packages/recognizers-sequence/src/resources/chineseIp.ts deleted file mode 100644 index 5e35dfd5cc..0000000000 --- a/JavaScript/packages/recognizers-sequence/src/resources/chineseIp.ts +++ /dev/null @@ -1,18 +0,0 @@ -// ------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// ------------------------------------------------------------------------------ - -import { BaseIp } from "./baseIp"; -import { ChinesePhoneNumbers as PhoneNumbersDefinitions } from "./chinesePhoneNumbers"; -export namespace ChineseIp { - export const Ipv4Regex = `(${PhoneNumbersDefinitions.WordBoundariesRegex}(1\\d{2}|2[0-4]\\d|25[0-5]|0?[1-9]\\d|0{0,2}\\d)((\\.(1\\d{2}|2[0-4]\\d|25[0-5]|0?[1-9]\\d|0{0,2}\\d)){3})${PhoneNumbersDefinitions.EndWordBoundariesRegex})`; - export const Ipv6EllipsisRegexOther = `(${PhoneNumbersDefinitions.NonWordBoundariesRegex}::${PhoneNumbersDefinitions.NonWordBoundariesRegex}|${PhoneNumbersDefinitions.NonWordBoundariesRegex}:(:${BaseIp.BasicIpv6Element}){1,7}${PhoneNumbersDefinitions.WordBoundariesRegex}|${PhoneNumbersDefinitions.WordBoundariesRegex}(${BaseIp.BasicIpv6Element}:){1,7}:${PhoneNumbersDefinitions.NonWordBoundariesRegex})`; - export const Ipv6Regex = `(${PhoneNumbersDefinitions.WordBoundariesRegex}${BaseIp.MergedIpv6Regex}${PhoneNumbersDefinitions.WordBoundariesRegex})|(${Ipv6EllipsisRegexOther})`; -} diff --git a/JavaScript/packages/recognizers-sequence/src/resources/chinesePhoneNumbers.ts b/JavaScript/packages/recognizers-sequence/src/resources/chinesePhoneNumbers.ts deleted file mode 100644 index 108f9d1d62..0000000000 --- a/JavaScript/packages/recognizers-sequence/src/resources/chinesePhoneNumbers.ts +++ /dev/null @@ -1,19 +0,0 @@ -// ------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// ------------------------------------------------------------------------------ - -export namespace ChinesePhoneNumbers { - export const NumberReplaceToken = `@builtin.phonenumber`; - export const WordBoundariesRegex = `(\\b|(?<=[\\u0800-\\u9FFF]))`; - export const NonWordBoundariesRegex = `(\\B|(?<=[\\u0800-\\u9FFF]))`; - export const EndWordBoundariesRegex = `(\\b|(?=[\\u0800-\\u9FFF]))`; - export const ColonPrefixCheckRegex = `(([a-z]|[\\u4E00-\\u9FA5])\\s*$)`; - export const ForbiddenPrefixMarkers = [ ":","%" ]; -} diff --git a/JavaScript/packages/recognizers-sequence/src/resources/chineseURL.ts b/JavaScript/packages/recognizers-sequence/src/resources/chineseURL.ts deleted file mode 100644 index 23bb02f861..0000000000 --- a/JavaScript/packages/recognizers-sequence/src/resources/chineseURL.ts +++ /dev/null @@ -1,19 +0,0 @@ -// ------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// ------------------------------------------------------------------------------ - -import { BaseIp } from "./baseIp"; -import { BaseURL } from "./baseURL"; -export namespace ChineseURL { - export const ExtractionRestrictionRegex = `(?<=\\s|[\\'\"\"\\(\\[::]|^|[\\u0800-\\u9FFF])`; - export const UrlPrefixRegex = `(${ExtractionRestrictionRegex}${BaseURL.ProtocolRegex}?|${BaseURL.ProtocolRegex})[a-zA-Z0-9][-a-zA-Z0-9._]{0,256}(?[a-zA-Z]{2,18})${BaseURL.UrlSuffixRegex}`; - export const IpUrlRegex = `(?(${ExtractionRestrictionRegex}${BaseURL.ProtocolRegex}(${BaseIp.Ipv4Regex}|localhost)${BaseURL.UrlSuffixRegex}))`; -} diff --git a/JavaScript/packages/recognizers-sequence/src/resources/englishPhoneNumbers.ts b/JavaScript/packages/recognizers-sequence/src/resources/englishPhoneNumbers.ts deleted file mode 100644 index df2b23184e..0000000000 --- a/JavaScript/packages/recognizers-sequence/src/resources/englishPhoneNumbers.ts +++ /dev/null @@ -1,15 +0,0 @@ -// ------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// ------------------------------------------------------------------------------ - -export namespace EnglishPhoneNumbers { - export const NumberReplaceToken = `@builtin.phonenumber`; - export const FalsePositivePrefixRegex = `(account|card)(\\s+(#|number))?(\\s+is)?:?\\s*$`; -} diff --git a/JavaScript/packages/recognizers-sequence/src/resources/portuguesePhoneNumbers.ts b/JavaScript/packages/recognizers-sequence/src/resources/portuguesePhoneNumbers.ts deleted file mode 100644 index 43184ae6c9..0000000000 --- a/JavaScript/packages/recognizers-sequence/src/resources/portuguesePhoneNumbers.ts +++ /dev/null @@ -1,15 +0,0 @@ -// ------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// ------------------------------------------------------------------------------ - -export namespace PortuguesePhoneNumbers { - export const NumberReplaceToken = `@builtin.phonenumber`; - export const FalsePositivePrefixRegex = `conta(\\s+(número|bancária(\\s+número)?))?(\\s+é)?:?\\s*$`; -} diff --git a/JavaScript/packages/recognizers-sequence/src/sequence/chinese/extractors.ts b/JavaScript/packages/recognizers-sequence/src/sequence/chinese/extractors.ts deleted file mode 100644 index 8740c7f872..0000000000 --- a/JavaScript/packages/recognizers-sequence/src/sequence/chinese/extractors.ts +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { RegExpUtility } from "@microsoft/recognizers-text"; -import { IURLExtractorConfiguration, IIpExtractorConfiguration, IPhoneNumberExtractorConfiguration } from "../extractors"; -import { ChineseURL } from "../../resources/chineseURL"; -import { ChinesePhoneNumbers } from "../../resources/chinesePhoneNumbers"; -import { ChineseIp } from "../../resources/chineseIp"; - -export class ChineseURLExtractorConfiguration implements IURLExtractorConfiguration { - readonly UrlRegex: RegExp; - readonly IpUrlRegex: RegExp; - - constructor() { - this.UrlRegex = RegExpUtility.getSafeRegExp(ChineseURL.UrlRegex); - this.IpUrlRegex = RegExpUtility.getSafeRegExp(ChineseURL.IpUrlRegex); - } -} - -export class ChinesePhoneNumberExtractorConfiguration implements IPhoneNumberExtractorConfiguration { - readonly WordBoundariesRegex: string; - readonly NonWordBoundariesRegex: string; - readonly EndWordBoundariesRegex: string; - readonly ColonPrefixCheckRegex: string; - readonly ForbiddenPrefixMarkers: string[]; - readonly FalsePositivePrefixRegex: string; - - constructor() { - this.WordBoundariesRegex = ChinesePhoneNumbers.WordBoundariesRegex; - this.NonWordBoundariesRegex = ChinesePhoneNumbers.NonWordBoundariesRegex; - this.EndWordBoundariesRegex = ChinesePhoneNumbers.EndWordBoundariesRegex; - this.ColonPrefixCheckRegex = ChinesePhoneNumbers.ColonPrefixCheckRegex; - this.ForbiddenPrefixMarkers = ChinesePhoneNumbers.ForbiddenPrefixMarkers; - this.FalsePositivePrefixRegex = null; - } -} - -export class ChineseIpExtractorConfiguration implements IIpExtractorConfiguration { - readonly Ipv4Regex: RegExp; - readonly Ipv6Regex: RegExp; - - constructor() { - this.Ipv4Regex = RegExpUtility.getSafeRegExp(ChineseIp.Ipv4Regex); - this.Ipv6Regex = RegExpUtility.getSafeRegExp(ChineseIp.Ipv6Regex); - } -} diff --git a/JavaScript/packages/recognizers-sequence/src/sequence/constants.ts b/JavaScript/packages/recognizers-sequence/src/sequence/constants.ts deleted file mode 100644 index d5313e1225..0000000000 --- a/JavaScript/packages/recognizers-sequence/src/sequence/constants.ts +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -export class Constants { - static readonly IP_REGEX_IPV4: string = "ipv4"; - static readonly IP_REGEX_IPV6: string = "ipv6"; - static readonly IPV6_ELLIPSIS: string = "::"; - static readonly PHONE_NUMBER_REGEX_GENERAL: string = "GeneralPhoneNumber"; - static readonly PHONE_NUMBER_REGEX_BR: string = "BRPhoneNumber"; - static readonly PHONE_NUMBER_REGEX_UK: string = "UKPhoneNumber"; - static readonly PHONE_NUMBER_REGEX_DE: string = "DEPhoneNumber"; - static readonly PHONE_NUMBER_REGEX_US: string = "USPhoneNumber"; - static readonly PHONE_NUMBER_REGEX_CN: string = "CNPhoneNumber"; - static readonly PHONE_NUMBER_REGEX_DK: string = "DKPhoneNumber"; - static readonly PHONE_NUMBER_REGEX_IT: string = "ITPhoneNumber"; - static readonly PHONE_NUMBER_REGEX_NL: string = "NLPhoneNumber"; - static readonly PHONE_NUMBER_REGEX_SPECIAL: string = "SpecialPhoneNumber"; - static readonly MENTION_REGEX = "Mention"; - static readonly HASHTAG_REGEX = "Hashtag"; - static readonly EMAIL_REGEX = "Email"; - static readonly URL_REGEX = "Url"; - static readonly GUID_REGEX = "Guid"; -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-sequence/src/sequence/english/extractors.ts b/JavaScript/packages/recognizers-sequence/src/sequence/english/extractors.ts deleted file mode 100644 index f73ad8e43f..0000000000 --- a/JavaScript/packages/recognizers-sequence/src/sequence/english/extractors.ts +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { BasePhoneNumberExtractorConfiguration, IIpExtractorConfiguration, BaseMentionExtractor, BaseHashtagExtractor, BaseEmailExtractor, IURLExtractorConfiguration, BaseGUIDExtractor, IPhoneNumberExtractorConfiguration } from "../extractors"; -import { ExtractResult, RegExpUtility } from "@microsoft/recognizers-text"; -import { BasePhoneNumbers } from "../../resources/basePhoneNumbers"; -import { BaseURL } from "../../resources/baseURL"; -import { BaseIp } from "../../resources/baseIp"; -import { EnglishPhoneNumbers } from "../../resources/EnglishPhoneNumbers"; - -export class EnglishPhoneNumberExtractorConfiguration extends BasePhoneNumberExtractorConfiguration { - readonly FalsePositivePrefixRegex: string; - - constructor() { - super(); - this.FalsePositivePrefixRegex = EnglishPhoneNumbers.FalsePositivePrefixRegex; - } -} - -export class EnglishIpExtractorConfiguration implements IIpExtractorConfiguration { - readonly Ipv4Regex: RegExp; - readonly Ipv6Regex: RegExp; - - constructor() { - this.Ipv4Regex = RegExpUtility.getSafeRegExp(BaseIp.Ipv4Regex); - this.Ipv6Regex = RegExpUtility.getSafeRegExp(BaseIp.Ipv6Regex); - } -} - -export class MentionExtractor extends BaseMentionExtractor { - -} - -export class HashtagExtractor extends BaseHashtagExtractor { - -} - -export class EmailExtractor extends BaseEmailExtractor { - -} - -export class EnglishURLExtractorConfiguration implements IURLExtractorConfiguration { - readonly UrlRegex: RegExp; - readonly IpUrlRegex: RegExp; - - constructor() { - this.UrlRegex = RegExpUtility.getSafeRegExp(BaseURL.UrlRegex); - this.IpUrlRegex = RegExpUtility.getSafeRegExp(BaseURL.IpUrlRegex); - } -} - -export class GUIDExtractor extends BaseGUIDExtractor { - -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-sequence/src/sequence/english/parsers.ts b/JavaScript/packages/recognizers-sequence/src/sequence/english/parsers.ts deleted file mode 100644 index 602ef6d589..0000000000 --- a/JavaScript/packages/recognizers-sequence/src/sequence/english/parsers.ts +++ /dev/null @@ -1,152 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { BasePhoneNumbers } from "../../resources/basePhoneNumbers"; -import { BaseSequenceParser, BaseIpParser } from "../parsers"; -import { ExtractResult, ParseResult, Match } from "@microsoft/recognizers-text"; -import { BaseGUID } from "../../resources/baseGUID"; - -export class PhoneNumberParser extends BaseSequenceParser { - scoreUpperLimit = 100; - scoreLowerLimit = 0; - baseScore = 30; - countryCodeAward = 40; - areaCodeAward = 30; - formattedAward = 20; - lengthAward = 10; - typicalFormatDeductionScore = 40; - continueDigitDeductionScore = 10; - tailSameDeductionScore = 10; - continueFormatIndicatorDeductionScore = 20; - wrongFormatIndicatorDeductionScore = 20; - maxFormatIndicatorNum = 3; - maxLengthAwardNum = 3; - tailSameLimit = 2; - phoneNumberLengthBase = 8; - pureDigitLengthLimit = 11; - completeBracketRegex = new RegExp("\\(.*\\)"); - singleBracketRegex = new RegExp("\\(|\\)"); - tailSameDigitRegex = new RegExp("([\\d])\\1{2,10}$"); - pureDigitRegex = new RegExp("^\\d*$"); - continueDigitRegex = new RegExp("\\d{5}\\d*", "ig"); - digitRegex = new RegExp("\\d", "ig"); - - ScorePhoneNumber(phoneNumberText: string): number { - let score = this.baseScore; - - let countryCodeRegex = new RegExp(BasePhoneNumbers.CountryCodeRegex); - let areaCodeRegex = new RegExp(BasePhoneNumbers.AreaCodeIndicatorRegex); - let formatIndicatorRegex = new RegExp(BasePhoneNumbers.FormatIndicatorRegex, "ig"); - let noAreaCodeUSphonenumbeRegex = new RegExp(BasePhoneNumbers.NoAreaCodeUSPhoneNumberRegex); - - // Country code score or area code score - score += countryCodeRegex.test(phoneNumberText) ? - this.countryCodeAward : areaCodeRegex.test(phoneNumberText) ? this.areaCodeAward : 0; - - // Formatted score - if (formatIndicatorRegex.test(phoneNumberText)) { - let formatMathes = phoneNumberText.match(formatIndicatorRegex); - let formatIndicatorCount = formatMathes.length; - score += Math.min(formatIndicatorCount, this.maxFormatIndicatorNum) * this.formattedAward; - score -= formatMathes.some(match => match.length > 1) ? this.continueFormatIndicatorDeductionScore : 0; - if (this.singleBracketRegex.test(phoneNumberText) && !this.completeBracketRegex.test(phoneNumberText)) { - score -= this.wrongFormatIndicatorDeductionScore; - } - } - - // Same tailing digit deduction - if (this.tailSameDigitRegex.test(phoneNumberText)) { - score -= (phoneNumberText.match(this.tailSameDigitRegex)[0].length - this.tailSameLimit) * this.tailSameDeductionScore; - - } - - // Length score - if (this.digitRegex.test(phoneNumberText)) { - score += Math.min((phoneNumberText.match(this.digitRegex).length - this.phoneNumberLengthBase), - this.maxLengthAwardNum) * this.lengthAward; - } - - // Pure digit deduction - if (this.pureDigitRegex.test(phoneNumberText)) { - score -= phoneNumberText.length > this.pureDigitLengthLimit ? - (phoneNumberText.length - this.pureDigitLengthLimit) * this.lengthAward : 0; - } - - // Special format deduction - score -= BasePhoneNumbers.TypicalDeductionRegexList.some(o => new RegExp(o).test(phoneNumberText)) ? this.typicalFormatDeductionScore : 0; - - // Continue digit deduction - if (this.continueDigitRegex.test(phoneNumberText)) { - score -= Math.max(phoneNumberText.match(this.continueDigitRegex).length - 1, 0) * this.continueDigitDeductionScore; - } - - // Special award for special USphonenumber, i.e. 223-4567 or 223 - 4567 - if (noAreaCodeUSphonenumbeRegex.test(phoneNumberText)) { - score += this.lengthAward * 1.5; - } - - return Math.max(Math.min(score, this.scoreUpperLimit), this.scoreLowerLimit) / (this.scoreUpperLimit - this.scoreLowerLimit); - } - - parse(extResult: ExtractResult): ParseResult { - let result = new ParseResult(extResult); - result.resolutionStr = extResult.text; - result.value = this.ScorePhoneNumber(extResult.text); - return result; - } -} - -export class IpParser extends BaseIpParser { - -} - -export class MentionParser extends BaseSequenceParser { - -} - -export class HashtagParser extends BaseSequenceParser { - -} - -export class EmailParser extends BaseSequenceParser { - -} - -export class URLParser extends BaseSequenceParser { - -} - -export class GUIDParser extends BaseSequenceParser { - scoreUpperLimit = 100; - scoreLowerLimit = 0; - baseScore = 100; - noBoundaryPenalty = 10; - noFormatPenalty = 10; - pureDigitPenalty = 15; - pureDigitRegex = new RegExp("^\\d*$"); - formatRegex = new RegExp("-"); - - ScoreGUID(GUIDText: string): number { - let score = this.baseScore; - - let guidElementRegex = new RegExp(BaseGUID.GUIDRegexElement); - - if (guidElementRegex.test(GUIDText)) { - let elementMatch = GUIDText.match(guidElementRegex); - let startIndex = elementMatch.index; - let elementGUID = elementMatch[0]; - score -= startIndex == 0 ? this.noBoundaryPenalty : 0; - score -= this.formatRegex.test(elementGUID) ? 0 : this.noFormatPenalty; - score -= this.pureDigitRegex.test(GUIDText) ? this.pureDigitPenalty : 0; - } - - return Math.max(Math.min(score, this.scoreUpperLimit), this.scoreLowerLimit) / (this.scoreUpperLimit - this.scoreLowerLimit); - } - - parse(extResult: ExtractResult): ParseResult { - let result = new ParseResult(extResult); - result.resolutionStr = extResult.text; - result.value = this.ScoreGUID(extResult.text); - return result; - } -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-sequence/src/sequence/extractors.ts b/JavaScript/packages/recognizers-sequence/src/sequence/extractors.ts deleted file mode 100644 index c9bf0a7f22..0000000000 --- a/JavaScript/packages/recognizers-sequence/src/sequence/extractors.ts +++ /dev/null @@ -1,385 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { IExtractor, ExtractResult, RegExpUtility, Match, StringUtility } from "@microsoft/recognizers-text"; -import { BasePhoneNumbers } from "../resources/basePhoneNumbers"; -import { BaseIp } from "../resources/baseIp"; -import { BaseMention } from "../resources/baseMention"; -import { BaseHashtag } from "../resources/baseHashtag"; -import { BaseEmail } from "../resources/baseEmail"; -import { BaseURL } from "../resources/baseURL"; -import { BaseGUID } from "../resources/baseGUID"; -import { Constants } from "./constants"; - -export abstract class BaseSequenceExtractor implements IExtractor { - abstract regexes: Map; - - protected extractType: string; - - extract(source: string): ExtractResult[] { - let results = new Array(); - - if (StringUtility.isNullOrWhitespace(source)) { - return results; - } - - let matchSource = new Map(); - let matched = new Array(source.length); - - // Traverse every match results to see each position in the text is matched or not. - let collections = this.regexes.forEach((typeExtracted, regex) => { - RegExpUtility.getMatches(regex, source).forEach(match => { - if (!this.isValidMatch(match)) { - return; - } - - for (let j = 0; j < match.length; j++) { - matched[match.index + j] = true; - } - - // Keep Source Data for extra information - matchSource.set(match, typeExtracted); - }); - }); - - // Form the extracted results from all the matched intervals in the text. - let lastNotMatched = -1; - for (let i = 0; i < source.length; i++) { - if (matched[i]) { - if (i + 1 === source.length || !matched[i + 1]) { - let start = lastNotMatched + 1; - let length = i - lastNotMatched; - let substr = source.substr(start, length); - let matchFunc = (o: Match) => o.index == start && o.length == length; - - let srcMatch = Array.from(matchSource.keys()).find(matchFunc); - if (srcMatch) { - results.push({ - start: start, - length: length, - text: substr, - type: this.extractType, - data: matchSource.has(srcMatch) ? matchSource.get(srcMatch) : null - }); - } - } - } - else { - lastNotMatched = i; - } - } - - return results; - } - - isValidMatch(match: Match): boolean { - return true; - } -} - -export interface IPhoneNumberExtractorConfiguration { - WordBoundariesRegex: string; - NonWordBoundariesRegex: string; - EndWordBoundariesRegex: string; - ColonPrefixCheckRegex: string; - FalsePositivePrefixRegex: string; - ForbiddenPrefixMarkers: string[]; -} - -export class BasePhoneNumberExtractorConfiguration implements IPhoneNumberExtractorConfiguration { - readonly WordBoundariesRegex: string; - readonly NonWordBoundariesRegex: string; - readonly EndWordBoundariesRegex: string; - readonly ColonPrefixCheckRegex: string; - readonly ForbiddenPrefixMarkers: string[]; - readonly FalsePositivePrefixRegex: string; - - constructor() { - this.WordBoundariesRegex = BasePhoneNumbers.WordBoundariesRegex; - this.NonWordBoundariesRegex = BasePhoneNumbers.NonWordBoundariesRegex; - this.EndWordBoundariesRegex = BasePhoneNumbers.EndWordBoundariesRegex; - this.ForbiddenPrefixMarkers = BasePhoneNumbers.ForbiddenPrefixMarkers; - this.ColonPrefixCheckRegex = BasePhoneNumbers.ColonPrefixCheckRegex; - this.FalsePositivePrefixRegex = null; - } -} - -export class BasePhoneNumberExtractor extends BaseSequenceExtractor { - regexes: Map; - config: IPhoneNumberExtractorConfiguration; - - constructor(config: IPhoneNumberExtractorConfiguration) { - super(); - this.config = config; - let wordBoundariesRegex = config.WordBoundariesRegex; - let nonWordBoundariesRegex = config.NonWordBoundariesRegex; - let endWordBoundariesRegex = config.EndWordBoundariesRegex; - this.regexes = new Map() - .set(RegExpUtility.getSafeRegExp(BasePhoneNumbers.BRPhoneNumberRegex(wordBoundariesRegex, nonWordBoundariesRegex, endWordBoundariesRegex)), Constants.PHONE_NUMBER_REGEX_BR) - .set(RegExpUtility.getSafeRegExp(BasePhoneNumbers.GeneralPhoneNumberRegex(wordBoundariesRegex, endWordBoundariesRegex)), Constants.PHONE_NUMBER_REGEX_GENERAL) - .set(RegExpUtility.getSafeRegExp(BasePhoneNumbers.UKPhoneNumberRegex(wordBoundariesRegex, nonWordBoundariesRegex, endWordBoundariesRegex)), Constants.PHONE_NUMBER_REGEX_UK) - .set(RegExpUtility.getSafeRegExp(BasePhoneNumbers.DEPhoneNumberRegex(wordBoundariesRegex, endWordBoundariesRegex)), Constants.PHONE_NUMBER_REGEX_DE) - .set(RegExpUtility.getSafeRegExp(BasePhoneNumbers.USPhoneNumberRegex(wordBoundariesRegex, nonWordBoundariesRegex, endWordBoundariesRegex)), Constants.PHONE_NUMBER_REGEX_US) - .set(RegExpUtility.getSafeRegExp(BasePhoneNumbers.CNPhoneNumberRegex(wordBoundariesRegex, endWordBoundariesRegex)), Constants.PHONE_NUMBER_REGEX_CN) - .set(RegExpUtility.getSafeRegExp(BasePhoneNumbers.DKPhoneNumberRegex(wordBoundariesRegex, endWordBoundariesRegex)), Constants.PHONE_NUMBER_REGEX_DK) - .set(RegExpUtility.getSafeRegExp(BasePhoneNumbers.ITPhoneNumberRegex(wordBoundariesRegex, endWordBoundariesRegex)), Constants.PHONE_NUMBER_REGEX_IT) - .set(RegExpUtility.getSafeRegExp(BasePhoneNumbers.NLPhoneNumberRegex(wordBoundariesRegex, endWordBoundariesRegex)), Constants.PHONE_NUMBER_REGEX_NL) - .set(RegExpUtility.getSafeRegExp(BasePhoneNumbers.SpecialPhoneNumberRegex(wordBoundariesRegex, endWordBoundariesRegex)), Constants.PHONE_NUMBER_REGEX_SPECIAL); - } - extract(source: string): ExtractResult[] { - let ret = new Array(); - if (!source.match(BasePhoneNumbers.PreCheckPhoneNumberRegex)) { - return ret; - } - let ers = super.extract(source); - let formatIndicatorRegex = new RegExp(BasePhoneNumbers.FormatIndicatorRegex, "ig"); - let digitRegex = new RegExp("[0-9]"); - for (let er of ers) { - let Digits = 0; - for (let t of er.text) { - if (t.match(digitRegex)) { - Digits++ ; - } - } - if ((Digits < 7 && er.data !== "ITPhoneNumber") || er.text.match(BasePhoneNumbers.SSNFilterRegex)) { - continue; - } - if (Digits === 16 && !(er.text.substring(0, 1) === "+")) { - continue; - } - if (Digits === 15) { - let flag = false; - let numSpans = er.text.split(" "); - for (let numSpan of numSpans) { - let numSpanDigit = 0; - for (let t of numSpan) { - if (t.match(digitRegex)) { - numSpanDigit++; - } - } - if (numSpanDigit == 4 || numSpanDigit == 3) { - flag = false; - } - else { - flag = true; - break; - } - } - if (flag == false) { - continue; - } - } - if (er.start + er.length < source.length) { - let ch = source[ er.start+er.length ]; - if (BasePhoneNumbers.ForbiddenSuffixMarkers.indexOf(ch) !== -1){ - continue; - } - } - let ch = source[er.start - 1]; - let front = source.substring(0, er.start - 1); - if (this.config.FalsePositivePrefixRegex && front.match(this.config.FalsePositivePrefixRegex)) { - continue; - } - - if (er.start !== 0) { - if (BasePhoneNumbers.BoundaryMarkers.indexOf(ch) !== -1) { - if (BasePhoneNumbers.SpecialBoundaryMarkers.indexOf(ch) !== -1 && - formatIndicatorRegex.test(er.text) && - er.start >= 2) { - let chGap = source[er.start - 2]; - if (chGap.match(digitRegex)) { - let match = front.match(BasePhoneNumbers.InternationDialingPrefixRegex); - if (match) { - let moveOffset = match[0].length + 1; - er.start = er.start - moveOffset; - er.length = er.length + moveOffset; - er.text = source.substring(er.start, er.start + er.length); - ret.push(er); - } - } - // Handle cases like "91a-677-0060". - else if (chGap <= 'z' && chGap >= 'a') { - continue; - } - else { - ret.push(er); - } - } - continue; - } - else if (this.config.ForbiddenPrefixMarkers.indexOf(ch) !== -1) { - // Handle "tel:123456". - if (BasePhoneNumbers.ColonMarkers.indexOf(ch) !== -1) { - // If the char before ':' is not letter, ignore it. - if (!front.match(this.config.ColonPrefixCheckRegex)) { - continue; - } - } - else { - continue; - } - } - } - ret.push(er); - } - - // filter hexadecimal address like 00 10 00 31 46 D9 E9 11 - let maskRegex = new RegExp(BasePhoneNumbers.PhoneNumberMaskRegex, "g"); - let m: RegExpExecArray | null; - while (true) { - m = maskRegex.exec(source); - if (m == null) { - break; - } - for (let i = ret.length - 1; i >= 0; --i) { - if (ret[i].start >= m.index && ret[i].start + ret[i].length <= m.index + m[0].length) { - ret.splice(i, 1); - } - } - } - return ret; - } -} - -export interface IIpExtractorConfiguration { - Ipv4Regex: RegExp; - Ipv6Regex: RegExp; -} - -export class BaseIpExtractor extends BaseSequenceExtractor { - regexes: Map; - - constructor(config: IIpExtractorConfiguration) { - super(); - this.regexes = new Map() - .set(config.Ipv4Regex, Constants.IP_REGEX_IPV4) - .set(config.Ipv6Regex, Constants.IP_REGEX_IPV6); - } - - extract(source: string): ExtractResult[] { - let results = new Array(); - - if (StringUtility.isNullOrWhitespace(source)) { - return results; - } - - let matchSource = new Map(); - let matched = new Array(source.length); - - let collections = this.regexes.forEach((typeExtracted, regex) => { - RegExpUtility.getMatches(regex, source).forEach(match => { - for (let j = 0; j < match.length; j++) { - matched[match.index + j] = true; - } - - // Keep Source Data for extra information - matchSource.set(match, typeExtracted); - }); - }); - - let lastNotMatched = -1; - for (let i = 0; i < source.length; i++) { - if (matched[i]) { - if (i + 1 === source.length || !matched[i + 1]) { - let start = lastNotMatched + 1; - let length = i - lastNotMatched; - let substr = source.substr(start, length); - if (substr.startsWith(Constants.IPV6_ELLIPSIS) && start > 0 && this.isLetterOrDigit(source[start - 1])) { - continue; - } - else if (substr.endsWith(Constants.IPV6_ELLIPSIS) && i + 1 < source.length && this.isLetterOrDigit(source[i + 1])) { - continue; - } - - let matchFunc = (o: Match) => o.index === start && o.length === length; - - let srcMatch = Array.from(matchSource.keys()).find(matchFunc); - if (srcMatch) { - results.push({ - start: start, - length: length, - text: substr, - type: this.extractType, - data: matchSource.has(srcMatch) ? matchSource.get(srcMatch) : null - }); - } - } - } - else { - lastNotMatched = i; - } - } - - return results; - } - - isLetterOrDigit(c: string): boolean { - return new RegExp("[0-9a-zA-z]").test(c); - } -} - -export class BaseMentionExtractor extends BaseSequenceExtractor { - regexes: Map; - - constructor() { - super(); - this.regexes = new Map() - .set(RegExpUtility.getSafeRegExp(BaseMention.MentionRegex), Constants.MENTION_REGEX); - } -} - -export class BaseHashtagExtractor extends BaseSequenceExtractor { - regexes: Map; - - constructor() { - super(); - this.regexes = new Map() - .set(RegExpUtility.getSafeRegExp(BaseHashtag.HashtagRegex), Constants.HASHTAG_REGEX); - } -} - -export class BaseEmailExtractor extends BaseSequenceExtractor { - regexes: Map; - - constructor() { - super(); - this.regexes = new Map() - .set(RegExpUtility.getSafeRegExp(BaseEmail.EmailRegex), Constants.EMAIL_REGEX); - // EmailRegex2 will break the code as it's not supported in Javascript, comment out for now - // .set(RegExpUtility.getSafeRegExp(BaseEmail.EmailRegex2), Constants.EMAIL_REGEX) - } -} - -export interface IURLExtractorConfiguration { - UrlRegex: RegExp; - IpUrlRegex: RegExp; -} - -export class BaseURLExtractor extends BaseSequenceExtractor { - regexes: Map; - ambiguousTimeTerm: RegExp; - - constructor(config: IURLExtractorConfiguration) { - super(); - this.regexes = new Map() - .set(config.UrlRegex, Constants.URL_REGEX) - .set(RegExpUtility.getSafeRegExp(BaseURL.UrlRegex2), Constants.URL_REGEX) - .set(config.IpUrlRegex, Constants.URL_REGEX); - this.ambiguousTimeTerm = RegExpUtility.getSafeRegExp(BaseURL.AmbiguousTimeTerm); - } - - isValidMatch(match: Match): boolean { - // For cases like "7.am" or "8.pm" which are more likely time terms. - return !RegExpUtility.isMatch(this.ambiguousTimeTerm, match.value); - } -} - -export class BaseGUIDExtractor extends BaseSequenceExtractor { - regexes: Map; - - constructor() { - super(); - this.regexes = new Map() - .set(RegExpUtility.getSafeRegExp(BaseGUID.GUIDRegex), Constants.GUID_REGEX); - } -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-sequence/src/sequence/models.ts b/JavaScript/packages/recognizers-sequence/src/sequence/models.ts deleted file mode 100644 index 05a6ab706e..0000000000 --- a/JavaScript/packages/recognizers-sequence/src/sequence/models.ts +++ /dev/null @@ -1,152 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { IModel, ModelResult, IExtractor, IParser, ParseResult, QueryProcessor } from "@microsoft/recognizers-text"; - -export abstract class AbstractSequenceModel implements IModel { - public abstract readonly modelTypeName: string; - - protected readonly extractor: IExtractor; - protected readonly parser: IParser; - - constructor(parser: IParser, extractor: IExtractor) { - this.extractor = extractor; - this.parser = parser; - } - - parse(query: string): ModelResult[] { - query = QueryProcessor.preProcess(query, true); - let parseResults = new Array(); - - try { - let extractResults = this.extractor.extract(query); - parseResults = extractResults.map(r => this.parser.parse(r)); - } - catch (err) { - // Nothing to do. Exceptions in result process should not affect other extracted entities. - // No result. - } - finally { - return parseResults - .map(o => o as ParseResult) - .map(o => ({ - start: o.start, - end: o.start + o.length - 1, - resolution: { "value": o.resolutionStr }, - text: o.text, - typeName: this.modelTypeName - })); - } - } -} - -export class PhoneNumberModel extends AbstractSequenceModel { - public modelTypeName: string = "phonenumber"; - - parse(query: string): ModelResult[] { - let parseResults = new Array(); - query = QueryProcessor.preProcess(query); - - try { - let extractResults = this.extractor.extract(query); - parseResults = extractResults.map(r => this.parser.parse(r)); - } - catch (err) { - // Nothing to do. Exceptions in result process should not affect other extracted entities. - // No result. - } - finally { - return parseResults - .map(o => o as ParseResult) - .map(o => ({ - start: o.start, - end: o.start + o.length - 1, - resolution: { - "value": o.resolutionStr, - "score": o.value.toString() - }, - text: o.text, - typeName: this.modelTypeName - })); - } - } -} - -export class IpAddressModel extends AbstractSequenceModel { - public modelTypeName: string = "ip"; - - parse(query: string): ModelResult[] { - let parseResults = new Array(); - - try { - let extractResults = this.extractor.extract(query); - parseResults = extractResults.map(r => this.parser.parse(r)); - } - catch (err) { - // Nothing to do. Exceptions in result process should not affect other extracted entities. - // No result. - } - finally { - return parseResults - .map(o => o as ParseResult) - .map(o => ({ - start: o.start, - end: o.start + o.length - 1, - resolution: { - "value": o.resolutionStr, - "type": o.data - }, - text: o.text, - typeName: this.modelTypeName - })); - } - } -} - -export class MentionModel extends AbstractSequenceModel { - public modelTypeName: string = "mention"; -} - -export class HashtagModel extends AbstractSequenceModel { - public modelTypeName: string = "hashtag"; -} - -export class EmailModel extends AbstractSequenceModel { - public modelTypeName: string = "email"; -} - -export class URLModel extends AbstractSequenceModel { - public modelTypeName: string = "url"; -} - -export class GUIDModel extends AbstractSequenceModel { - public modelTypeName: string = "guid"; - - parse(query: string): ModelResult[] { - let parseResults = new Array(); - query = QueryProcessor.preProcess(query); - - try { - let extractResults = this.extractor.extract(query); - parseResults = extractResults.map(r => this.parser.parse(r)); - } - catch (err) { - // Nothing to do. in result process should not affect other extracted entities. - // No result. - } - finally { - return parseResults - .map(o => o as ParseResult) - .map(o => ({ - start: o.start, - end: o.start + o.length - 1, - resolution: { - "value": o.resolutionStr, - "score": o.value.toString() - }, - text: o.text, - typeName: this.modelTypeName - })); - } - } -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-sequence/src/sequence/parsers.ts b/JavaScript/packages/recognizers-sequence/src/sequence/parsers.ts deleted file mode 100644 index 99c6c2717d..0000000000 --- a/JavaScript/packages/recognizers-sequence/src/sequence/parsers.ts +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { IParser, ExtractResult, ParseResult } from "@microsoft/recognizers-text"; - -export class BaseSequenceParser implements IParser { - parse(extResult: ExtractResult): ParseResult { - let result = new ParseResult(extResult); - result.resolutionStr = extResult.text; - return result; - } -} - -export class BaseIpParser extends BaseSequenceParser { - parse(extResult: ExtractResult): ParseResult { - let result = new ParseResult(extResult); - result.resolutionStr = this.dropLeadingZeros(extResult.text); - return result; - } - - private dropLeadingZeros(text: string): string { - let result = ""; - - let number = ""; - for (let i = 0; i < text.length; i++) { - let c = text[i]; - if (c == '.' || c == ':') { - if (number != "") { - number = number == "0" ? number : number.replace(/^(0*)/, ""); - number = number == "" ? "0" : number; - result += number; - } - result += text[i]; - number = ""; - } - else { - number += c.toString(); - if (i == text.length - 1) { - number = number == "0" ? number : number.replace(/^(0*)/, ""); - number = number == "" ? "0" : number; - result += number; - } - } - } - - return result; - } -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-sequence/src/sequence/portuguese/extractors.ts b/JavaScript/packages/recognizers-sequence/src/sequence/portuguese/extractors.ts deleted file mode 100644 index 00c9e5ce38..0000000000 --- a/JavaScript/packages/recognizers-sequence/src/sequence/portuguese/extractors.ts +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { BasePhoneNumberExtractorConfiguration, IIpExtractorConfiguration, BaseMentionExtractor, BaseHashtagExtractor, BaseEmailExtractor, IURLExtractorConfiguration, BaseGUIDExtractor, IPhoneNumberExtractorConfiguration } from "../extractors"; -import { ExtractResult, RegExpUtility } from "@microsoft/recognizers-text"; -import { BasePhoneNumbers } from "../../resources/basePhoneNumbers"; -import { BaseURL } from "../../resources/baseURL"; -import { BaseIp } from "../../resources/baseIp"; -import { PortuguesePhoneNumbers } from "../../resources/PortuguesePhoneNumbers"; - -export class PortuguesePhoneNumberExtractorConfiguration extends BasePhoneNumberExtractorConfiguration { - readonly FalsePositivePrefixRegex: string; - - constructor() { - super(); - this.FalsePositivePrefixRegex = PortuguesePhoneNumbers.FalsePositivePrefixRegex; - } -} diff --git a/JavaScript/packages/recognizers-sequence/src/sequence/sequenceRecognizer.ts b/JavaScript/packages/recognizers-sequence/src/sequence/sequenceRecognizer.ts deleted file mode 100644 index dd162cfd69..0000000000 --- a/JavaScript/packages/recognizers-sequence/src/sequence/sequenceRecognizer.ts +++ /dev/null @@ -1,129 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { Recognizer, IModel, Culture, ModelResult } from "@microsoft/recognizers-text"; -import { PhoneNumberModel, IpAddressModel, MentionModel, HashtagModel, EmailModel, URLModel, GUIDModel } from "./models"; -import { PhoneNumberParser, IpParser, MentionParser, HashtagParser, EmailParser, URLParser, GUIDParser } from "./english/parsers"; -import { EnglishIpExtractorConfiguration, MentionExtractor, HashtagExtractor, EmailExtractor, EnglishURLExtractorConfiguration, GUIDExtractor, EnglishPhoneNumberExtractorConfiguration } from "./english/extractors"; -import { ChineseURLExtractorConfiguration, ChinesePhoneNumberExtractorConfiguration, ChineseIpExtractorConfiguration } from "./chinese/extractors"; -import { PortuguesePhoneNumberExtractorConfiguration } from "./portuguese/extractors"; -import { BaseURLExtractor, BasePhoneNumberExtractor, BaseIpExtractor } from "./extractors"; - - -export enum SequenceOptions { - None = 0, -} - -export function recognizePhoneNumber(query: string, culture: string, options: SequenceOptions = SequenceOptions.None): ModelResult[] { - if (culture.toLowerCase().startsWith("zh-") || culture.toLowerCase().startsWith("ja-")) { - return recognizeByModel(recognizer => recognizer.getPhoneNumberModel(), query, Culture.Chinese, options); - } - return recognizeByModel(recognizer => recognizer.getPhoneNumberModel(), query, culture, options); -} - -export function recognizeIpAddress(query: string, culture: string, options: SequenceOptions = SequenceOptions.None): ModelResult[] { - if (culture.toLowerCase().startsWith("zh-") || culture.toLowerCase().startsWith("ja-")) { - return recognizeByModel(recognizer => recognizer.getIpAddressModel(), query, Culture.Chinese, options); - } - return recognizeByModel(recognizer => recognizer.getIpAddressModel(), query, culture, options); -} - -export function recognizeMention(query: string, culture: string, options: SequenceOptions = SequenceOptions.None): ModelResult[] { - return recognizeByModel(recognizer => recognizer.getMentionModel(), query, culture, options); -} - -export function recognizeHashtag(query: string, culture: string, options: SequenceOptions = SequenceOptions.None): ModelResult[] { - return recognizeByModel(recognizer => recognizer.getHashtagModel(), query, culture, options); -} - -export function recognizeEmail(query: string, culture: string, options: SequenceOptions = SequenceOptions.None): ModelResult[] { - return recognizeByModel(recognizer => recognizer.getEmailModel(), query, culture, options); -} - -export function recognizeURL(query: string, culture: string, options: SequenceOptions = SequenceOptions.None): ModelResult[] { - if (culture.toLowerCase().startsWith("zh-") || culture.toLowerCase().startsWith("ja-")) { - return recognizeByModel(recognizer => recognizer.getURLModel(), query, Culture.Chinese, options); - } - return recognizeByModel(recognizer => recognizer.getURLModel(), query, culture, options); -} - -export function recognizeGUID(query: string, culture: string, options: SequenceOptions = SequenceOptions.None): ModelResult[] { - return recognizeByModel(recognizer => recognizer.getGUIDModel(), query, culture, options); -} - -function recognizeByModel(getModelFunc: (n: SequenceRecognizer) => IModel, query: string, culture: string, options: SequenceOptions): ModelResult[] { - let recognizer = new SequenceRecognizer(culture, options); - let model = getModelFunc(recognizer); - return model.parse(query); -} - - -export default class SequenceRecognizer extends Recognizer { - constructor(culture: string, options: SequenceOptions = SequenceOptions.None, lazyInitialization: boolean = false) { - super(culture, options, lazyInitialization); - } - - protected IsValidOptions(options: any): boolean { - return options >= 0 && options <= SequenceOptions.None; - } - - protected InitializeConfiguration() { - this.registerModel("PhoneNumberModel", Culture.English, (options) => new PhoneNumberModel( - new PhoneNumberParser(), - new BasePhoneNumberExtractor(new EnglishPhoneNumberExtractorConfiguration()))); - this.registerModel("PhoneNumberModel", Culture.Chinese, (options) => new PhoneNumberModel( - new PhoneNumberParser(), - new BasePhoneNumberExtractor(new ChinesePhoneNumberExtractorConfiguration()))); - this.registerModel("PhoneNumberModel", Culture.Portuguese, (options) => new PhoneNumberModel( - new PhoneNumberParser(), - new BasePhoneNumberExtractor(new PortuguesePhoneNumberExtractorConfiguration()))); - - this.registerModel("IpAddressModel", Culture.English, (options) => new IpAddressModel( - new IpParser(), - new BaseIpExtractor(new EnglishIpExtractorConfiguration()))); - this.registerModel("IpAddressModel", Culture.Chinese, (options) => new IpAddressModel( - new IpParser(), - new BaseIpExtractor(new ChineseIpExtractorConfiguration()))); - - this.registerModel("MentionModel", Culture.English, (options) => new MentionModel(new MentionParser(), new MentionExtractor())); - this.registerModel("HashtagModel", Culture.English, (options) => new HashtagModel(new HashtagParser(), new HashtagExtractor())); - this.registerModel("EmailModel", Culture.English, (options) => new EmailModel(new EmailParser(), new EmailExtractor())); - - this.registerModel("URLModel", Culture.English, (options) => new URLModel( - new URLParser(), - new BaseURLExtractor(new EnglishURLExtractorConfiguration()))); - this.registerModel("URLModel", Culture.Chinese, (options) => new URLModel( - new URLParser(), - new BaseURLExtractor(new ChineseURLExtractorConfiguration()))); - - this.registerModel("GUIDModel", Culture.English, (options) => new GUIDModel(new GUIDParser(), new GUIDExtractor())); - } - - getPhoneNumberModel(culture: string = null, fallbackToDefaultCulture: boolean = true): IModel { - return this.getModel("PhoneNumberModel", culture, fallbackToDefaultCulture); - } - - getIpAddressModel(culture: string = null, fallbackToDefaultCulture: boolean = true): IModel { - return this.getModel("IpAddressModel", culture, fallbackToDefaultCulture); - } - - getMentionModel(culture: string = null, fallbackToDefaultCulture: boolean = true): IModel { - return this.getModel("MentionModel", culture, fallbackToDefaultCulture); - } - - getHashtagModel(culture: string = null, fallbackToDefaultCulture: boolean = true): IModel { - return this.getModel("HashtagModel", culture, fallbackToDefaultCulture); - } - - getEmailModel(culture: string = null, fallbackToDefaultCulture: boolean = true): IModel { - return this.getModel("EmailModel", culture, fallbackToDefaultCulture); - } - - getURLModel(culture: string = null, fallbackToDefaultCulture: boolean = true): IModel { - return this.getModel("URLModel", culture, fallbackToDefaultCulture); - } - - getGUIDModel(culture: string = null, fallbackToDefaultCulture: boolean = true): IModel { - return this.getModel("GUIDModel", culture, fallbackToDefaultCulture); - } -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-sequence/tsconfig.json b/JavaScript/packages/recognizers-sequence/tsconfig.json deleted file mode 100644 index 4c43817e54..0000000000 --- a/JavaScript/packages/recognizers-sequence/tsconfig.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "target": "es2015", - "outDir": "compiled", - "sourceMap": true, - "rootDir": "src", - "moduleResolution": "node", - "declaration": true, - "declarationDir": "dist/types", - "typeRoots": [ - "node_modules/@types" - ] - }, - "include": [ - "src" - ] -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-text-suite/.npmignore b/JavaScript/packages/recognizers-text-suite/.npmignore deleted file mode 100644 index 757fb9517d..0000000000 --- a/JavaScript/packages/recognizers-text-suite/.npmignore +++ /dev/null @@ -1,4 +0,0 @@ -* -!dist/*.js -!dist/types/**/* -!README.md \ No newline at end of file diff --git a/JavaScript/packages/recognizers-text-suite/README.md b/JavaScript/packages/recognizers-text-suite/README.md deleted file mode 100644 index ca18b2204c..0000000000 --- a/JavaScript/packages/recognizers-text-suite/README.md +++ /dev/null @@ -1,221 +0,0 @@ -# Microsoft.Recognizers.Text for JavaScript - -## Getting Started - -Recognizer's are organized into groups and designed to be used in C#, Node.js, Python and Java to help you build great applications! To use the samples, install the `recognizers-text-suite` package, or clone our GitHub repository using Git. - -## Cloning and building the Repository - - git clone https://github.com/Microsoft/Recognizers-Text.git - cd Recognizers-Text - -You can choose between build the solution manually or through an automatized build.cmd file. - -### Manual Build - -Open a terminal and run the following commands: - - cd JavaScript - npm install - npm run build - npm run test - -### Automatized Build - -Launch `Build.cmd` file. - -## Installation from NPM - --- **Note:** the initial versions of the packages are available with the **@preview** tag. -- - -Install all the Recognizer's by launching the following command: - -* Get **all** the Recognizers in a single module: -`npm install @microsoft/recognizers-text-suite` - -Or, if you prefer to use a single type of recognizer: - -* Get **only** the numbers Recognizer's features: -`npm install @microsoft/recognizers-text-number` - -* Get **only** the numbers with units Recognizer's features: -`npm install @microsoft/recognizers-text-number-with-unit` - -* Get **only** the date and time Recognizer's features: -`npm install @microsoft/recognizers-text-date-time` - -* Get **only** the sequence Recognizer's features: -`npm install @microsoft/recognizers-text-sequence` - -* Get **only** the choice Recognizer's features: -`npm install @microsoft/recognizers-text-choice` - -## API Documentation - -Once the proper package is installed, you'll need to reference the package: - -````JavaScript -var Recognizers = require('@microsoft/recognizers-text-suite'); -var NumberRecognizers = require('@microsoft/recognizers-text-number'); -var NumberWithUnitRecognizers = require('@microsoft/recognizers-text-number-with-unit'); -var DateTimeRecognizers = require('@microsoft/recognizers-text-date-time'); -var SequenceRecognizers = require('@microsoft/recognizers-text-sequence'); -var ChoiceRecognizers = require('@microsoft/recognizers-text-choice'); -```` - -### Recognizer's Models - -This is the preferred way if you need to parse multiple inputs based on the same context (e.g.: language and options): - -```JavaScript -var recognizer = new NumberRecognizers.NumberRecognizer(Recognizers.Culture.English); -var model = recognizer.getNumberModel(); -var result = model.parse('Twelve'); -``` - -Or, for less verbosity, you use the helper methods: - -`var result = Recognizers.recognizeNumber("Twelve", Recognizers.Culture.English);` - -Internally, both methods will cache the instance models to avoid extra costs. - -### Microsoft.Recognizers.Text.Number - -* **Numbers** - - This recognizer will find any number from the input. E.g. _"I have two apples"_ will return _"2"_. - - `Recognizers.recognizeNumber('I have two apples', Recognizers.Culture.English)` - - Or you can obtain a model instance using: - - `new NumberRecognizers.NumberRecognizer(Recognizers.Culture.English).getNumberModel()` - - -* **Ordinal Numbers** - - This recognizer will find any ordinal number. E.g. _"eleventh"_ will return _"11"_. - - `Recognizers.recognizeOrdinal('eleventh', Recognizers.Culture.English)` - - Or you can obtain a model instance using: - - `new NumberRecognizers.NumberRecognizer(Recognizers.Culture.English).getOrdinalModel()` - - -* **Percentages** - - This recognizer will find any number presented as percentage. E.g. _"one hundred percents"_ will return _"100%"_. - - `Recognizers.recognizePercentage('one hundred percents', Recognizers.Culture.English)` - - Or you can obtain a model instance using: - - `new NumberRecognizers.NumberRecognizer(Recognizers.Culture.English).getPercentageModel()` - -### Microsoft.Recognizers.Text.NumberWithUnit - -* **Ages** - - This recognizer will find any age number presented. E.g. _"After ninety five years of age, perspectives change"_ will return _"95 Year"_. - - `Recognizers.recognizeAge('After ninety five years of age, perspectives change', Recognizers.Culture.English)` - - Or you can obtain a model instance using: - - `new NumberWithUnitRecognizers.NumberWithUnitRecognizer(Recognizers.Culture.English).getAgeModel()` - - -* **Currencies** - - This recognizer will find any currency presented. E.g. _"Interest expense in the 1988 third quarter was $ 75.3 million"_ will return _"75300000 Dollar"_. - - `Recognizers.recognizeCurrency('Interest expense in the 1988 third quarter was $ 75.3 million', Recognizers.Culture.English)` - - Or you can obtain a model instance using: - - `new NumberWithUnitRecognizers.NumberWithUnitRecognizer(Recognizers.Culture.English).getCurrencyModel()` - - -* **Dimensions** - - This recognizer will find any dimension presented. E.g. _"The six-mile trip to my airport hotel that had taken 20 minutes earlier in the day took more than three hours."_ will return _"6 Mile"_. - - `Recognizers.recognizeDimension('The six-mile trip to my airport hotel that had taken 20 minutes earlier in the day took more than three hours.', Recognizers.Culture.English)` - - Or you can obtain a model instance using: - - `new NumberWithUnitRecognizers.NumberWithUnitRecognizer(Recognizers.Culture.English).getDimensionModel()` - - -* **Temperatures** - - This recognizer will find any temperature presented. E.g. _"Set the temperature to 30 degrees celsius"_ will return _"30 C"_. - - `Recognizers.recognizeTemperature('Set the temperature to 30 degrees celsius', Recognizers.Culture.English)` - - Or you can obtain a model instance using: - - `new NumberWithUnitRecognizers.NumberWithUnitRecognizer(Recognizers.Culture.English).getTemperatureModel()` - - -### Microsoft.Recognizers.Text.DateTime - -* **DateTime** - - This recognizer will find any date, time, duration and date/time ranges, even if its write in colloquial language. E.g. _"I'll go back 8pm today"_ will return _"2017-10-04 20:00:00"_. - - `Recognizers.recognizeDateTime("I'll go back 8pm today", Recognizers.Culture.English)` - - Or you can obtain a model instance using: - - `new DateTimeRecognizers.DateTimeRecognizer(Recognizers.Culture.English).getDateTimeModel()` - -### Microsoft.Recognizers.Text.Sequence - -* **Phone Numbers** - - This model will find any patter of symbols detected as a phone number, even if its write in coloquial language. E.g. "My phone number is 1 (877) 609-2233." will return "1 (877) 609-2233". - - `Recognizers.recognizePhoneNumber("My phone number is 1 (877) 609-2233.", Culture.English)` - - Or you can obtain a model instance using: - - `new SequenceRecognizers.SequenceRecognizer(Culture.English).GetPhoneNumberModel()` - -* **IP Address** - - This model will find any Ipv4/Ipv6 presented. - E.g. "My Ip is 8.8.8.8". - - `Recognizers.recognizeIpAddress("My Ip is 8.8.8.8")` - - Or you can obtain a model instance using: - - `new SequenceRecognizers.SequenceRecognizer(Culture.English).IpAddressModel()` - -### Microsoft.Recognizers.Text.Choice - -* **Booleans** - - This recognizer will find any boolean value, even if its write with emoji. - E.g. _"👌 It's ok"_ will return _"true"_. - - `Recognizers.recognizeBoolean("👌 It's ok", Recognizers.Culture.English)` - - Or you can obtain a model instance using: - - `new ChoiceRecognizers.ChoiceRecognizer(Recognizers.Culture.English).getBooleanModel()` - -## Samples - -[Start using recognizers!](https://github.com/Microsoft/Recognizers-Text/tree/master/JavaScript/samples) - -## Integration tips - -The recognizers were designed to disjoint language's logic from the recognizer's core in order to grow without the obligation of change the supported platforms. - -To achieve this, the recognizers contains the following folders: - -* [Specs](https://github.com/Microsoft/Recognizers-Text/tree/master/Specs) - Contains all the necessary tests that should be run on any improvements to the recognizers. It's divided by recognizer and supported language. -* [Patterns](https://github.com/Microsoft/Recognizers-Text/tree/master/Patterns) - Contains all the regular expressions that fulfill the recognizers logic. It's divided by supported language. diff --git a/JavaScript/packages/recognizers-text-suite/package.json b/JavaScript/packages/recognizers-text-suite/package.json deleted file mode 100644 index a376e763f3..0000000000 --- a/JavaScript/packages/recognizers-text-suite/package.json +++ /dev/null @@ -1,43 +0,0 @@ -{ - "name": "@microsoft/recognizers-text-suite", - "version": "1.3.0", - "description": "recognizers-text-suite provides robust recognition and resolution of numbers, units, date/time, and more; expressed in multiple languages.", - "author": "Microsoft Corp.", - "license": "MIT", - "keywords": [ - "nlp", - "nlp-entity-extraction", - "datetime", - "entity-extraction", - "timex", - "numex", - "parser-library" - ], - "main": "dist/recognizers-text-suite.umd.js", - "module": "dist/recognizers-text-suite.es5.js", - "typings": "dist/types/recognizers-text-suite.d.ts", - "browser": "dist/recognizers-text-suite.browser.js", - "repository": { - "type": "git", - "url": "https://github.com/Microsoft/Recognizers-Text" - }, - "bugs": { - "url": "https://github.com/Microsoft/Recognizers-Text/issues" - }, - "engines": { - "node": ">=10.3.0" - }, - "scripts": { - "clean-build": "rimraf dist && rimraf compiled", - "prepare": "npm run clean-build && tsc && rollup -c" - }, - "dependencies": { - "@microsoft/recognizers-text-data-types-timex-expression": "~1.3.0", - "@microsoft/recognizers-text": "~1.3.0", - "@microsoft/recognizers-text-number": "~1.3.0", - "@microsoft/recognizers-text-number-with-unit": "~1.3.0", - "@microsoft/recognizers-text-date-time": "~1.3.0", - "@microsoft/recognizers-text-sequence": "~1.3.0", - "@microsoft/recognizers-text-choice": "~1.3.0" - } -} diff --git a/JavaScript/packages/recognizers-text-suite/rollup.config.js b/JavaScript/packages/recognizers-text-suite/rollup.config.js deleted file mode 100644 index 9c6c6cea30..0000000000 --- a/JavaScript/packages/recognizers-text-suite/rollup.config.js +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import pkg from './package.json'; -import camelCase from 'lodash.camelcase'; -import resolve from 'rollup-plugin-node-resolve'; -import commonjs from 'rollup-plugin-commonjs'; -import sourceMaps from 'rollup-plugin-sourcemaps'; -import alias from 'rollup-plugin-alias'; -import path from 'path'; - -export default { - input: `compiled/recognizers-text-suite.js`, - output: [ - { file: pkg.module, format: 'es' }, - { file: pkg.main, name: camelCase(pkg.name), format: 'umd', exports: 'named' }, - { file: pkg.browser, format: 'iife', name: 'RecognizersText', exports: 'named' } - ], - exports: 'named', - sourcemap: true, - plugins: [ - alias({ - '@microsoft/recognizers-text': path.resolve(__dirname, '../recognizers-text/compiled/recognizers-text.js'), - '@microsoft/recognizers-text-choice': path.resolve(__dirname, '../recognizers-choice/compiled/recognizers-text-choice.js'), - '@microsoft/recognizers-text-number': path.resolve(__dirname, '../recognizers-number/compiled/recognizers-text-number.js'), - '@microsoft/recognizers-text-number-with-unit': path.resolve(__dirname, '../recognizers-number-with-unit/compiled/recognizers-text-number-with-unit.js'), - '@microsoft/recognizers-text-date-time': path.resolve(__dirname, '../recognizers-date-time/compiled/recognizers-text-date-time.js'), - '@microsoft/recognizers-text-sequence': path.resolve(__dirname, '../recognizers-sequence/compiled/recognizers-text-sequence.js'), - }), - // Allow bundling cjs modules (unlike webpack, rollup doesn't understand cjs) - commonjs(), - // Allow node_modules resolution, so you can use 'external' to control - // which external modules to include in the bundle - // https://github.com/rollup/rollup-plugin-node-resolve#usage - resolve(), - - // Resolve source maps to the original source - sourceMaps() - ] -}; diff --git a/JavaScript/packages/recognizers-text-suite/src/recognizers-text-suite.ts b/JavaScript/packages/recognizers-text-suite/src/recognizers-text-suite.ts deleted file mode 100644 index a237159718..0000000000 --- a/JavaScript/packages/recognizers-text-suite/src/recognizers-text-suite.ts +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -export { Culture, NumberOptions, recognizeNumber, recognizeOrdinal, recognizePercentage } from "@microsoft/recognizers-text-number"; -export { NumberWithUnitOptions, recognizeAge, recognizeCurrency, recognizeDimension, recognizeTemperature } from "@microsoft/recognizers-text-number-with-unit"; -export { DateTimeOptions, recognizeDateTime } from "@microsoft/recognizers-text-date-time"; -export { ChoiceOptions, recognizeBoolean } from "@microsoft/recognizers-text-choice"; -export { SequenceOptions, recognizePhoneNumber, recognizeIpAddress, recognizeMention, recognizeHashtag, recognizeEmail, recognizeURL, recognizeGUID } from "@microsoft/recognizers-text-sequence"; \ No newline at end of file diff --git a/JavaScript/packages/recognizers-text-suite/tsconfig.json b/JavaScript/packages/recognizers-text-suite/tsconfig.json deleted file mode 100644 index 4c43817e54..0000000000 --- a/JavaScript/packages/recognizers-text-suite/tsconfig.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "target": "es2015", - "outDir": "compiled", - "sourceMap": true, - "rootDir": "src", - "moduleResolution": "node", - "declaration": true, - "declarationDir": "dist/types", - "typeRoots": [ - "node_modules/@types" - ] - }, - "include": [ - "src" - ] -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-text/README.md b/JavaScript/packages/recognizers-text/README.md deleted file mode 100644 index dfea248945..0000000000 --- a/JavaScript/packages/recognizers-text/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# Microsoft.Recognizers.Text for JavaScript - -This module (`recognizers-text`) is a sub-module of `recognizers-text-suite`. - -Please check the [main README](https://github.com/Microsoft/Recognizers-Text/tree/master/JavaScript/packages/recognizers-text-suite) for more details. \ No newline at end of file diff --git a/JavaScript/packages/recognizers-text/package.json b/JavaScript/packages/recognizers-text/package.json deleted file mode 100644 index 308d2ea14d..0000000000 --- a/JavaScript/packages/recognizers-text/package.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "name": "@microsoft/recognizers-text", - "version": "1.3.0", - "description": "recognizers-text provides base classes for robust recognition and resolution of text entities.", - "author": "Microsoft Corp.", - "license": "MIT", - "keywords": [ - "nlp", - "nlp-entity-extraction", - "entity-extraction", - "parser-library" - ], - "main": "dist/recognizers-text.umd.js", - "module": "dist/recognizers-text.es5.js", - "typings": "dist/types/recognizers-text.d.ts", - "browser": "dist/recognizers-text.browser.js", - "repository": { - "type": "git", - "url": "https://github.com/Microsoft/Recognizers-Text" - }, - "bugs": { - "url": "https://github.com/Microsoft/Recognizers-Text/issues" - }, - "engines": { - "node": ">=10.3.0" - }, - "scripts": { - "clean-build": "rimraf dist && rimraf compiled", - "prepare": "npm run clean-build && tsc && rollup -c" - } -} diff --git a/JavaScript/packages/recognizers-text/rollup.config.js b/JavaScript/packages/recognizers-text/rollup.config.js deleted file mode 100644 index fa23c841a0..0000000000 --- a/JavaScript/packages/recognizers-text/rollup.config.js +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import resolve from 'rollup-plugin-node-resolve'; -import commonjs from 'rollup-plugin-commonjs'; -import sourceMaps from 'rollup-plugin-sourcemaps'; -import pkg from './package.json'; -import camelCase from 'lodash.camelcase'; - -export default { - input: `compiled/recognizers-text.js`, - output: [ - { file: pkg.module, format: 'es' }, - { file: pkg.main, name: camelCase(pkg.name), format: 'umd', exports: 'named' }, - { file: pkg.browser, format: 'iife', name: camelCase(pkg.name), exports: 'named' } - ], - exports: 'named', - sourcemap: true, - plugins: [ - // Allow bundling cjs modules (unlike webpack, rollup doesn't understand cjs) - commonjs(), - // Allow node_modules resolution, so you can use 'external' to control - // which external modules to include in the bundle - // https://github.com/rollup/rollup-plugin-node-resolve#usage - resolve(), - - // Resolve source maps to the original source - sourceMaps() - ] -}; diff --git a/JavaScript/packages/recognizers-text/src/culture.ts b/JavaScript/packages/recognizers-text/src/culture.ts deleted file mode 100644 index 1ed5e754b3..0000000000 --- a/JavaScript/packages/recognizers-text/src/culture.ts +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -export class Culture { - - static readonly English: string = "en-us" - static readonly EnglishOthers: string = "en-*" - static readonly Chinese: string = "zh-cn" - static readonly Spanish: string = "es-es" - static readonly Portuguese: string = "pt-br" - static readonly French: string = "fr-fr" - static readonly German: string = "de-de" - static readonly Japanese: string = "ja-jp" - static readonly Dutch: string = "nl-nl" - static readonly Italian: string = "it-it" - - static readonly supportedCultures: Culture[] = [ - new Culture("English", Culture.English), - new Culture("EnglishOthers", Culture.EnglishOthers), - new Culture("Chinese", Culture.Chinese), - new Culture("Spanish", Culture.Spanish), - new Culture("Portuguese", Culture.Portuguese), - new Culture("French", Culture.French), - new Culture("German", Culture.German), - new Culture("Japanese", Culture.Japanese), - new Culture("Dutch", Culture.Dutch), - new Culture("Italian", Culture.Italian) - ] - - readonly cultureName: string - readonly cultureCode: string - - protected constructor(cultureName: string, cultureCode: string) { - this.cultureName = cultureName; - this.cultureCode = cultureCode; - } - - static getSupportedCultureCodes(): string[] { - return Culture.supportedCultures.map(c => c.cultureCode); - } - - static mapToNearestLanguage(cultureCode: string): string { - if (cultureCode !== undefined) { - cultureCode = cultureCode.toLowerCase(); - let supportedCultureCodes = Culture.getSupportedCultureCodes(); - - if (supportedCultureCodes.indexOf(cultureCode) < 0) { - let culturePrefix = cultureCode.split('-')[0].trim(); - - supportedCultureCodes.forEach(function (supportedCultureCode) { - if (supportedCultureCode.startsWith(culturePrefix)) { - cultureCode = supportedCultureCode; - } - }); - } - } - - return cultureCode; - } -} - -export class CultureInfo { - readonly code: string; - - static getCultureInfo(cultureCode: string): CultureInfo { - return new CultureInfo(cultureCode); - } - - constructor(cultureName: string) { - this.code = cultureName; - } -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-text/src/extractors.ts b/JavaScript/packages/recognizers-text/src/extractors.ts deleted file mode 100644 index 7dd083b077..0000000000 --- a/JavaScript/packages/recognizers-text/src/extractors.ts +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { MetaData } from "./metaData"; - -export interface IExtractor { - extract(input: string): ExtractResult[] -} - -export class ExtractResult { - start: number; - length: number; - text: string; - type: string; - data?: any; - metaData?: MetaData; - - static isOverlap(erA: ExtractResult, erB: ExtractResult): boolean { - return !(erA.start >= erB.start + erB.length) && !(erB.start >= erA.start + erA.length); - } - - static isCover(er1: ExtractResult, er2: ExtractResult): boolean { - return ((er2.start < er1.start) && ((er2.start + er2.length) >= (er1.start + er1.length))) - || ((er2.start <= er1.start) && ((er2.start + er2.length) > (er1.start + er1.length))); - } - - static getFromText(source: string): ExtractResult { - return { - start: 0, - length: source.length, - text: source, - type: 'custom' - }; - } -} diff --git a/JavaScript/packages/recognizers-text/src/metaData.ts b/JavaScript/packages/recognizers-text/src/metaData.ts deleted file mode 100644 index e9e08c0977..0000000000 --- a/JavaScript/packages/recognizers-text/src/metaData.ts +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -export class MetaData { - private isHoliday: boolean = false; - - get IsHoliday(): boolean { - return this.isHoliday; - } - set IsHoliday(isHoliday: boolean) { - this.isHoliday = isHoliday; - } - - private hasMod: boolean = false; - - get HasMod(): boolean { - return this.hasMod; - } - set HasMod(hasMod: boolean) { - this.hasMod = hasMod; - } - - private isDurationWithAgoAndLater: boolean = false; - - get IsDurationWithAgoAndLater(): boolean { - return this.isDurationWithAgoAndLater; - } - set IsDurationWithAgoAndLater(isDurationWithAgoAndLater: boolean) { - this.isDurationWithAgoAndLater = isDurationWithAgoAndLater; - } -} diff --git a/JavaScript/packages/recognizers-text/src/models.ts b/JavaScript/packages/recognizers-text/src/models.ts deleted file mode 100644 index 2d6f059542..0000000000 --- a/JavaScript/packages/recognizers-text/src/models.ts +++ /dev/null @@ -1,128 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { Culture } from "./culture"; -import { match, cache } from "xregexp"; -import { StringUtility } from "./utilities"; - -export interface IModel { - readonly modelTypeName: string - parse(query: string): ModelResult[] -} - -export class ModelResult { - text: string - start: number - end: number - typeName: string - resolution: { [key: string]: any } -} - -export class ExtendedModelResult extends ModelResult { - parentText: string - - constructor(source: ModelResult = null) { - super(); - if (source) { - this.text = source.text; - this.start = source.start; - this.end = source.end; - this.typeName = source.typeName; - this.resolution = source.resolution; - } - } -} - -class ModelFactoryKey { - culture: string; - modelType: string; - options: TModelOptions; - constructor(culture: string, modelType: string, options: TModelOptions = null) { - this.culture = culture ? culture.toLowerCase() : null; - this.modelType = modelType; - this.options = options; - } - - public toString(): string { - return JSON.stringify(this); - } - - public static fromString(key: string): ModelFactoryKey { - return JSON.parse(key) as ModelFactoryKey; - } -} - -export class ModelFactory { - static readonly fallbackCulture: string = Culture.English; - - private modelFactories: Map IModel> = new Map IModel>(); - - private static cache: Map = new Map(); - - getModel(modelTypeName: string, culture: string, fallbackToDefaultCulture: boolean, options: TModelOptions): IModel { - - let result = this.tryGetModel(modelTypeName, culture, options); - if (!result.containsModel && fallbackToDefaultCulture) { - result = this.tryGetModel(modelTypeName, ModelFactory.fallbackCulture, options); - } - - if (result.containsModel) { - return result.model; - } - - throw new Error(`Could not find Model with the specified configuration: ${culture},${modelTypeName}`); - } - - tryGetModel(modelTypeName: string, culture: string, options: TModelOptions): { containsModel: boolean; model?: IModel } { - culture = Culture.mapToNearestLanguage(culture); - let cacheResult = this.getModelFromCache(modelTypeName, culture, options); - if (cacheResult) { - return { containsModel: true, model: cacheResult }; - } - - let key = this.generateKey(modelTypeName, culture); - if (this.modelFactories.has(key)) { - let model = this.modelFactories.get(key)(options); - this.registerModelInCache(modelTypeName, culture, options, model); - return { containsModel: true, model: model }; - } - - return { containsModel: false }; - } - - registerModel(modelTypeName: string, culture: string, modelCreator: (options: TModelOptions) => IModel) { - let key = this.generateKey(modelTypeName, culture); - if (this.modelFactories.has(key)) { - throw new Error(`${culture}-${modelTypeName} has already been registered.`); - } - - this.modelFactories.set(key, modelCreator); - } - - initializeModels(targetCulture: string, options: TModelOptions) { - this.modelFactories.forEach((value, key) => { - let modelFactoryKey = ModelFactoryKey.fromString(key); - if (StringUtility.isNullOrEmpty(targetCulture) || modelFactoryKey.culture === targetCulture) { - this.tryGetModel(modelFactoryKey.modelType, modelFactoryKey.culture, modelFactoryKey.options); - } - }); - } - - private generateKey(modelTypeName: string, culture: string): string { - return new ModelFactoryKey(culture, modelTypeName).toString(); - } - - private getModelFromCache(modelTypeName: string, culture: string, options: TModelOptions): IModel { - let key = this.generateCacheKey(modelTypeName, culture, options); - return ModelFactory.cache.get(key); - } - - private registerModelInCache(modelTypeName: string, culture: string, options: TModelOptions, model: IModel) { - let key = this.generateCacheKey(modelTypeName, culture, options); - ModelFactory.cache.set(key, model); - } - - private generateCacheKey(modelTypeName: string, culture: string, options: TModelOptions): string { - return new ModelFactoryKey(culture, modelTypeName, options).toString(); - } -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-text/src/parsers.ts b/JavaScript/packages/recognizers-text/src/parsers.ts deleted file mode 100644 index e508385aab..0000000000 --- a/JavaScript/packages/recognizers-text/src/parsers.ts +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { ExtractResult } from "./extractors"; - -export interface IParser { - parse(extResult: ExtractResult): ParseResult | null -} - -export class ParseResult extends ExtractResult { - constructor(er?: ExtractResult) { - super(); - if (er) { - this.length = er.length; - this.start = er.start; - this.data = er.data; - this.text = er.text; - this.type = er.type; - } - this.resolutionStr = ""; - } - - // Value is for resolution. - // e.g. 1000 for "one thousand". - // The resolutions are different for different parsers. - // Therefore, we use object here. - value?: any; - - // Output the value in string format. - // It is used in some parsers. - resolutionStr?: string; -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-text/src/recognizer.ts b/JavaScript/packages/recognizers-text/src/recognizer.ts deleted file mode 100644 index 56d478b397..0000000000 --- a/JavaScript/packages/recognizers-text/src/recognizer.ts +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { IModel, ModelFactory } from "./models"; - -export abstract class Recognizer { - public readonly Options: TRecognizerOptions; - public readonly TargetCulture: string; - - private readonly modelFactory: ModelFactory = new ModelFactory(); - - protected constructor(targetCulture: string, options: TRecognizerOptions, lazyInitialization: boolean); - protected constructor(targetCulture: string, options: any, lazyInitialization: boolean) { - if (!this.IsValidOptions(options)) { - throw new Error(`${options} is not a valid options value.`); - } - this.TargetCulture = targetCulture; - this.Options = options; - this.InitializeConfiguration(); - - if (!lazyInitialization) { - this.initializeModels(targetCulture, options); - } - } - - protected abstract InitializeConfiguration(); - - protected abstract IsValidOptions(options): boolean; - - getModel(modelTypeName: string, culture: string, fallbackToDefaultCulture: boolean): IModel { - return this.modelFactory.getModel(modelTypeName, culture || this.TargetCulture, fallbackToDefaultCulture, this.Options); - } - - registerModel(modelTypeName: string, culture: string, modelCreator: (options: TRecognizerOptions) => IModel) { - this.modelFactory.registerModel(modelTypeName, culture, modelCreator); - } - - private initializeModels(targetCulture: string, options: TRecognizerOptions) { - this.modelFactory.initializeModels(targetCulture, options); - } -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-text/src/recognizers-text.ts b/JavaScript/packages/recognizers-text/src/recognizers-text.ts deleted file mode 100644 index 6be841402e..0000000000 --- a/JavaScript/packages/recognizers-text/src/recognizers-text.ts +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -export { Culture, CultureInfo } from "./culture"; -export { IModel, ModelResult, ModelFactory } from "./models"; -export { Recognizer } from "./recognizer"; -export { IExtractor, ExtractResult } from "./extractors"; -export { IParser, ParseResult } from "./parsers"; -export { MetaData } from "./metaData"; -export { QueryProcessor, StringUtility, Match, RegExpUtility } from "./utilities"; \ No newline at end of file diff --git a/JavaScript/packages/recognizers-text/src/utilities.ts b/JavaScript/packages/recognizers-text/src/utilities.ts deleted file mode 100644 index c8017f2fe1..0000000000 --- a/JavaScript/packages/recognizers-text/src/utilities.ts +++ /dev/null @@ -1,1056 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import * as XRegExp from "xregexp"; - -export class Match { - constructor(index: number, length: number, value: string, groups) { - this.index = index; - this.length = length; - this.value = value; - this.innerGroups = groups; - } - - index: number; - length: number; - value: string; - private innerGroups: { [id: string]: { value: string, index: number, length: number, captures: string[] } }; - - groups(key: string): { value: string, index: number, length: number, captures: string[] } { - return this.innerGroups[key] ? this.innerGroups[key] : { value: '', index: 0, length: 0, captures: [] }; - } -} - -export class ConditionalMatch { - constructor(match: Match, success: boolean) { - this.match = match; - this.success = success; - } - - match: Match; - success: boolean; -} - -export class RegExpUtility { - static getMatches(regex: RegExp, source: string): Match[] { - if (!regex) { - return []; - } - - return this.getMatchesSimple(regex, source); - } - - static getMatchEnd(regex: RegExp, source: string, trim: boolean): ConditionalMatch { - let match = this.getMatches(regex, source).pop(); - let strAfter = ""; - if (match) { - strAfter = source.substring(match.index + match.length); - if (trim) { - strAfter = strAfter.trim(); - } - } - - return new ConditionalMatch(match, match && StringUtility.isNullOrEmpty(strAfter)); - } - - static getMatchesSimple(regex: RegExp, source: string): Match[] { - - // Word boundary (\b) in JS is not unicode-aware, so words starting/ending with accentuated characters will not match - // use a normalized string to match, the return matches' values using the original one - // http://blog.stevenlevithan.com/archives/javascript-regex-and-unicode - // https://stackoverflow.com/questions/2881445/utf-8-word-boundary-regex-in-javascript - let normalized = StringUtility.removeDiacriticsFromWordBoundaries(source); - - let matches = new Array(); - XRegExp.forEach(normalized, regex, match => { - let groups: { [id: string]: { value: string, index: number, length: number, captures: string[] } } = {}; - let lastGroup = ''; - - Object.keys(match).forEach(key => { - - let groupKey = key.substr(0, key.lastIndexOf('__')); - lastGroup = groupKey; - - if (!groups[groupKey]) { - groups[groupKey] = { value: '', index: 0, length: 0, captures: [] }; - } - - if (match[key]) { - let index = match.index + match[0].indexOf(match[key]); - let length = match[key].length; - let value = source.substr(index, length); - groups[groupKey].index = index; - groups[groupKey].length = length; - groups[groupKey].value = value; - groups[groupKey].captures.push(value); - } - }); - - let value = match[0]; - let index = match.index; - let length = value.length; - value = source.substr(index, length); - - matches.push(new Match(index, length, value, groups)); - }); - - return matches; - } - - static getSafeRegExp(source: string, flags?: string): RegExp { - let sanitizedSource = this.sanitizeGroups(source); - return XRegExp(sanitizedSource, flags || 'gis'); - } - - static getFirstMatchIndex(regex: RegExp, source: string): { matched: boolean; index: number; value: string; } { - let matches = RegExpUtility.getMatches(regex, source); - if (matches.length) { - return { - matched: true, - index: matches[0].index, - value: matches[0].value - }; - } - - return { matched: false, index: -1, value: null }; - } - - static split(regex: RegExp, source: string): string[] { - return XRegExp.split(source, regex); - } - - static isMatch(regex: RegExp, source: string): boolean { - return !StringUtility.isNullOrEmpty(source) - && this.getMatches(regex, source).length > 0; - } - - private static matchGroup = XRegExp(String.raw`\?<(?\w+)>`, 'gis'); - private static matchPositiveLookbehind = XRegExp(String.raw`\(\?<=`, 'gis'); - private static matchNegativeLookbehind = XRegExp(String.raw`\(\? match.replace(name, `${name}__${index++}`)); - return result; - } - - private static getNextRegex(source: string, startPos: number) { - startPos = RegExpUtility.getClosePos(source, startPos) + 1; - let closePos = RegExpUtility.getClosePos(source, startPos); - if (source[startPos] !== '(') { - closePos--; - } - - let next = (startPos === closePos) - ? null - : source.substring(startPos, closePos + 1); - - return next; - } - - private static getClosePos(source: string, startPos: number): number { - let counter = 1; - let closePos = startPos; - while (counter > 0 && closePos < source.length) { - let c = source[++closePos]; - if (c === '(') { - counter++; - } - else if (c === ')') { - counter--; - } - } - return closePos; - } -} - -export class QueryProcessor { - - static readonly Expression: string = `(?<=(\\s|\\d))(kB|K[Bb]?|M[BbM]?|G[Bb]?|B)\\b`; - static readonly SpecialTokensRegex: RegExp = RegExpUtility.getSafeRegExp(QueryProcessor.Expression, "gs"); - - static preProcess(query: string, caseSensitive: boolean = false, recode: boolean = true): string { - - if (recode) { - query = query - .replace(/0/g, "0") - .replace(/1/g, "1") - .replace(/2/g, "2") - .replace(/3/g, "3") - .replace(/4/g, "4") - .replace(/5/g, "5") - .replace(/6/g, "6") - .replace(/7/g, "7") - .replace(/8/g, "8") - .replace(/9/g, "9") - .replace(/:/g, ":") - .replace(/-/g, "-") - .replace(/,/g, ",") - .replace(///g, "/") - .replace(/G/g, "G") - .replace(/M/g, "M") - .replace(/T/g, "T") - .replace(/K/g, "K") - .replace(/k/g, "k") - .replace(/./g, ".") - .replace(/(/g, "(") - .replace(/)/g, ")") - .replace(/%/g, "%") - .replace(/、/g, ","); - } - - if (!caseSensitive) { - query = query.toLowerCase(); - } - else { - query = QueryProcessor.toLowerTermSensitive(query); - } - - return query; - } - - private static applyReverse(idx: number, str: string, value: string): string { - - let array = str.split(''); - - for (let i = 0; i < value.length; ++i) { - array[idx + i] = value[i]; - } - - return array.join(''); - } - - private static toLowerTermSensitive(input: string): string { - let result = input.toLowerCase(); - - let matches = RegExpUtility.getMatches(QueryProcessor.SpecialTokensRegex, input); - matches.forEach(match => { - result = QueryProcessor.applyReverse(match.index, result, match.value); - }); - - return result; - } - -} - -export class StringUtility { - static isNullOrWhitespace(input: string): boolean { - return !input || !input.trim(); - } - - static isNullOrEmpty(input: string): boolean { - return !input || input === ''; - } - - static isWhitespace(input: string): boolean { - return input && input !== '' && !input.trim(); - } - - static insertInto(input: string, value: string, index: number): string { - return input.substr(0, index) + value + input.substr(index); - } - - static removeDiacriticsFromWordBoundaries(input: string) { - return input.split(' ') - .map((s) => { - let length = s.length; - if (length === 0) { - return s; - } - let first = StringUtility.removeDiacritics(s.substring(0, 1)); - if (length === 1) { - return first; - } - let last = length > 1 ? StringUtility.removeDiacritics(s.substring(length - 1)) : ''; - let mid = s.substring(1, length - 1); - // console.log(first + mid + last) - return first + mid + last; - }) - .join(' '); - } - - static removeDiacritics(c: string): string { - let clean = StringUtility.diacriticsRemovalMap[c]; - return !clean ? c : clean; - } - - private static readonly diacriticsRemovalMap = { - "Ⓐ": "A", - "A": "A", - "À": "A", - "Á": "A", - "Â": "A", - "Ầ": "A", - "Ấ": "A", - "Ẫ": "A", - "Ẩ": "A", - "Ã": "A", - "Ā": "A", - "Ă": "A", - "Ằ": "A", - "Ắ": "A", - "Ẵ": "A", - "Ẳ": "A", - "Ȧ": "A", - "Ǡ": "A", - "Ä": "A", - "Ǟ": "A", - "Ả": "A", - "Å": "A", - "Ǻ": "A", - "Ǎ": "A", - "Ȁ": "A", - "Ȃ": "A", - "Ạ": "A", - "Ậ": "A", - "Ặ": "A", - "Ḁ": "A", - "Ą": "A", - "Ⱥ": "A", - "Ɐ": "A", - "Ⓑ": "B", - "B": "B", - "Ḃ": "B", - "Ḅ": "B", - "Ḇ": "B", - "Ƀ": "B", - "Ƃ": "B", - "Ɓ": "B", - "Ⓒ": "C", - "C": "C", - "Ć": "C", - "Ĉ": "C", - "Ċ": "C", - "Č": "C", - "Ç": "C", - "Ḉ": "C", - "Ƈ": "C", - "Ȼ": "C", - "Ꜿ": "C", - "Ⓓ": "D", - "D": "D", - "Ḋ": "D", - "Ď": "D", - "Ḍ": "D", - "Ḑ": "D", - "Ḓ": "D", - "Ḏ": "D", - "Đ": "D", - "Ƌ": "D", - "Ɗ": "D", - "Ɖ": "D", - "Ꝺ": "D", - "Ⓔ": "E", - "E": "E", - "È": "E", - "É": "E", - "Ê": "E", - "Ề": "E", - "Ế": "E", - "Ễ": "E", - "Ể": "E", - "Ẽ": "E", - "Ē": "E", - "Ḕ": "E", - "Ḗ": "E", - "Ĕ": "E", - "Ė": "E", - "Ë": "E", - "Ẻ": "E", - "Ě": "E", - "Ȅ": "E", - "Ȇ": "E", - "Ẹ": "E", - "Ệ": "E", - "Ȩ": "E", - "Ḝ": "E", - "Ę": "E", - "Ḙ": "E", - "Ḛ": "E", - "Ɛ": "E", - "Ǝ": "E", - "Ⓕ": "F", - "F": "F", - "Ḟ": "F", - "Ƒ": "F", - "Ꝼ": "F", - "Ⓖ": "G", - "G": "G", - "Ǵ": "G", - "Ĝ": "G", - "Ḡ": "G", - "Ğ": "G", - "Ġ": "G", - "Ǧ": "G", - "Ģ": "G", - "Ǥ": "G", - "Ɠ": "G", - "Ꞡ": "G", - "Ᵹ": "G", - "Ꝿ": "G", - "Ⓗ": "H", - "H": "H", - "Ĥ": "H", - "Ḣ": "H", - "Ḧ": "H", - "Ȟ": "H", - "Ḥ": "H", - "Ḩ": "H", - "Ḫ": "H", - "Ħ": "H", - "Ⱨ": "H", - "Ⱶ": "H", - "Ɥ": "H", - "Ⓘ": "I", - "I": "I", - "Ì": "I", - "Í": "I", - "Î": "I", - "Ĩ": "I", - "Ī": "I", - "Ĭ": "I", - "İ": "I", - "Ï": "I", - "Ḯ": "I", - "Ỉ": "I", - "Ǐ": "I", - "Ȉ": "I", - "Ȋ": "I", - "Ị": "I", - "Į": "I", - "Ḭ": "I", - "Ɨ": "I", - "Ⓙ": "J", - "J": "J", - "Ĵ": "J", - "Ɉ": "J", - "Ⓚ": "K", - "K": "K", - "Ḱ": "K", - "Ǩ": "K", - "Ḳ": "K", - "Ķ": "K", - "Ḵ": "K", - "Ƙ": "K", - "Ⱪ": "K", - "Ꝁ": "K", - "Ꝃ": "K", - "Ꝅ": "K", - "Ꞣ": "K", - "Ⓛ": "L", - "L": "L", - "Ŀ": "L", - "Ĺ": "L", - "Ľ": "L", - "Ḷ": "L", - "Ḹ": "L", - "Ļ": "L", - "Ḽ": "L", - "Ḻ": "L", - "Ł": "L", - "Ƚ": "L", - "Ɫ": "L", - "Ⱡ": "L", - "Ꝉ": "L", - "Ꝇ": "L", - "Ꞁ": "L", - "Ⓜ": "M", - "M": "M", - "Ḿ": "M", - "Ṁ": "M", - "Ṃ": "M", - "Ɱ": "M", - "Ɯ": "M", - "Ⓝ": "N", - "N": "N", - "Ǹ": "N", - "Ń": "N", - "Ñ": "N", - "Ṅ": "N", - "Ň": "N", - "Ṇ": "N", - "Ņ": "N", - "Ṋ": "N", - "Ṉ": "N", - "Ƞ": "N", - "Ɲ": "N", - "Ꞑ": "N", - "Ꞥ": "N", - "Ⓞ": "O", - "O": "O", - "Ò": "O", - "Ó": "O", - "Ô": "O", - "Ồ": "O", - "Ố": "O", - "Ỗ": "O", - "Ổ": "O", - "Õ": "O", - "Ṍ": "O", - "Ȭ": "O", - "Ṏ": "O", - "Ō": "O", - "Ṑ": "O", - "Ṓ": "O", - "Ŏ": "O", - "Ȯ": "O", - "Ȱ": "O", - "Ö": "O", - "Ȫ": "O", - "Ỏ": "O", - "Ő": "O", - "Ǒ": "O", - "Ȍ": "O", - "Ȏ": "O", - "Ơ": "O", - "Ờ": "O", - "Ớ": "O", - "Ỡ": "O", - "Ở": "O", - "Ợ": "O", - "Ọ": "O", - "Ộ": "O", - "Ǫ": "O", - "Ǭ": "O", - "Ø": "O", - "Ǿ": "O", - "Ɔ": "O", - "Ɵ": "O", - "Ꝋ": "O", - "Ꝍ": "O", - "Ⓟ": "P", - "P": "P", - "Ṕ": "P", - "Ṗ": "P", - "Ƥ": "P", - "Ᵽ": "P", - "Ꝑ": "P", - "Ꝓ": "P", - "Ꝕ": "P", - "Ⓠ": "Q", - "Q": "Q", - "Ꝗ": "Q", - "Ꝙ": "Q", - "Ɋ": "Q", - "Ⓡ": "R", - "R": "R", - "Ŕ": "R", - "Ṙ": "R", - "Ř": "R", - "Ȑ": "R", - "Ȓ": "R", - "Ṛ": "R", - "Ṝ": "R", - "Ŗ": "R", - "Ṟ": "R", - "Ɍ": "R", - "Ɽ": "R", - "Ꝛ": "R", - "Ꞧ": "R", - "Ꞃ": "R", - "Ⓢ": "S", - "S": "S", - "ẞ": "S", - "Ś": "S", - "Ṥ": "S", - "Ŝ": "S", - "Ṡ": "S", - "Š": "S", - "Ṧ": "S", - "Ṣ": "S", - "Ṩ": "S", - "Ș": "S", - "Ş": "S", - "Ȿ": "S", - "Ꞩ": "S", - "Ꞅ": "S", - "Ⓣ": "T", - "T": "T", - "Ṫ": "T", - "Ť": "T", - "Ṭ": "T", - "Ț": "T", - "Ţ": "T", - "Ṱ": "T", - "Ṯ": "T", - "Ŧ": "T", - "Ƭ": "T", - "Ʈ": "T", - "Ⱦ": "T", - "Ꞇ": "T", - "Ⓤ": "U", - "U": "U", - "Ù": "U", - "Ú": "U", - "Û": "U", - "Ũ": "U", - "Ṹ": "U", - "Ū": "U", - "Ṻ": "U", - "Ŭ": "U", - "Ü": "U", - "Ǜ": "U", - "Ǘ": "U", - "Ǖ": "U", - "Ǚ": "U", - "Ủ": "U", - "Ů": "U", - "Ű": "U", - "Ǔ": "U", - "Ȕ": "U", - "Ȗ": "U", - "Ư": "U", - "Ừ": "U", - "Ứ": "U", - "Ữ": "U", - "Ử": "U", - "Ự": "U", - "Ụ": "U", - "Ṳ": "U", - "Ų": "U", - "Ṷ": "U", - "Ṵ": "U", - "Ʉ": "U", - "Ⓥ": "V", - "V": "V", - "Ṽ": "V", - "Ṿ": "V", - "Ʋ": "V", - "Ꝟ": "V", - "Ʌ": "V", - "Ⓦ": "W", - "W": "W", - "Ẁ": "W", - "Ẃ": "W", - "Ŵ": "W", - "Ẇ": "W", - "Ẅ": "W", - "Ẉ": "W", - "Ⱳ": "W", - "Ⓧ": "X", - "X": "X", - "Ẋ": "X", - "Ẍ": "X", - "Ⓨ": "Y", - "Y": "Y", - "Ỳ": "Y", - "Ý": "Y", - "Ŷ": "Y", - "Ỹ": "Y", - "Ȳ": "Y", - "Ẏ": "Y", - "Ÿ": "Y", - "Ỷ": "Y", - "Ỵ": "Y", - "Ƴ": "Y", - "Ɏ": "Y", - "Ỿ": "Y", - "Ⓩ": "Z", - "Z": "Z", - "Ź": "Z", - "Ẑ": "Z", - "Ż": "Z", - "Ž": "Z", - "Ẓ": "Z", - "Ẕ": "Z", - "Ƶ": "Z", - "Ȥ": "Z", - "Ɀ": "Z", - "Ⱬ": "Z", - "Ꝣ": "Z", - "ⓐ": "a", - "a": "a", - "ẚ": "a", - "à": "a", - "á": "a", - "â": "a", - "ầ": "a", - "ấ": "a", - "ẫ": "a", - "ẩ": "a", - "ã": "a", - "ā": "a", - "ă": "a", - "ằ": "a", - "ắ": "a", - "ẵ": "a", - "ẳ": "a", - "ȧ": "a", - "ǡ": "a", - "ä": "a", - "ǟ": "a", - "ả": "a", - "å": "a", - "ǻ": "a", - "ǎ": "a", - "ȁ": "a", - "ȃ": "a", - "ạ": "a", - "ậ": "a", - "ặ": "a", - "ḁ": "a", - "ą": "a", - "ⱥ": "a", - "ɐ": "a", - "ⓑ": "b", - "b": "b", - "ḃ": "b", - "ḅ": "b", - "ḇ": "b", - "ƀ": "b", - "ƃ": "b", - "ɓ": "b", - "ⓒ": "c", - "c": "c", - "ć": "c", - "ĉ": "c", - "ċ": "c", - "č": "c", - "ç": "c", - "ḉ": "c", - "ƈ": "c", - "ȼ": "c", - "ꜿ": "c", - "ↄ": "c", - "ⓓ": "d", - "d": "d", - "ḋ": "d", - "ď": "d", - "ḍ": "d", - "ḑ": "d", - "ḓ": "d", - "ḏ": "d", - "đ": "d", - "ƌ": "d", - "ɖ": "d", - "ɗ": "d", - "ꝺ": "d", - "ⓔ": "e", - "e": "e", - "è": "e", - "é": "e", - "ê": "e", - "ề": "e", - "ế": "e", - "ễ": "e", - "ể": "e", - "ẽ": "e", - "ē": "e", - "ḕ": "e", - "ḗ": "e", - "ĕ": "e", - "ė": "e", - "ë": "e", - "ẻ": "e", - "ě": "e", - "ȅ": "e", - "ȇ": "e", - "ẹ": "e", - "ệ": "e", - "ȩ": "e", - "ḝ": "e", - "ę": "e", - "ḙ": "e", - "ḛ": "e", - "ɇ": "e", - "ɛ": "e", - "ǝ": "e", - "ⓕ": "f", - "f": "f", - "ḟ": "f", - "ƒ": "f", - "ꝼ": "f", - "ⓖ": "g", - "g": "g", - "ǵ": "g", - "ĝ": "g", - "ḡ": "g", - "ğ": "g", - "ġ": "g", - "ǧ": "g", - "ģ": "g", - "ǥ": "g", - "ɠ": "g", - "ꞡ": "g", - "ᵹ": "g", - "ꝿ": "g", - "ⓗ": "h", - "h": "h", - "ĥ": "h", - "ḣ": "h", - "ḧ": "h", - "ȟ": "h", - "ḥ": "h", - "ḩ": "h", - "ḫ": "h", - "ẖ": "h", - "ħ": "h", - "ⱨ": "h", - "ⱶ": "h", - "ɥ": "h", - "ⓘ": "i", - "i": "i", - "ì": "i", - "í": "i", - "î": "i", - "ĩ": "i", - "ī": "i", - "ĭ": "i", - "ï": "i", - "ḯ": "i", - "ỉ": "i", - "ǐ": "i", - "ȉ": "i", - "ȋ": "i", - "ị": "i", - "į": "i", - "ḭ": "i", - "ɨ": "i", - "ı": "i", - "ⓙ": "j", - "j": "j", - "ĵ": "j", - "ǰ": "j", - "ɉ": "j", - "ⓚ": "k", - "k": "k", - "ḱ": "k", - "ǩ": "k", - "ḳ": "k", - "ķ": "k", - "ḵ": "k", - "ƙ": "k", - "ⱪ": "k", - "ꝁ": "k", - "ꝃ": "k", - "ꝅ": "k", - "ꞣ": "k", - "ⓛ": "l", - "l": "l", - "ŀ": "l", - "ĺ": "l", - "ľ": "l", - "ḷ": "l", - "ḹ": "l", - "ļ": "l", - "ḽ": "l", - "ḻ": "l", - "ſ": "l", - "ł": "l", - "ƚ": "l", - "ɫ": "l", - "ⱡ": "l", - "ꝉ": "l", - "ꞁ": "l", - "ꝇ": "l", - "ⓜ": "m", - "m": "m", - "ḿ": "m", - "ṁ": "m", - "ṃ": "m", - "ɱ": "m", - "ɯ": "m", - "ⓝ": "n", - "n": "n", - "ǹ": "n", - "ń": "n", - "ñ": "n", - "ṅ": "n", - "ň": "n", - "ṇ": "n", - "ņ": "n", - "ṋ": "n", - "ṉ": "n", - "ƞ": "n", - "ɲ": "n", - "ʼn": "n", - "ꞑ": "n", - "ꞥ": "n", - "ⓞ": "o", - "o": "o", - "ò": "o", - "ó": "o", - "ô": "o", - "ồ": "o", - "ố": "o", - "ỗ": "o", - "ổ": "o", - "õ": "o", - "ṍ": "o", - "ȭ": "o", - "ṏ": "o", - "ō": "o", - "ṑ": "o", - "ṓ": "o", - "ŏ": "o", - "ȯ": "o", - "ȱ": "o", - "ö": "o", - "ȫ": "o", - "ỏ": "o", - "ő": "o", - "ǒ": "o", - "ȍ": "o", - "ȏ": "o", - "ơ": "o", - "ờ": "o", - "ớ": "o", - "ỡ": "o", - "ở": "o", - "ợ": "o", - "ọ": "o", - "ộ": "o", - "ǫ": "o", - "ǭ": "o", - "ø": "o", - "ǿ": "o", - "ɔ": "o", - "ꝋ": "o", - "ꝍ": "o", - "ɵ": "o", - "ⓟ": "p", - "p": "p", - "ṕ": "p", - "ṗ": "p", - "ƥ": "p", - "ᵽ": "p", - "ꝑ": "p", - "ꝓ": "p", - "ꝕ": "p", - "ⓠ": "q", - "q": "q", - "ɋ": "q", - "ꝗ": "q", - "ꝙ": "q", - "ⓡ": "r", - "r": "r", - "ŕ": "r", - "ṙ": "r", - "ř": "r", - "ȑ": "r", - "ȓ": "r", - "ṛ": "r", - "ṝ": "r", - "ŗ": "r", - "ṟ": "r", - "ɍ": "r", - "ɽ": "r", - "ꝛ": "r", - "ꞧ": "r", - "ꞃ": "r", - "ⓢ": "s", - "s": "s", - "ß": "s", - "ś": "s", - "ṥ": "s", - "ŝ": "s", - "ṡ": "s", - "š": "s", - "ṧ": "s", - "ṣ": "s", - "ṩ": "s", - "ș": "s", - "ş": "s", - "ȿ": "s", - "ꞩ": "s", - "ꞅ": "s", - "ẛ": "s", - "ⓣ": "t", - "t": "t", - "ṫ": "t", - "ẗ": "t", - "ť": "t", - "ṭ": "t", - "ț": "t", - "ţ": "t", - "ṱ": "t", - "ṯ": "t", - "ŧ": "t", - "ƭ": "t", - "ʈ": "t", - "ⱦ": "t", - "ꞇ": "t", - "ⓤ": "u", - "u": "u", - "ù": "u", - "ú": "u", - "û": "u", - "ũ": "u", - "ṹ": "u", - "ū": "u", - "ṻ": "u", - "ŭ": "u", - "ü": "u", - "ǜ": "u", - "ǘ": "u", - "ǖ": "u", - "ǚ": "u", - "ủ": "u", - "ů": "u", - "ű": "u", - "ǔ": "u", - "ȕ": "u", - "ȗ": "u", - "ư": "u", - "ừ": "u", - "ứ": "u", - "ữ": "u", - "ử": "u", - "ự": "u", - "ụ": "u", - "ṳ": "u", - "ų": "u", - "ṷ": "u", - "ṵ": "u", - "ʉ": "u", - "ⓥ": "v", - "v": "v", - "ṽ": "v", - "ṿ": "v", - "ʋ": "v", - "ꝟ": "v", - "ʌ": "v", - "ⓦ": "w", - "w": "w", - "ẁ": "w", - "ẃ": "w", - "ŵ": "w", - "ẇ": "w", - "ẅ": "w", - "ẘ": "w", - "ẉ": "w", - "ⱳ": "w", - "ⓧ": "x", - "x": "x", - "ẋ": "x", - "ẍ": "x", - "ⓨ": "y", - "y": "y", - "ỳ": "y", - "ý": "y", - "ŷ": "y", - "ỹ": "y", - "ȳ": "y", - "ẏ": "y", - "ÿ": "y", - "ỷ": "y", - "ẙ": "y", - "ỵ": "y", - "ƴ": "y", - "ɏ": "y", - "ỿ": "y", - "ⓩ": "z", - "z": "z", - "ź": "z", - "ẑ": "z", - "ż": "z", - "ž": "z", - "ẓ": "z", - "ẕ": "z", - "ƶ": "z", - "ȥ": "z", - "ɀ": "z", - "ⱬ": "z", - "ꝣ": "z" - } -} \ No newline at end of file diff --git a/JavaScript/packages/recognizers-text/tsconfig.json b/JavaScript/packages/recognizers-text/tsconfig.json deleted file mode 100644 index 35ad0e3efa..0000000000 --- a/JavaScript/packages/recognizers-text/tsconfig.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "target": "es2015", - "outDir": "compiled", - "sourceMap": true, - "rootDir": "src", - "moduleResolution": "node", - "declaration": true, - "declarationDir": "dist/types", - "allowSyntheticDefaultImports": true, - "typeRoots": [ - "node_modules/@types" - ] - }, - "include": [ - "src" - ] -} \ No newline at end of file diff --git a/JavaScript/packages/resource-generator/index.ts b/JavaScript/packages/resource-generator/index.ts deleted file mode 100644 index e12fc04342..0000000000 --- a/JavaScript/packages/resource-generator/index.ts +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import * as generator from "./lib/base-code-generator"; -import { join, basename } from "path"; - -class ResourceConfig { - input: string[]; - output: string; - header: string[]; - footer: string[]; -} - -class ResourceDefinitions { - outputPath: string; - configFiles: ResourceConfig[]; -} - -const resourcesPath = '../../../Patterns/'; - -class Startup { - public static main(): number { - let resourceDefinitionPath = process.argv[2]; - let specs: ResourceDefinitions = require(resourceDefinitionPath); - let outputPath = specs.outputPath; - specs.configFiles.forEach(config => { - let inputFilePath = join(resourcesPath, ...config.input).concat('.yaml'); - let outputFilePath = join(outputPath, config.output).concat('.ts'); - console.log(`${basename(inputFilePath)} => ${basename(outputFilePath)}`); - try { - generator.generate(inputFilePath, outputFilePath, config.header.join('\n'), config.footer.join('\n')); - } - catch (err) { - let msg = `Error while creating the resource ${basename(outputFilePath)} ${err.toString()}`; - console.log(msg); - throw err; - } - }); - - return 0; - } -} - -Startup.main(); \ No newline at end of file diff --git a/JavaScript/packages/resource-generator/lib/base-code-generator.ts b/JavaScript/packages/resource-generator/lib/base-code-generator.ts deleted file mode 100644 index f10fe2fb59..0000000000 --- a/JavaScript/packages/resource-generator/lib/base-code-generator.ts +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import * as YamlParser from "./yaml-parser"; -import { GenerateCode, CodeWriter } from "./code-writers"; -import { readFileSync, createWriteStream, write, WriteStream } from "fs"; - -const headerComment = - `// ------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// ------------------------------------------------------------------------------`; - -export function generate(yamlFilePath: string, tsFileName: string, header: string, footer: string) { - - let lineBreak = '\n'; - let yamlRaw = readFileSync(yamlFilePath, 'utf8'); - let yamlObj = YamlParser.parse(yamlRaw); - let code = GenerateCode(yamlObj); - let file = createWriteStream(tsFileName); - file.write(headerComment + lineBreak + lineBreak); - file.write(header + lineBreak); - for (let line in code) { - file.write(' ' + code[line].write() + lineBreak); - } - file.write(footer + lineBreak); - file.end(); -} \ No newline at end of file diff --git a/JavaScript/packages/resource-generator/lib/code-writers.ts b/JavaScript/packages/resource-generator/lib/code-writers.ts deleted file mode 100644 index 474e04da77..0000000000 --- a/JavaScript/packages/resource-generator/lib/code-writers.ts +++ /dev/null @@ -1,218 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { DataTypes } from "./data-types"; - -export abstract class CodeWriter { - readonly name: string; - abstract write(): string; - - constructor(name: string) { - this.name = name; - } -} - -class DefaultWriter extends CodeWriter { - readonly definition: string; - - constructor(name: string, definition: string) { - super(name); - this.definition = sanitizeDefinition(definition); - } - - write() { - return `export const ${this.name} = \`${this.definition}\`;`; - } -} - -class BooleanWriter extends CodeWriter { - readonly definition: boolean; - - constructor(name: string, definition: boolean) { - super(name); - this.definition = definition; - } - - write() { - return `export const ${this.name} = ${this.definition};`; - } -} - -class SimpleRegexWriter extends CodeWriter { - readonly definition: string; - - constructor(name: string, definition: string) { - super(name); - this.definition = sanitizeDefinition(definition, 'regex'); - } - - write() { - return `export const ${this.name} = \`${this.definition}\`;`; - } -} - -class NestedRegexWriter extends CodeWriter { - readonly definition: string; - - constructor(name: string, definition: string, references: string[]) { - super(name); - references.forEach((value, index) => { - let regex = new RegExp(`{${value}}`, 'g'); - let token = `\${${value}}`; - definition = definition.replace(regex, token); - }); - this.definition = sanitizeDefinition(definition, 'regex'); - } - - write() { - return `export const ${this.name} = \`${this.definition}\`;`; - } -} - -class ParamsRegexWriter extends CodeWriter { - readonly definition: string; - readonly params: string; - - constructor(name: string, definition: string, params: string[]) { - super(name); - params.forEach((value, index) => { - let regex = new RegExp(`{${value}}`, 'g'); - let token = `\${${value}}`; - definition = definition.replace(regex, token); - }); - this.params = params.join(': string, ').concat(': string'); - this.definition = sanitizeDefinition(definition, 'regex'); - } - - write() { - return `export const ${this.name} = (${this.params}) => { return \`${this.definition}\`; }`; - } -} - -class DictionaryWriter extends CodeWriter { - readonly keyType: string; - readonly valueType: string; - readonly entries: string[]; - - constructor(name: string, keyType: string, valueType: string, entries: Record) { - super(name); - this.entries = []; - - this.keyType = toJsType(keyType); - this.valueType = toJsType(valueType); - - let valueQuote1: string; - let valueQuote2: string; - if (this.valueType.endsWith("[]")) { - valueQuote1 = "["; - valueQuote2 = "]"; - } - else { - valueQuote1 = valueQuote2 = this.valueType === 'number' ? '' : '"'; - } - - for (let propName in entries) { - this.entries.push(`["${sanitizeElement(propName, this.keyType)}", ${valueQuote1}${sanitizeElement(entries[propName], this.valueType)}${valueQuote2}]`); - } - } - - write() { - return `export const ${this.name}: ReadonlyMap<${this.keyType}, ${this.valueType}> = new Map<${this.keyType}, ${this.valueType}>([${this.entries.join(',')}]);`; - } -} - -function sanitizeElement(value: string, valueType: string): string { - return sanitizeValue(value, valueType, false); -} - -function sanitizeDefinition(value: string, valueType: string = null): string { - - if (!valueType) { - valueType = typeof value; - } - - return sanitizeValue(value, valueType, true); -} - -function sanitizeValue(value: string, valueType: string, directUse: boolean = false): string { - - if (valueType === 'number' || valueType === 'boolean') { - return value; - } - - let stringified = JSON.stringify(value); - - // Escape backtick, only if value is directly used, as code generation will output values as backticked strings. - if (directUse) { - stringified = stringified.replace(/(? { - this.entries.push(`"${sanitizeElement(element, typeof element)}"`); - }); - } - - write() { - return `export const ${this.name} = [ ${this.entries.join(',')} ];`; - } -} - -export function GenerateCode(root: any): CodeWriter[] { - - let lines: CodeWriter[] = []; - - for (let tokenName in root) { - - let token = root[tokenName]; - if (token instanceof DataTypes.SimpleRegex) { - lines.push(new SimpleRegexWriter(tokenName, token.def)); - } - else if (token instanceof DataTypes.NestedRegex) { - lines.push(new NestedRegexWriter(tokenName, token.def, token.references)); - } - else if (token instanceof DataTypes.ParamsRegex) { - lines.push(new ParamsRegexWriter(tokenName, token.def, token.params)); - } - else if (token instanceof DataTypes.Dictionary) { - lines.push(new DictionaryWriter(tokenName, token.keyType, token.valueType, token.entries)); - } - else if (token instanceof DataTypes.List) { - lines.push(new ArrayWriter(tokenName, token.entries)); - } - else if (token instanceof Array) { - lines.push(new ArrayWriter(tokenName, token)); - } - else if (typeof token === "boolean") { - lines.push(new BooleanWriter(tokenName, token)); - } - else { - lines.push(new DefaultWriter(tokenName, token)); - } - }; - - return lines; -} \ No newline at end of file diff --git a/JavaScript/packages/resource-generator/lib/data-types.ts b/JavaScript/packages/resource-generator/lib/data-types.ts deleted file mode 100644 index a02fe0bb19..0000000000 --- a/JavaScript/packages/resource-generator/lib/data-types.ts +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -export namespace DataTypes { - export class SimpleRegex { - def: string; - } - - export class NestedRegex { - def: string; - references: string[]; - } - - export class ParamsRegex { - def: string; - params: string[]; - } - - export class Dictionary { - keyType: string; - valueType: string; - entries: Record; - } - - export class List { - type: string; - entries: string[]; - } - - export function getSimpleRegex(data: any): SimpleRegex { - let result = new SimpleRegex(); - result.def = data.def; - return result; - } - - export function getNestedRegex(data: any): NestedRegex { - let result = new NestedRegex(); - result.def = data.def; - result.references = data.references; - return result; - } - - export function getParamsRegex(data: any): ParamsRegex { - let result = new ParamsRegex(); - result.def = data.def; - result.params = data.params; - return result; - } - - export function getDictionary(data: any): Dictionary { - let result = new Dictionary(); - result.keyType = data.types[0]; - result.valueType = data.types[1]; - result.entries = data.entries; - return result; - } - - export function getList(data: any): List { - let result = new List(); - data.type = data.types[0]; - result.entries = data.entries; - return result; - } - - export function getCharacter(data: any): string { - return data; - } - - export function getBoolean(data: any): boolean { - return Boolean(JSON.parse(data)); - } -} \ No newline at end of file diff --git a/JavaScript/packages/resource-generator/lib/yaml-parser.ts b/JavaScript/packages/resource-generator/lib/yaml-parser.ts deleted file mode 100644 index 1d63305cfc..0000000000 --- a/JavaScript/packages/resource-generator/lib/yaml-parser.ts +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import * as Yaml from "js-yaml"; -import { DataTypes } from "./data-types"; - -const SimpleRegexYamlType = new Yaml.Type('!simpleRegex', { - kind: 'mapping', - construct: (data) => DataTypes.getSimpleRegex(data) -}); - -const NestedRegexYamlType = new Yaml.Type('!nestedRegex', { - kind: 'mapping', - construct: (data) => DataTypes.getNestedRegex(data) -}); - -const ParamsRegexYamlType = new Yaml.Type('!paramsRegex', { - kind: 'mapping', - construct: (data) => DataTypes.getParamsRegex(data) -}); - -const DictionaryYamlType = new Yaml.Type('!dictionary', { - kind: 'mapping', - construct: (data) => DataTypes.getDictionary(data) -}); - -const ListYamlType = new Yaml.Type('!list', { - kind: 'mapping', - construct: (data) => DataTypes.getList(data) -}); - -const CharYamlType = new Yaml.Type('!char', { - kind: 'scalar', - construct: (data) => DataTypes.getCharacter(data) -}); - -const BooleanYamlType = new Yaml.Type('!bool', { - kind: 'scalar', - construct: (data) => DataTypes.getBoolean(data) -}); - -const SCHEMA = Yaml.Schema.create([SimpleRegexYamlType, NestedRegexYamlType, ParamsRegexYamlType, DictionaryYamlType, ListYamlType, CharYamlType, BooleanYamlType]); -const yamlOptions = { schema: SCHEMA }; - -export function parse(fileStream: string) { - return Yaml.load(fileStream, yamlOptions); -} \ No newline at end of file diff --git a/JavaScript/packages/resource-generator/package.json b/JavaScript/packages/resource-generator/package.json deleted file mode 100644 index cf7c50ad6e..0000000000 --- a/JavaScript/packages/resource-generator/package.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "name": "resource-generator", - "version": "1.0.0", - "description": "Internal resource generator tool", - "author": "Microsoft Corp.", - "license": "MIT", - "keywords": [], - "files": [ - "compiled" - ], - "engines": { - "node": ">=10.3.0" - }, - "scripts": { - "build-resources": "ts-node --project tools/resource-generator/ tools/resource-generator/" - }, - "dependencies": { - "js-yaml": "^3.9.1" - } -} diff --git a/JavaScript/packages/resource-generator/tsconfig.json b/JavaScript/packages/resource-generator/tsconfig.json deleted file mode 100644 index 47bb5c3e0e..0000000000 --- a/JavaScript/packages/resource-generator/tsconfig.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "compilerOptions": { - "target": "es6", - "module": "commonjs", - "moduleResolution": "node", - "outDir": "compiled", - "rootDir": "./", - "sourceMap": true - }, - "exclude": [ - "node_modules", - "generated" - ] -} \ No newline at end of file diff --git a/JavaScript/samples/README.md b/JavaScript/samples/README.md deleted file mode 100644 index 8ed7b15bb9..0000000000 --- a/JavaScript/samples/README.md +++ /dev/null @@ -1,379 +0,0 @@ -# JavaScript Samples - -The best way to learn how to use something is through examples. The JavaScript project contains two simple samples to get you started. - -## Simple Console ([source](./simple-console)) - -This sample demonstrate the combination of all Recognizers to extract possible values from the user's input. - -First, install its dependencies: - -````npm install```` - -And then start the sample: - -````npm start```` - -The important piece is the `Recognizers` module, which you'll need to import using: - -````JavaScript -var Recognizers = require('@microsoft/recognizers-text-suite'); -```` - -Then, the sample gets a model reference of each available Recognizer. We need to do so by passing the Culture code we'll want to detect. E.g.: `en-us`. - -So far, the available models are: - -````JavaScript -// Use English for the Recognizers culture -var myCulture = Recognizers.Culture.English; - -// Add Number recognizer - This recognizer will find any number from the input -// E.g "I have two apples" will return "2". -Recognizers.recognizeNumber(query, myCulture) - -// Add Ordinal number recognizer - This recognizer will find any ordinal number -// E.g "eleventh" will return "11". -Recognizers.recognizeOrdinal(query, myCulture) - -// Add Percentage recognizer - This recognizer will find any number presented as percentage -// E.g "one hundred percents" will return "100%" -Recognizers.recognizePercentage(query, myCulture) - -// Add Age recognizer - This recognizer will find any age number presented -// E.g "After ninety five years of age, perspectives change" will return "95 Year" -Recognizers.recognizeAge(query, myCulture) - -// Add Currency recognizer - This recognizer will find any currency presented -// E.g "Interest expense in the 1988 third quarter was $ 75.3 million" will return "75300000 Dollar" -Recognizers.recognizeCurrency(query, myCulture) - -// Add Dimension recognizer - This recognizer will find any dimension presented -// E.g "The six-mile trip to my airport hotel that had taken 20 minutes earlier in the day took more than three hours." will return "6 Mile" -Recognizers.recognizeDimension(query, myCulture) - -// Add Temperature recognizer - This recognizer will find any temperature presented -// E.g "Set the temperature to 30 degrees celsius" will return "30 C" -Recognizers.recognizeTemperature(query, myCulture) - -// Add Datetime recognizer - This model will find any Date even if its write in coloquial language - -// E.g "I'll go back 8pm today" will return "2017-10-04 20:00:00" -Recognizers.recognizeDateTime(query, myCulture) - -// Add PhoneNumber recognizer - This recognizer will find any phone number presented -// E.g "My phone number is ( 19 ) 38294427." -Recognizers.recognizePhoneNumber(query, myCulture), - -// Add IP recognizer - This recognizer will find any Ipv4/Ipv6 presented -// E.g "My Ip is 8.8.8.8" -Recognizers.recognizeIpAddress(query, myCulture), - -// Boolean recognizer - This function will find yes/no like responses, including emoji - -// E.g "yup, I need that" will return "True" -Recognizers.recognizeBoolean(query, myCulture) -```` - -All these models accept an input as a string and returns an **Array** of [ModelResult](../packages/recognizers-number/src/models.ts#L8-L14): - -````JavaScript -var result = Recognizers.recognizeNumber("I have twenty apples"); - -// Returns: -// [ -// { -// "start": 7, -// "end": 12, -// "resolution": { -// "value": "20" -// }, -// "text": "twenty", -// "typeName": "number" -// } -// ] -```` - -## Browser Sample ([source](./browser)) - -The Recognizers package can also be used in a browser. So far, all major browsers are supported and IE11 can be supported using a Polyfill. - -The Browser sample parses the user input and prints the results. -It allows to select the Recognizer type and also the culture. - -To run the sample, first install its dependencies: - -````npm install```` - -Run the sample's web server: - -````npm start```` - -Open a browser to [http://localhost:8000/](http://localhost:8000/) - -The sample works by referencing the browser bundle generated on build (located at `/dist/recognizers-text.browser.js`). - -Recognizers Models can then be obtained from the global `RecognizersText` namespace: - -````JavaScript -var result = Recognizers.recognizeDateTime("I need to leave ASAP", "en-us"); - -// Returns: -// [ -// { -// "start": 16, -// "end": 19, -// "resolution": [ -// { -// "timex": "FUTURE_REF", -// "type": "datetime", -// "value": "2017-10-12 18:13:44" -// } -// ], -// "text": "asap", -// "typeName": "datetimeV2.datetime" -// } -// ] -```` - -> Alternativly, if you are using Browserify, Babel or Webpack, the UMD module can be used instead (located at `/dist/recognizers-text.umd.js`). This is the default when using `require('@microsoft/recognizers-text')`. - -> NOTE for IE11: In order to support it, the [core-js shim](https://github.com/zloirock/core-js) needs to be added: - -````HTML - - -```` - -## BotBuilder Sample ([source](./botbuilder)) - -This sample demonstrate how the Recognizers can be used with a BotBuilder Bot to parse user input. The bot provides a basic experience for ordering roses, it starts by asking the amount of roses and then asks for a delivery date and time. - -First, install its dependencies: - -````npm install```` - -Start the sample: - -````npm start```` - -Then, launch the [BotFramework Emulator](https://github.com/Microsoft/BotFramework-Emulator/releases) and connect it to **http://127.0.0.1:3978/api/messages**. - -Once connected, the bot will display a welcome message and ask for how many roses to deliver. - -In order to validate user input, [Custom prompts](https://github.com/Microsoft/BotBuilder/issues/3129#issuecomment-315849557) are used, which can run custom validation logic using the [`onRecognizer` handler](https://docs.botframework.com/en-us/node/builder/chat-reference/classes/_botbuilder_d_.prompt.html#onrecognize). The following code creates a bot dialog that prompts the user for an integer number: - -````JavaScript -// Ask for amount of roses and validate input -bot.dialog('ask-amount', new builder.Prompt().onRecognize((context, callback) => { - var input = context.message.text || ''; - var results = Recognizers.recognizeNumber(input, Recognizers.Culture.English); - - // Care for the first result only - if (results.length && results[0].typeName === 'number') { - var first = results[0]; - var resolution = parseFloat(first.resolution.value); - if (resolution % 1 === 0) { - // no decimal part detected, good! - return callback(null, 1, resolution); - } else { - // decimal part detected - context.dialogData.options.prompt = 'I need to send whole roses, not fractions of them. How many would you like to send?'; - } - } else { - context.dialogData.options.prompt = 'I\'m sorry, that doesn\'t seem to be a valid quantity'; - } - - // return with score 0 to re-prompt - callback(null, 0); -})); -```` - -Now, to call this dialog and later obtain its value, we need to invoke it throught a waterfall dialog, call the prompt in the first function and obtain the value in the next function: - -````JavaScript -var bot = new builder.UniversalBot(connector, [ - function (session) { - // Welcome message - // ... - - // Prompt for amount of roses - var promptMessage = [ - 'How many roses do you want to send?', - 'Some valid options are:', - ' - A dozen', - ' - 22', - ' - Just one rose']; - - session.beginDialog('ask-amount', { prompt: promptMessage.join('\n\n') }); - }, - - function (session, results) { - // results.response contains the prompt returned value - var amount = results.response; - - var amountMsg = session.ngettext(`I'll send just one rose.`, `I'll send ${amount} roses.`, amount); - session.send(`Great! ${amountMsg}`); - - // ... - session.endDialog(); - } -]); -```` - -Asking the user for a specific delivery time may require special parsing, like extracting both date and time from the user input, or even obtain a range of dates and times. - -The [`ask-date` dialog](./botbuilder/index.js#L118-L132) does exactly that. It will prompt the user for a possible delivery time, parse the user's input and extract, at least, one of these avaliable return values using the DateTime Recognizer: - - - date - - daterange - - datetime - - datetimerange - -(These are the DateTime Recognizer types that contains *date* information) - -> NOTE: The DateTime Recognizer uses LUIS datetimeV2 subtypes. For a full list, please visit [LUIS prebuilt entities - Subtypes of datetimeV2](https://docs.microsoft.com/en-us/azure/cognitive-services/luis/pre-builtentities#subtypes-of-datetimev2). - -This dialog uses a helper method to call the DateTime Recognizer, to validate the subtype and check the selected delivery moment is at least one hour from now: - -````JavaScript -// Date Helpers -function validateAndExtract(input) { - - var results = Recognizers.recognizeDateTime(input, Recognizers.Culture.English); - - // Check there are valid results - if (results.length && results[0].typeName.startsWith('datetimeV2')) { - // The DateTime model can return several resolution types (https://github.com/Microsoft/Recognizers-Text/blob/master/JavaScript/recognizers-date-time/src/dateTime/constants.ts#L2-L9) - // We only care for those with a date, date and time, or date time period: - // date, daterange, datetime, datetimerange - - var first = results[0]; - var subType = first.typeName.split('.')[1]; - var resolutionValues = first.resolution && first.resolution.values; - - if (!resolutionValues) { - // no resolution values - return { - valid: false - } - } - - if (subType.includes('date') && !subType.includes('range')) { - // a date (or date & time) or multiple - var moments = resolutionValues.map(m => new Date(m.value)); - var moment = moments.find(isFuture) || moments[0]; // Look for the first future moment; default to first resolution - if (isFuture(moment)) { - // a future moment, valid! - return { - valid: true, - value: moment - }; - } - - // a past moment - return { - valid: false, - error: 'past_value', - value: moment, - } - } else if (subType.includes('date') && subType.includes('range')) { - // range - var from = new Date(resolutionValues[0].start); - var to = new Date(resolutionValues[0].end); - if (!isNaN(from.getTime()) && !isNaN(to.getTime())) { - if (isFuture(from) && isFuture(to)) { - // future - return { - valid: true, - value: [from, to] - }; - } - - // past - return { - valid: false, - error: 'past_value', - value: [from, to] - }; - } - } - } - - return { - valid: false - }; -} - -function isFuture(date) { - // at least one hour - var anHour = 1000 * 60 * 60; - return date.getTime() > (Date.now() + anHour); -} -```` - -We use the helper function from the [`ask-date` custom prompt dialog](./botbuilder/index.js#L118-L132): - -````JavaScript -var DateValidationErros = { - 'past_value': 'I\'m sorry, but I need at least an hour to deliver.\n\n $moment$ is no good for me.\n\nWhat other moment suits you best?', - 'default': 'I\'m sorry, that doesn\'t seem to be a valid delivery date and time' -}; - -// Ask for delivery date and validate input -bot.dialog('ask-date', new builder.Prompt().onRecognize((context, callback) => { - - var result = validateAndExtract(context.message.text || ''); - if (result.valid) { - // return value to calling dialog - return callback(null, 1, result.value); - } - - // Set error message and re-prompt; - var errorTemplate = DateValidationErros[result.error] || DateValidationErros.default; - context.dialogData.options.prompt = errorTemplate.replace('$moment$', momentOrRangeToString(result.value, '')); - callback(null, 0); -})); - -function momentOrRangeToString(moment, momentPrefix) { - momentPrefix = momentPrefix !== undefined ? momentPrefix : 'on '; - if (_.isDate(moment)) { - return momentPrefix + moment.toLocaleString('en-US'); - } else if (_.isArray(moment)) { - return 'from ' + moment.map(m => momentOrRangeToString(m, '')).join(' to '); - } - - return 'not supported'; -} -```` - -Finally, this is how you call the dialog and obtain the date (or dates) back: - -````JavaScript -var bot = new builder.UniversalBot(connector, [ - function (session) { - // Prompt for delivery date - var promptMessage = [ - 'When do you want to receive the delivery?', - 'Some valid options are:', - ' - Tomorrow morning', - ' - 12/30/2017', - ' - 9PM Tomorrow', - ' - Five hours from now', - ' - From 9AM to 10AM tomorrow']; - session.beginDialog('ask-date', { prompt: promptMessage.join('\n\n') }); - }, - - function (session, results) { - // results.response contains the date (or array of dates) returned from the prompt - var momentOrRange = results.response; - - session.send(`Thank you! I'll deliver ${momentOrRangeToString(momentOrRange)}.`); - - // TODO: It should continue to a checkout dialog or page - session.send('Have a nice day!'); - session.endDialog(); - } -]); -```` diff --git a/JavaScript/samples/botbuilder/.env b/JavaScript/samples/botbuilder/.env deleted file mode 100644 index c77a797cc4..0000000000 --- a/JavaScript/samples/botbuilder/.env +++ /dev/null @@ -1,4 +0,0 @@ -# Bot Framework Credentials - -MICROSOFT_APP_ID= -MICROSOFT_APP_PASSWORD= \ No newline at end of file diff --git a/JavaScript/samples/botbuilder/.vscode/launch.json b/JavaScript/samples/botbuilder/.vscode/launch.json deleted file mode 100644 index b048bd4f3d..0000000000 --- a/JavaScript/samples/botbuilder/.vscode/launch.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - // Use IntelliSense to learn about possible attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [ - { - "type": "node", - "request": "launch", - "name": "Launch Program", - "program": "${workspaceFolder}\\index.js" - } - ] -} \ No newline at end of file diff --git a/JavaScript/samples/botbuilder/index.js b/JavaScript/samples/botbuilder/index.js deleted file mode 100644 index 3f8a301686..0000000000 --- a/JavaScript/samples/botbuilder/index.js +++ /dev/null @@ -1,286 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// Our Number and DateTime Recognizer models -var Recognizers = require('@microsoft/recognizers-text-suite'); -var recognizeNumber = (query) => Recognizers.recognizeNumber(query, Recognizers.Culture.English); -var recognizeDate = (query) => Recognizers.recognizeDateTime(query, Recognizers.Culture.English); -var recognizeBoolean = (query) => Recognizers.recognizeBoolean(query, Recognizers.Culture.English); - -// This loads the environment variables from the .env file -require('dotenv-extended').load(); - -var _ = require('lodash'); -var builder = require('botbuilder'); -var restify = require('restify'); - -// Setup Restify Server -var server = restify.createServer(); -server.listen(process.env.port || process.env.PORT || 3979, function () { - console.log('%s listening to %s', server.name, server.url); -}); - -// Create chat bot and listen to messages -var connector = new builder.ChatConnector({ - appId: process.env.MICROSOFT_APP_ID, - appPassword: process.env.MICROSOFT_APP_PASSWORD -}); -server.post('/api/messages', connector.listen()); - -var bot = new builder.UniversalBot(connector, [ - function (session) { - // Welcome message - var welcomeCard = new builder.HeroCard(session) - .title('Welcome to Contoso Roses') - .subtitle('These are the roses you are looking for!') - .images([ - new builder.CardImage(session) - .url('https://placeholdit.imgix.net/~text?txtsize=56&txt=Contoso%20Roses&w=640&h=330') - .alt('Contoso Roses') - ]); - - session.send(new builder.Message(session).addAttachment(welcomeCard)); - - // Prompt for amount of roses - var promptMessage = [ - 'How many roses do you want to send?', - 'Some valid options are:', - ' - A dozen', - ' - 22', - ' - Just one rose']; - - session.beginDialog('ask-amount', { prompt: promptMessage.join('\n\n') }); - }, - - function (session, results) { - // results.response contains the prompt returned value - var amount = results.response; - var amountMsg = session.ngettext(`I'll send just one rose.`, `I'll send ${amount} roses.`, amount); - session.send(`Great! ${amountMsg}`); - - // store amount - session.dialogData.amount = amount; - - // Prompt for delivery date - var promptMessage = [ - `When do you want to receive the ${session.ngettext('rose', 'roses', amount)}?`, - 'Some valid options are:', - ' - Tomorrow morning', - ' - 12/30/2017', - ' - 9PM Tomorrow', - ' - Five hours from now', - ' - From 9AM to 10AM tomorrow']; - session.beginDialog('ask-date', { prompt: promptMessage.join('\n\n') }); - }, - - function (session, results) { - // results.response contains the date (or array of dates) returned from the prompt - var momentOrRange = results.response; - - // store dateTime - session.dialogData.momentOrRange = momentOrRangeToString(momentOrRange); - - var amount = session.dialogData.amount; - var nRoses = session.ngettext(`just one rose`, `${amount} roses`, amount); - session.send(`Just a last confirmation. You need ${nRoses} ${momentOrRangeToString(momentOrRange)}.`); - - var promptMessage = [ - `It's that ok?`, - `(hint: I can speak emoji 👌)` - ]; - - session.beginDialog('ask-confirmation', { prompt: promptMessage.join('\n\n') }); - }, - - function (session, results) { - // results.response contains the confirmation returned from the prompt - var confirmation = results.response; - - if (confirmation) { - var amount = session.dialogData.amount; - var momentOrRange = session.dialogData.momentOrRange; - var nRoses = session.ngettext(`just one rose`, `${amount} roses`, amount); - session.send(`Thank you! I'll deliver ${nRoses} ${momentOrRange}.`); - - // TODO: It should continue to a checkout dialog or page - session.send('Have a nice day!'); - } else { - session.send("okay... anyways, I'm going to keep the flowers in case you change your mind"); - } - - session.endDialog(); - } -]); - -// Ask for amount of roses and validate input -bot.dialog('ask-amount', new builder.Prompt().onRecognize((context, callback) => { - var input = context.message.text || ''; - - // Parse user input as is - var results = recognizeNumber(input); - - // Care for the first result only - if (results.length && results[0].typeName === 'number') { - var first = results[0]; - var resolution = parseFloat(first.resolution.value); - if (resolution % 1 === 0) { - // no decimal part detected, good! - return callback(null, 1, resolution); - } else { - // decimal part detected - context.dialogData.options.prompt = 'I need to send whole roses, not fractions of them. How many would you like to send?'; - } - } else { - context.dialogData.options.prompt = 'I\'m sorry, that doesn\'t seem to be a valid quantity'; - } - - // return with score 0 to re-prompt - callback(null, 0); -})); - -var DateValidationErros = { - 'past_value': 'I\'m sorry, but I need at least an hour to deliver.\n\n $moment$ is no good for me.\n\nWhat other moment suits you best?', - 'default': 'I\'m sorry, that doesn\'t seem to be a valid delivery date and time' -}; - -// Ask for delivery date and validate input -bot.dialog('ask-date', new builder.Prompt().onRecognize((context, callback) => { - var result = validateAndExtract(context.message.text || ''); - - if (result.valid) { - // return value to calling dialog - return callback(null, 1, result.value); - } - - // Set error message and re-prompt; - var errorTemplate = DateValidationErros[result.error] || DateValidationErros.default; - context.dialogData.options.prompt = errorTemplate.replace('$moment$', momentOrRangeToString(result.value, '')); - callback(null, 0); -})); - -// Ask for confirmation and validate input -bot.dialog('ask-confirmation', new builder.Prompt().onRecognize((context, callback) => { - var input = context.message.text || ''; - - // Parse user input as is - var results = recognizeBoolean(input); - - // Care for the first result only - if (results.length && results[0].typeName === 'boolean') { - var first = results[0]; - var resolution = first.resolution.value; - if (typeof(resolution) === 'boolean') { - // it's a boolean, good! - return callback(null, 1, resolution); - } else { - // resolution value undefined - context.dialogData.options.prompt = 'I need a direct response, please'; - } - } else { - context.dialogData.options.prompt = 'I\'m sorry, that doesn\'t seem to be a valid response'; - } - - // return with score 0 to re-prompt - callback(null, 0); -})); - -// Send welcome when conversation with bot is started, by initiating the root dialog -bot.on('conversationUpdate', function (message) { - if (message.membersAdded) { - message.membersAdded.forEach(function (identity) { - if (identity.id === message.address.bot.id) { - bot.beginDialog(message.address, '/'); - } - }); - } -}); - -// log any bot errors into the console -bot.on('error', function (e) { - console.log('And error ocurred', e); -}); - -// Date Helpers -function validateAndExtract(input) { - - var results = recognizeDate(input); - - // Check there are valid results - if (results.length && results[0].typeName.startsWith('datetimeV2')) { - // The DateTime model can return several resolution types (https://github.com/Microsoft/Recognizers-Text/blob/master/JavaScript/recognizers-date-time/src/dateTime/constants.ts#L2-L9) - // We only care for those with a date, date and time, or date time period: - // date, daterange, datetime, datetimerange - - var first = results[0]; - var subType = first.typeName.split('.')[1]; - var resolutionValues = first.resolution && first.resolution.values; - - if (!resolutionValues) { - // no resolution values - return { - valid: false - } - } - - if (subType.includes('date') && !subType.includes('range')) { - // a date (or date & time) or multiple - var moments = resolutionValues.map(m => new Date(m.value)); - var moment = moments.find(isFuture) || moments[0]; // Look for the first future moment; default to first resolution - if (isFuture(moment)) { - // a future moment, valid! - return { - valid: true, - value: moment - }; - } - - // a past moment - return { - valid: false, - error: 'past_value', - value: moment, - } - } else if (subType.includes('date') && subType.includes('range')) { - // range - var from = new Date(resolutionValues[0].start); - var to = new Date(resolutionValues[0].end); - if (!isNaN(from.getTime()) && !isNaN(to.getTime())) { - if (isFuture(from) && isFuture(to)) { - // future - return { - valid: true, - value: [from, to] - }; - } - - // past - return { - valid: false, - error: 'past_value', - value: [from, to] - }; - } - } - } - - return { - valid: false - }; -} - -function isFuture(date) { - // at least one hour - var anHour = 1000 * 60 * 60; - return date.getTime() > (Date.now() + anHour); -} - -function momentOrRangeToString(moment, momentPrefix) { - momentPrefix = momentPrefix !== undefined ? momentPrefix : 'on '; - if (_.isDate(moment)) { - return momentPrefix + moment.toLocaleString('en-US'); - } else if (_.isArray(moment)) { - return 'from ' + moment.map(m => momentOrRangeToString(m, '')).join(' to '); - } - - return 'not supported'; -} diff --git a/JavaScript/samples/botbuilder/package.json b/JavaScript/samples/botbuilder/package.json deleted file mode 100644 index 02affe773b..0000000000 --- a/JavaScript/samples/botbuilder/package.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "name": "recognizers-text-botbuilder-sample", - "version": "1.0.0", - "description": "", - "main": "index.js", - "scripts": { - "start": "node index.js" - }, - "author": "", - "license": "MIT", - "dependencies": { - "botbuilder": "^3.11.0", - "dotenv-extended": "^2.0.1", - "lodash": "^4.17.4", - "@microsoft/recognizers-text-suite": "file:../../packages/recognizers-text-suite", - "restify": "^6.0.1" - } -} diff --git a/JavaScript/samples/browser/Dockerfile b/JavaScript/samples/browser/Dockerfile deleted file mode 100644 index e2770ee3ce..0000000000 --- a/JavaScript/samples/browser/Dockerfile +++ /dev/null @@ -1,42 +0,0 @@ -## Use this container to download, and build recognizers source project -## in Nodejs without having to install the prerequisite software. This -## container doesn't depend on the underlying host's copy of the repository. -## -## Docker Image Name: recognizers-text -## Docker Container Name: recognizers-text-browser -## -## Once the container is running, use the URL on the host -## (http://localhost:8000/) to query the recognizers at ./index.html. -## -## The container user and password are both "docker" -## Log on interactively to use other Nodejs samples - - -## Step 1: BUILD & RUN: -#> docker build -t recognizers-text . && docker run -it -p 0.0.0.0:8000:8000 --name recognizers-text-browser recognizers-text - -## Step 2: Wait until you see: -#> Browser Sample listening on port 8000! - -## Step 3: Open browser to http://localhost:8000/ - -FROM node:latest - -#user is docker with password docker, has access to sudo -RUN useradd -m docker && \ - echo "docker:docker" | chpasswd && \ - adduser docker sudo - -WORKDIR /usr/src/ - -RUN git clone https://github.com/Microsoft/Recognizers-Text && \ - echo "***Clone complete" && \ - cd Recognizers-Text/JavaScript && \ - npm install && \ - echo "***Install complete" && \ - npm run-script build && \ - echo "***Build complete" - -WORKDIR /usr/src/Recognizers-Text/JavaScript/samples/browser - -CMD ["npm", "start"] diff --git a/JavaScript/samples/browser/index.html b/JavaScript/samples/browser/index.html deleted file mode 100644 index 6d4ebd4216..0000000000 --- a/JavaScript/samples/browser/index.html +++ /dev/null @@ -1,127 +0,0 @@ - - - - - - - Recognizers-Text | Browser Sandbox - - - - - - - - -

Browser Test

- - - - -
-
- - - - -
-
- -
- -
- -
Result: -
-        ...
-    
- - - - - \ No newline at end of file diff --git a/JavaScript/samples/browser/index.js b/JavaScript/samples/browser/index.js deleted file mode 100644 index 7d6668b32e..0000000000 --- a/JavaScript/samples/browser/index.js +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -const express = require('express') -const app = express() - -app.use(express.static('./')) -app.use("/scripts", express.static('../../packages/recognizers-text-suite/dist/')) - -app.listen(8000, function () { - console.log('Browser Sample listening on port 8000!') -}) \ No newline at end of file diff --git a/JavaScript/samples/browser/package.json b/JavaScript/samples/browser/package.json deleted file mode 100644 index 537fba4157..0000000000 --- a/JavaScript/samples/browser/package.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "name": "recognizers-text-browser-sample", - "version": "1.0.0", - "description": "", - "main": "index.js", - "scripts": { - "start": "node index.js" - }, - "author": "", - "license": "MIT", - "dependencies": { - "express": "^4.16.1" - } -} diff --git a/JavaScript/samples/simple-console/.vscode/launch.json b/JavaScript/samples/simple-console/.vscode/launch.json deleted file mode 100644 index bfccfe43ac..0000000000 --- a/JavaScript/samples/simple-console/.vscode/launch.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - // Use IntelliSense to learn about possible attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [ - { - "type": "node", - "request": "launch", - "name": "Launch Program", - "program": "${workspaceFolder}\\index.js", - "console": "integratedTerminal" - } - ] -} \ No newline at end of file diff --git a/JavaScript/samples/simple-console/index.js b/JavaScript/samples/simple-console/index.js deleted file mode 100644 index 8a652014f0..0000000000 --- a/JavaScript/samples/simple-console/index.js +++ /dev/null @@ -1,126 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -var Recognizers = require('@microsoft/recognizers-text-suite'); - -// Use English for the Recognizers culture -const defaultCulture = Recognizers.Culture.English; - -// Start Sample -showIntro(); -runRecognition(); - -// Read from Console and recognize -function runRecognition() { - var stdin = process.openStdin(); - - // Read the text to recognize - write('Enter the text to recognize: '); - - stdin.addListener('data', function (e) { - var input = e.toString().trim(); - if (input) { - // Exit - if (input.toLowerCase() === 'exit') { - return process.exit(); - } else { - // Retrieve all the ModelResult recognized from the user input - var results = parseAll(input, defaultCulture); - - results = [].concat.apply([], results); - - // Write results on console - write(); - write(results.length > 0 ? "I found the following entities (" + results.length + "):" : "I found no entities."); - write(); - results.forEach(function (result) { - write(JSON.stringify(result, null, "\t")); - write(); - }); - } - - } - - // Read the text to recognize - write('\nEnter the text to recognize: '); - }); -} - -// Write on console -function write(message = ""){ - process.stdout.write(message + "\n"); -} - -function parseAll(input, culture) { - return [ - // Number recognizer - This function will find any number from the input - // E.g "I have two apples" will return "2". - ...Recognizers.recognizeNumber(input, culture), - - // Ordinal number recognizer - This function will find any ordinal number - // E.g "eleventh" will return "11". - ...Recognizers.recognizeOrdinal(input, culture), - - // Percentage recognizer - This function will find any number presented as percentage - // E.g "one hundred percents" will return "100%" - ...Recognizers.recognizePercentage(input, culture), - - // Age recognizer - This function will find any age number presented - // E.g "After ninety five years of age, perspectives change" will return "95 Year" - ...Recognizers.recognizeAge(input, culture), - - // Currency recognizer - This function will find any currency presented - // E.g "Interest expense in the 1988 third quarter was $ 75.3 million" will return "75300000 Dollar" - ...Recognizers.recognizeCurrency(input, culture), - - // Dimension recognizer - This function will find any dimension presented - // E.g "The six-mile trip to my airport hotel that had taken 20 minutes earlier in the day took more than three hours." will return "6 Mile" - ...Recognizers.recognizeDimension(input, culture), - - // Temperature recognizer - This function will find any temperature presented - // E.g "Set the temperature to 30 degrees celsius" will return "30 C" - ...Recognizers.recognizeTemperature(input, culture), - - // DateTime recognizer - This function will find any Date even if its write in colloquial language - - // E.g "I'll go back 8pm today" will return "2017-10-04 20:00:00" - ...Recognizers.recognizeDateTime(input, culture), - - // Add PhoneNumber recognizer - This recognizer will find any phone number presented - // E.g "My phone number is ( 19 ) 38294427." - ...Recognizers.recognizePhoneNumber(input, culture), - - // Add IP recognizer - This recognizer will find any Ipv4/Ipv6 presented - // E.g "My Ip is 8.8.8.8" - ...Recognizers.recognizeIpAddress(input, culture), - - // URL recognizer -This recognizer will find all the urls - // E.g "bing.com" - ...Recognizers.recognizeURL(input, culture), - - // GUID recognizer - This recognizer will find all the GUID presented - // E.g "My GUID number is {123e4567-e89b-12d3-a456-426655440000}" - ...Recognizers.recognizeGUID(input, culture), - - // Boolean recognizer - This function will find yes/no like responses, including emoji - - // E.g "yup, I need that" will return "True" - ...Recognizers.recognizeBoolean(input, culture) - ]; -} - -// Show Introduction -function showIntro() { - write("Welcome to the Recognizer's Sample console application!"); - write("To try the recognizers enter a phrase and let us show you the different outputs for each recognizer or just type 'exit' to leave the application."); - write(); - write("Here are some examples you could try:"); - write(); - write("\" I want twenty meters of cable for tomorrow\""); - write("\" I'll be available tomorrow from 11am to 2pm to receive up to 5kg of sugar\""); - write("\" I'll be out between 4 and 22 this month\""); - write("\" I was the fifth person to finish the 10 km race\""); - write("\" The temperature this night will be of 40 deg celsius\""); - write("\" The american stock exchange said a seat was sold for down $ 5,000 from the previous sale last friday\""); - write("\" It happened when the baby was only ten months old\""); - write("\" No, I don't think that we can make 100k USD today\""); - write(); -} \ No newline at end of file diff --git a/JavaScript/samples/simple-console/package.json b/JavaScript/samples/simple-console/package.json deleted file mode 100644 index 1e98409b82..0000000000 --- a/JavaScript/samples/simple-console/package.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "name": "recognizers-text-console-sample", - "version": "1.0.0", - "description": "Recognizer's Sample Application", - "main": "index.js", - "scripts": { - "start": "node index.js" - }, - "license": "MIT", - "dependencies": { - "@microsoft/recognizers-text-suite": "file:../../packages/recognizers-text-suite" - } -} diff --git a/JavaScript/test/.babelrc b/JavaScript/test/.babelrc deleted file mode 100644 index d8eb23aa2c..0000000000 --- a/JavaScript/test/.babelrc +++ /dev/null @@ -1,6 +0,0 @@ -{ - "presets": [ - "@ava/stage-4" - ], - "plugins": [] -} \ No newline at end of file diff --git a/JavaScript/test/README.md b/JavaScript/test/README.md deleted file mode 100644 index 50910c0b7b..0000000000 --- a/JavaScript/test/README.md +++ /dev/null @@ -1,27 +0,0 @@ -# JavaScript Tests - -In order to verify the correct behavior of the JavaScript Recognizers, the same [Specs suite](../../Specs) is shared between platforms. - -The JavaScript test runner is implemented as a custom test reader for the specs and the execution is then derived to the proper Test Runner, based on the environment: [AVA](https://github.com/avajs/ava) for Node and [Mocha.js](https://mochajs.org) on the Browser. - -## Running the Specs in Node - -Specs can be run for Node by invoking AVA (if installed globally) or executing the `test` NPM task: - -If AVA is installed globally: -- From the [JavaScript](../) directory, execute `ava` - -Or use NPM instead: -- From the [JavaScript](../) directory, execute `npm run test` - -> NOTE: Both require to have previously built the packages ([build.cmd](../build.cmd)) - -## Running the Specs in a Browser - -All mayor browsers are supported and IE11 is also supported by [adding the core-js polyfill](../samples/browser/index.html#L9-L13) to your page's scripts. - -Running the specs on the browser is also supported. The Test Runner can be ran in the Browser using Mocha.js instead of AVA. In order to do so, the following commands need to be executed: - -- From the [JavaScript](../) directory, execute `npm run browser-test` - -Then open a browser and navigate to [http://localhost:8001/](http://localhost:8001/). \ No newline at end of file diff --git a/JavaScript/test/browser-specs/index.html b/JavaScript/test/browser-specs/index.html deleted file mode 100644 index 706a1c358c..0000000000 --- a/JavaScript/test/browser-specs/index.html +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - - - Recognizers-Text | Browser Specs - - - - - - - -
- - - - - - - - - - - - - - - \ No newline at end of file diff --git a/JavaScript/test/browser-specs/index.js b/JavaScript/test/browser-specs/index.js deleted file mode 100644 index 35311440a4..0000000000 --- a/JavaScript/test/browser-specs/index.js +++ /dev/null @@ -1,17917 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o - * Copyright JS Foundation and other contributors - * Released under MIT license - * Based on Underscore.js 1.8.3 - * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors - */ -;(function() { - - /** Used as a safe reference for `undefined` in pre-ES5 environments. */ - var undefined; - - /** Used as the semantic version number. */ - var VERSION = '4.17.4'; - - /** Used as the size to enable large array optimizations. */ - var LARGE_ARRAY_SIZE = 200; - - /** Error message constants. */ - var CORE_ERROR_TEXT = 'Unsupported core-js use. Try https://npms.io/search?q=ponyfill.', - FUNC_ERROR_TEXT = 'Expected a function'; - - /** Used to stand-in for `undefined` hash values. */ - var HASH_UNDEFINED = '__lodash_hash_undefined__'; - - /** Used as the maximum memoize cache size. */ - var MAX_MEMOIZE_SIZE = 500; - - /** Used as the internal argument placeholder. */ - var PLACEHOLDER = '__lodash_placeholder__'; - - /** Used to compose bitmasks for cloning. */ - var CLONE_DEEP_FLAG = 1, - CLONE_FLAT_FLAG = 2, - CLONE_SYMBOLS_FLAG = 4; - - /** Used to compose bitmasks for value comparisons. */ - var COMPARE_PARTIAL_FLAG = 1, - COMPARE_UNORDERED_FLAG = 2; - - /** Used to compose bitmasks for function metadata. */ - var WRAP_BIND_FLAG = 1, - WRAP_BIND_KEY_FLAG = 2, - WRAP_CURRY_BOUND_FLAG = 4, - WRAP_CURRY_FLAG = 8, - WRAP_CURRY_RIGHT_FLAG = 16, - WRAP_PARTIAL_FLAG = 32, - WRAP_PARTIAL_RIGHT_FLAG = 64, - WRAP_ARY_FLAG = 128, - WRAP_REARG_FLAG = 256, - WRAP_FLIP_FLAG = 512; - - /** Used as default options for `_.truncate`. */ - var DEFAULT_TRUNC_LENGTH = 30, - DEFAULT_TRUNC_OMISSION = '...'; - - /** Used to detect hot functions by number of calls within a span of milliseconds. */ - var HOT_COUNT = 800, - HOT_SPAN = 16; - - /** Used to indicate the type of lazy iteratees. */ - var LAZY_FILTER_FLAG = 1, - LAZY_MAP_FLAG = 2, - LAZY_WHILE_FLAG = 3; - - /** Used as references for various `Number` constants. */ - var INFINITY = 1 / 0, - MAX_SAFE_INTEGER = 9007199254740991, - MAX_INTEGER = 1.7976931348623157e+308, - NAN = 0 / 0; - - /** Used as references for the maximum length and index of an array. */ - var MAX_ARRAY_LENGTH = 4294967295, - MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1, - HALF_MAX_ARRAY_LENGTH = MAX_ARRAY_LENGTH >>> 1; - - /** Used to associate wrap methods with their bit flags. */ - var wrapFlags = [ - ['ary', WRAP_ARY_FLAG], - ['bind', WRAP_BIND_FLAG], - ['bindKey', WRAP_BIND_KEY_FLAG], - ['curry', WRAP_CURRY_FLAG], - ['curryRight', WRAP_CURRY_RIGHT_FLAG], - ['flip', WRAP_FLIP_FLAG], - ['partial', WRAP_PARTIAL_FLAG], - ['partialRight', WRAP_PARTIAL_RIGHT_FLAG], - ['rearg', WRAP_REARG_FLAG] - ]; - - /** `Object#toString` result references. */ - var argsTag = '[object Arguments]', - arrayTag = '[object Array]', - asyncTag = '[object AsyncFunction]', - boolTag = '[object Boolean]', - dateTag = '[object Date]', - domExcTag = '[object DOMException]', - errorTag = '[object Error]', - funcTag = '[object Function]', - genTag = '[object GeneratorFunction]', - mapTag = '[object Map]', - numberTag = '[object Number]', - nullTag = '[object Null]', - objectTag = '[object Object]', - promiseTag = '[object Promise]', - proxyTag = '[object Proxy]', - regexpTag = '[object RegExp]', - setTag = '[object Set]', - stringTag = '[object String]', - symbolTag = '[object Symbol]', - undefinedTag = '[object Undefined]', - weakMapTag = '[object WeakMap]', - weakSetTag = '[object WeakSet]'; - - var arrayBufferTag = '[object ArrayBuffer]', - dataViewTag = '[object DataView]', - float32Tag = '[object Float32Array]', - float64Tag = '[object Float64Array]', - int8Tag = '[object Int8Array]', - int16Tag = '[object Int16Array]', - int32Tag = '[object Int32Array]', - uint8Tag = '[object Uint8Array]', - uint8ClampedTag = '[object Uint8ClampedArray]', - uint16Tag = '[object Uint16Array]', - uint32Tag = '[object Uint32Array]'; - - /** Used to match empty string literals in compiled template source. */ - var reEmptyStringLeading = /\b__p \+= '';/g, - reEmptyStringMiddle = /\b(__p \+=) '' \+/g, - reEmptyStringTrailing = /(__e\(.*?\)|\b__t\)) \+\n'';/g; - - /** Used to match HTML entities and HTML characters. */ - var reEscapedHtml = /&(?:amp|lt|gt|quot|#39);/g, - reUnescapedHtml = /[&<>"']/g, - reHasEscapedHtml = RegExp(reEscapedHtml.source), - reHasUnescapedHtml = RegExp(reUnescapedHtml.source); - - /** Used to match template delimiters. */ - var reEscape = /<%-([\s\S]+?)%>/g, - reEvaluate = /<%([\s\S]+?)%>/g, - reInterpolate = /<%=([\s\S]+?)%>/g; - - /** Used to match property names within property paths. */ - var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/, - reIsPlainProp = /^\w*$/, - reLeadingDot = /^\./, - rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g; - - /** - * Used to match `RegExp` - * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns). - */ - var reRegExpChar = /[\\^$.*+?()[\]{}|]/g, - reHasRegExpChar = RegExp(reRegExpChar.source); - - /** Used to match leading and trailing whitespace. */ - var reTrim = /^\s+|\s+$/g, - reTrimStart = /^\s+/, - reTrimEnd = /\s+$/; - - /** Used to match wrap detail comments. */ - var reWrapComment = /\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/, - reWrapDetails = /\{\n\/\* \[wrapped with (.+)\] \*/, - reSplitDetails = /,? & /; - - /** Used to match words composed of alphanumeric characters. */ - var reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g; - - /** Used to match backslashes in property paths. */ - var reEscapeChar = /\\(\\)?/g; - - /** - * Used to match - * [ES template delimiters](http://ecma-international.org/ecma-262/7.0/#sec-template-literal-lexical-components). - */ - var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g; - - /** Used to match `RegExp` flags from their coerced string values. */ - var reFlags = /\w*$/; - - /** Used to detect bad signed hexadecimal string values. */ - var reIsBadHex = /^[-+]0x[0-9a-f]+$/i; - - /** Used to detect binary string values. */ - var reIsBinary = /^0b[01]+$/i; - - /** Used to detect host constructors (Safari). */ - var reIsHostCtor = /^\[object .+?Constructor\]$/; - - /** Used to detect octal string values. */ - var reIsOctal = /^0o[0-7]+$/i; - - /** Used to detect unsigned integer values. */ - var reIsUint = /^(?:0|[1-9]\d*)$/; - - /** Used to match Latin Unicode letters (excluding mathematical operators). */ - var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g; - - /** Used to ensure capturing order of template delimiters. */ - var reNoMatch = /($^)/; - - /** Used to match unescaped characters in compiled string literals. */ - var reUnescapedString = /['\n\r\u2028\u2029\\]/g; - - /** Used to compose unicode character classes. */ - var rsAstralRange = '\\ud800-\\udfff', - rsComboMarksRange = '\\u0300-\\u036f', - reComboHalfMarksRange = '\\ufe20-\\ufe2f', - rsComboSymbolsRange = '\\u20d0-\\u20ff', - rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange, - rsDingbatRange = '\\u2700-\\u27bf', - rsLowerRange = 'a-z\\xdf-\\xf6\\xf8-\\xff', - rsMathOpRange = '\\xac\\xb1\\xd7\\xf7', - rsNonCharRange = '\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf', - rsPunctuationRange = '\\u2000-\\u206f', - rsSpaceRange = ' \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000', - rsUpperRange = 'A-Z\\xc0-\\xd6\\xd8-\\xde', - rsVarRange = '\\ufe0e\\ufe0f', - rsBreakRange = rsMathOpRange + rsNonCharRange + rsPunctuationRange + rsSpaceRange; - - /** Used to compose unicode capture groups. */ - var rsApos = "['\u2019]", - rsAstral = '[' + rsAstralRange + ']', - rsBreak = '[' + rsBreakRange + ']', - rsCombo = '[' + rsComboRange + ']', - rsDigits = '\\d+', - rsDingbat = '[' + rsDingbatRange + ']', - rsLower = '[' + rsLowerRange + ']', - rsMisc = '[^' + rsAstralRange + rsBreakRange + rsDigits + rsDingbatRange + rsLowerRange + rsUpperRange + ']', - rsFitz = '\\ud83c[\\udffb-\\udfff]', - rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')', - rsNonAstral = '[^' + rsAstralRange + ']', - rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}', - rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]', - rsUpper = '[' + rsUpperRange + ']', - rsZWJ = '\\u200d'; - - /** Used to compose unicode regexes. */ - var rsMiscLower = '(?:' + rsLower + '|' + rsMisc + ')', - rsMiscUpper = '(?:' + rsUpper + '|' + rsMisc + ')', - rsOptContrLower = '(?:' + rsApos + '(?:d|ll|m|re|s|t|ve))?', - rsOptContrUpper = '(?:' + rsApos + '(?:D|LL|M|RE|S|T|VE))?', - reOptMod = rsModifier + '?', - rsOptVar = '[' + rsVarRange + ']?', - rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*', - rsOrdLower = '\\d*(?:(?:1st|2nd|3rd|(?![123])\\dth)\\b)', - rsOrdUpper = '\\d*(?:(?:1ST|2ND|3RD|(?![123])\\dTH)\\b)', - rsSeq = rsOptVar + reOptMod + rsOptJoin, - rsEmoji = '(?:' + [rsDingbat, rsRegional, rsSurrPair].join('|') + ')' + rsSeq, - rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')'; - - /** Used to match apostrophes. */ - var reApos = RegExp(rsApos, 'g'); - - /** - * Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks) and - * [combining diacritical marks for symbols](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks_for_Symbols). - */ - var reComboMark = RegExp(rsCombo, 'g'); - - /** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */ - var reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g'); - - /** Used to match complex or compound words. */ - var reUnicodeWord = RegExp([ - rsUpper + '?' + rsLower + '+' + rsOptContrLower + '(?=' + [rsBreak, rsUpper, '$'].join('|') + ')', - rsMiscUpper + '+' + rsOptContrUpper + '(?=' + [rsBreak, rsUpper + rsMiscLower, '$'].join('|') + ')', - rsUpper + '?' + rsMiscLower + '+' + rsOptContrLower, - rsUpper + '+' + rsOptContrUpper, - rsOrdUpper, - rsOrdLower, - rsDigits, - rsEmoji - ].join('|'), 'g'); - - /** Used to detect strings with [zero-width joiners or code points from the astral planes](http://eev.ee/blog/2015/09/12/dark-corners-of-unicode/). */ - var reHasUnicode = RegExp('[' + rsZWJ + rsAstralRange + rsComboRange + rsVarRange + ']'); - - /** Used to detect strings that need a more robust regexp to match words. */ - var reHasUnicodeWord = /[a-z][A-Z]|[A-Z]{2,}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/; - - /** Used to assign default `context` object properties. */ - var contextProps = [ - 'Array', 'Buffer', 'DataView', 'Date', 'Error', 'Float32Array', 'Float64Array', - 'Function', 'Int8Array', 'Int16Array', 'Int32Array', 'Map', 'Math', 'Object', - 'Promise', 'RegExp', 'Set', 'String', 'Symbol', 'TypeError', 'Uint8Array', - 'Uint8ClampedArray', 'Uint16Array', 'Uint32Array', 'WeakMap', - '_', 'clearTimeout', 'isFinite', 'parseInt', 'setTimeout' - ]; - - /** Used to make template sourceURLs easier to identify. */ - var templateCounter = -1; - - /** Used to identify `toStringTag` values of typed arrays. */ - var typedArrayTags = {}; - typedArrayTags[float32Tag] = typedArrayTags[float64Tag] = - typedArrayTags[int8Tag] = typedArrayTags[int16Tag] = - typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] = - typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] = - typedArrayTags[uint32Tag] = true; - typedArrayTags[argsTag] = typedArrayTags[arrayTag] = - typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] = - typedArrayTags[dataViewTag] = typedArrayTags[dateTag] = - typedArrayTags[errorTag] = typedArrayTags[funcTag] = - typedArrayTags[mapTag] = typedArrayTags[numberTag] = - typedArrayTags[objectTag] = typedArrayTags[regexpTag] = - typedArrayTags[setTag] = typedArrayTags[stringTag] = - typedArrayTags[weakMapTag] = false; - - /** Used to identify `toStringTag` values supported by `_.clone`. */ - var cloneableTags = {}; - cloneableTags[argsTag] = cloneableTags[arrayTag] = - cloneableTags[arrayBufferTag] = cloneableTags[dataViewTag] = - cloneableTags[boolTag] = cloneableTags[dateTag] = - cloneableTags[float32Tag] = cloneableTags[float64Tag] = - cloneableTags[int8Tag] = cloneableTags[int16Tag] = - cloneableTags[int32Tag] = cloneableTags[mapTag] = - cloneableTags[numberTag] = cloneableTags[objectTag] = - cloneableTags[regexpTag] = cloneableTags[setTag] = - cloneableTags[stringTag] = cloneableTags[symbolTag] = - cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] = - cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true; - cloneableTags[errorTag] = cloneableTags[funcTag] = - cloneableTags[weakMapTag] = false; - - /** Used to map Latin Unicode letters to basic Latin letters. */ - var deburredLetters = { - // Latin-1 Supplement block. - '\xc0': 'A', '\xc1': 'A', '\xc2': 'A', '\xc3': 'A', '\xc4': 'A', '\xc5': 'A', - '\xe0': 'a', '\xe1': 'a', '\xe2': 'a', '\xe3': 'a', '\xe4': 'a', '\xe5': 'a', - '\xc7': 'C', '\xe7': 'c', - '\xd0': 'D', '\xf0': 'd', - '\xc8': 'E', '\xc9': 'E', '\xca': 'E', '\xcb': 'E', - '\xe8': 'e', '\xe9': 'e', '\xea': 'e', '\xeb': 'e', - '\xcc': 'I', '\xcd': 'I', '\xce': 'I', '\xcf': 'I', - '\xec': 'i', '\xed': 'i', '\xee': 'i', '\xef': 'i', - '\xd1': 'N', '\xf1': 'n', - '\xd2': 'O', '\xd3': 'O', '\xd4': 'O', '\xd5': 'O', '\xd6': 'O', '\xd8': 'O', - '\xf2': 'o', '\xf3': 'o', '\xf4': 'o', '\xf5': 'o', '\xf6': 'o', '\xf8': 'o', - '\xd9': 'U', '\xda': 'U', '\xdb': 'U', '\xdc': 'U', - '\xf9': 'u', '\xfa': 'u', '\xfb': 'u', '\xfc': 'u', - '\xdd': 'Y', '\xfd': 'y', '\xff': 'y', - '\xc6': 'Ae', '\xe6': 'ae', - '\xde': 'Th', '\xfe': 'th', - '\xdf': 'ss', - // Latin Extended-A block. - '\u0100': 'A', '\u0102': 'A', '\u0104': 'A', - '\u0101': 'a', '\u0103': 'a', '\u0105': 'a', - '\u0106': 'C', '\u0108': 'C', '\u010a': 'C', '\u010c': 'C', - '\u0107': 'c', '\u0109': 'c', '\u010b': 'c', '\u010d': 'c', - '\u010e': 'D', '\u0110': 'D', '\u010f': 'd', '\u0111': 'd', - '\u0112': 'E', '\u0114': 'E', '\u0116': 'E', '\u0118': 'E', '\u011a': 'E', - '\u0113': 'e', '\u0115': 'e', '\u0117': 'e', '\u0119': 'e', '\u011b': 'e', - '\u011c': 'G', '\u011e': 'G', '\u0120': 'G', '\u0122': 'G', - '\u011d': 'g', '\u011f': 'g', '\u0121': 'g', '\u0123': 'g', - '\u0124': 'H', '\u0126': 'H', '\u0125': 'h', '\u0127': 'h', - '\u0128': 'I', '\u012a': 'I', '\u012c': 'I', '\u012e': 'I', '\u0130': 'I', - '\u0129': 'i', '\u012b': 'i', '\u012d': 'i', '\u012f': 'i', '\u0131': 'i', - '\u0134': 'J', '\u0135': 'j', - '\u0136': 'K', '\u0137': 'k', '\u0138': 'k', - '\u0139': 'L', '\u013b': 'L', '\u013d': 'L', '\u013f': 'L', '\u0141': 'L', - '\u013a': 'l', '\u013c': 'l', '\u013e': 'l', '\u0140': 'l', '\u0142': 'l', - '\u0143': 'N', '\u0145': 'N', '\u0147': 'N', '\u014a': 'N', - '\u0144': 'n', '\u0146': 'n', '\u0148': 'n', '\u014b': 'n', - '\u014c': 'O', '\u014e': 'O', '\u0150': 'O', - '\u014d': 'o', '\u014f': 'o', '\u0151': 'o', - '\u0154': 'R', '\u0156': 'R', '\u0158': 'R', - '\u0155': 'r', '\u0157': 'r', '\u0159': 'r', - '\u015a': 'S', '\u015c': 'S', '\u015e': 'S', '\u0160': 'S', - '\u015b': 's', '\u015d': 's', '\u015f': 's', '\u0161': 's', - '\u0162': 'T', '\u0164': 'T', '\u0166': 'T', - '\u0163': 't', '\u0165': 't', '\u0167': 't', - '\u0168': 'U', '\u016a': 'U', '\u016c': 'U', '\u016e': 'U', '\u0170': 'U', '\u0172': 'U', - '\u0169': 'u', '\u016b': 'u', '\u016d': 'u', '\u016f': 'u', '\u0171': 'u', '\u0173': 'u', - '\u0174': 'W', '\u0175': 'w', - '\u0176': 'Y', '\u0177': 'y', '\u0178': 'Y', - '\u0179': 'Z', '\u017b': 'Z', '\u017d': 'Z', - '\u017a': 'z', '\u017c': 'z', '\u017e': 'z', - '\u0132': 'IJ', '\u0133': 'ij', - '\u0152': 'Oe', '\u0153': 'oe', - '\u0149': "'n", '\u017f': 's' - }; - - /** Used to map characters to HTML entities. */ - var htmlEscapes = { - '&': '&', - '<': '<', - '>': '>', - '"': '"', - "'": ''' - }; - - /** Used to map HTML entities to characters. */ - var htmlUnescapes = { - '&': '&', - '<': '<', - '>': '>', - '"': '"', - ''': "'" - }; - - /** Used to escape characters for inclusion in compiled string literals. */ - var stringEscapes = { - '\\': '\\', - "'": "'", - '\n': 'n', - '\r': 'r', - '\u2028': 'u2028', - '\u2029': 'u2029' - }; - - /** Built-in method references without a dependency on `root`. */ - var freeParseFloat = parseFloat, - freeParseInt = parseInt; - - /** Detect free variable `global` from Node.js. */ - var freeGlobal = typeof global == 'object' && global && global.Object === Object && global; - - /** Detect free variable `self`. */ - var freeSelf = typeof self == 'object' && self && self.Object === Object && self; - - /** Used as a reference to the global object. */ - var root = freeGlobal || freeSelf || Function('return this')(); - - /** Detect free variable `exports`. */ - var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports; - - /** Detect free variable `module`. */ - var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module; - - /** Detect the popular CommonJS extension `module.exports`. */ - var moduleExports = freeModule && freeModule.exports === freeExports; - - /** Detect free variable `process` from Node.js. */ - var freeProcess = moduleExports && freeGlobal.process; - - /** Used to access faster Node.js helpers. */ - var nodeUtil = (function() { - try { - return freeProcess && freeProcess.binding && freeProcess.binding('util'); - } catch (e) {} - }()); - - /* Node.js helper references. */ - var nodeIsArrayBuffer = nodeUtil && nodeUtil.isArrayBuffer, - nodeIsDate = nodeUtil && nodeUtil.isDate, - nodeIsMap = nodeUtil && nodeUtil.isMap, - nodeIsRegExp = nodeUtil && nodeUtil.isRegExp, - nodeIsSet = nodeUtil && nodeUtil.isSet, - nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray; - - /*--------------------------------------------------------------------------*/ - - /** - * Adds the key-value `pair` to `map`. - * - * @private - * @param {Object} map The map to modify. - * @param {Array} pair The key-value pair to add. - * @returns {Object} Returns `map`. - */ - function addMapEntry(map, pair) { - // Don't return `map.set` because it's not chainable in IE 11. - map.set(pair[0], pair[1]); - return map; - } - - /** - * Adds `value` to `set`. - * - * @private - * @param {Object} set The set to modify. - * @param {*} value The value to add. - * @returns {Object} Returns `set`. - */ - function addSetEntry(set, value) { - // Don't return `set.add` because it's not chainable in IE 11. - set.add(value); - return set; - } - - /** - * A faster alternative to `Function#apply`, this function invokes `func` - * with the `this` binding of `thisArg` and the arguments of `args`. - * - * @private - * @param {Function} func The function to invoke. - * @param {*} thisArg The `this` binding of `func`. - * @param {Array} args The arguments to invoke `func` with. - * @returns {*} Returns the result of `func`. - */ - function apply(func, thisArg, args) { - switch (args.length) { - case 0: return func.call(thisArg); - case 1: return func.call(thisArg, args[0]); - case 2: return func.call(thisArg, args[0], args[1]); - case 3: return func.call(thisArg, args[0], args[1], args[2]); - } - return func.apply(thisArg, args); - } - - /** - * A specialized version of `baseAggregator` for arrays. - * - * @private - * @param {Array} [array] The array to iterate over. - * @param {Function} setter The function to set `accumulator` values. - * @param {Function} iteratee The iteratee to transform keys. - * @param {Object} accumulator The initial aggregated object. - * @returns {Function} Returns `accumulator`. - */ - function arrayAggregator(array, setter, iteratee, accumulator) { - var index = -1, - length = array == null ? 0 : array.length; - - while (++index < length) { - var value = array[index]; - setter(accumulator, value, iteratee(value), array); - } - return accumulator; - } - - /** - * A specialized version of `_.forEach` for arrays without support for - * iteratee shorthands. - * - * @private - * @param {Array} [array] The array to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @returns {Array} Returns `array`. - */ - function arrayEach(array, iteratee) { - var index = -1, - length = array == null ? 0 : array.length; - - while (++index < length) { - if (iteratee(array[index], index, array) === false) { - break; - } - } - return array; - } - - /** - * A specialized version of `_.forEachRight` for arrays without support for - * iteratee shorthands. - * - * @private - * @param {Array} [array] The array to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @returns {Array} Returns `array`. - */ - function arrayEachRight(array, iteratee) { - var length = array == null ? 0 : array.length; - - while (length--) { - if (iteratee(array[length], length, array) === false) { - break; - } - } - return array; - } - - /** - * A specialized version of `_.every` for arrays without support for - * iteratee shorthands. - * - * @private - * @param {Array} [array] The array to iterate over. - * @param {Function} predicate The function invoked per iteration. - * @returns {boolean} Returns `true` if all elements pass the predicate check, - * else `false`. - */ - function arrayEvery(array, predicate) { - var index = -1, - length = array == null ? 0 : array.length; - - while (++index < length) { - if (!predicate(array[index], index, array)) { - return false; - } - } - return true; - } - - /** - * A specialized version of `_.filter` for arrays without support for - * iteratee shorthands. - * - * @private - * @param {Array} [array] The array to iterate over. - * @param {Function} predicate The function invoked per iteration. - * @returns {Array} Returns the new filtered array. - */ - function arrayFilter(array, predicate) { - var index = -1, - length = array == null ? 0 : array.length, - resIndex = 0, - result = []; - - while (++index < length) { - var value = array[index]; - if (predicate(value, index, array)) { - result[resIndex++] = value; - } - } - return result; - } - - /** - * A specialized version of `_.includes` for arrays without support for - * specifying an index to search from. - * - * @private - * @param {Array} [array] The array to inspect. - * @param {*} target The value to search for. - * @returns {boolean} Returns `true` if `target` is found, else `false`. - */ - function arrayIncludes(array, value) { - var length = array == null ? 0 : array.length; - return !!length && baseIndexOf(array, value, 0) > -1; - } - - /** - * This function is like `arrayIncludes` except that it accepts a comparator. - * - * @private - * @param {Array} [array] The array to inspect. - * @param {*} target The value to search for. - * @param {Function} comparator The comparator invoked per element. - * @returns {boolean} Returns `true` if `target` is found, else `false`. - */ - function arrayIncludesWith(array, value, comparator) { - var index = -1, - length = array == null ? 0 : array.length; - - while (++index < length) { - if (comparator(value, array[index])) { - return true; - } - } - return false; - } - - /** - * A specialized version of `_.map` for arrays without support for iteratee - * shorthands. - * - * @private - * @param {Array} [array] The array to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @returns {Array} Returns the new mapped array. - */ - function arrayMap(array, iteratee) { - var index = -1, - length = array == null ? 0 : array.length, - result = Array(length); - - while (++index < length) { - result[index] = iteratee(array[index], index, array); - } - return result; - } - - /** - * Appends the elements of `values` to `array`. - * - * @private - * @param {Array} array The array to modify. - * @param {Array} values The values to append. - * @returns {Array} Returns `array`. - */ - function arrayPush(array, values) { - var index = -1, - length = values.length, - offset = array.length; - - while (++index < length) { - array[offset + index] = values[index]; - } - return array; - } - - /** - * A specialized version of `_.reduce` for arrays without support for - * iteratee shorthands. - * - * @private - * @param {Array} [array] The array to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @param {*} [accumulator] The initial value. - * @param {boolean} [initAccum] Specify using the first element of `array` as - * the initial value. - * @returns {*} Returns the accumulated value. - */ - function arrayReduce(array, iteratee, accumulator, initAccum) { - var index = -1, - length = array == null ? 0 : array.length; - - if (initAccum && length) { - accumulator = array[++index]; - } - while (++index < length) { - accumulator = iteratee(accumulator, array[index], index, array); - } - return accumulator; - } - - /** - * A specialized version of `_.reduceRight` for arrays without support for - * iteratee shorthands. - * - * @private - * @param {Array} [array] The array to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @param {*} [accumulator] The initial value. - * @param {boolean} [initAccum] Specify using the last element of `array` as - * the initial value. - * @returns {*} Returns the accumulated value. - */ - function arrayReduceRight(array, iteratee, accumulator, initAccum) { - var length = array == null ? 0 : array.length; - if (initAccum && length) { - accumulator = array[--length]; - } - while (length--) { - accumulator = iteratee(accumulator, array[length], length, array); - } - return accumulator; - } - - /** - * A specialized version of `_.some` for arrays without support for iteratee - * shorthands. - * - * @private - * @param {Array} [array] The array to iterate over. - * @param {Function} predicate The function invoked per iteration. - * @returns {boolean} Returns `true` if any element passes the predicate check, - * else `false`. - */ - function arraySome(array, predicate) { - var index = -1, - length = array == null ? 0 : array.length; - - while (++index < length) { - if (predicate(array[index], index, array)) { - return true; - } - } - return false; - } - - /** - * Gets the size of an ASCII `string`. - * - * @private - * @param {string} string The string inspect. - * @returns {number} Returns the string size. - */ - var asciiSize = baseProperty('length'); - - /** - * Converts an ASCII `string` to an array. - * - * @private - * @param {string} string The string to convert. - * @returns {Array} Returns the converted array. - */ - function asciiToArray(string) { - return string.split(''); - } - - /** - * Splits an ASCII `string` into an array of its words. - * - * @private - * @param {string} The string to inspect. - * @returns {Array} Returns the words of `string`. - */ - function asciiWords(string) { - return string.match(reAsciiWord) || []; - } - - /** - * The base implementation of methods like `_.findKey` and `_.findLastKey`, - * without support for iteratee shorthands, which iterates over `collection` - * using `eachFunc`. - * - * @private - * @param {Array|Object} collection The collection to inspect. - * @param {Function} predicate The function invoked per iteration. - * @param {Function} eachFunc The function to iterate over `collection`. - * @returns {*} Returns the found element or its key, else `undefined`. - */ - function baseFindKey(collection, predicate, eachFunc) { - var result; - eachFunc(collection, function(value, key, collection) { - if (predicate(value, key, collection)) { - result = key; - return false; - } - }); - return result; - } - - /** - * The base implementation of `_.findIndex` and `_.findLastIndex` without - * support for iteratee shorthands. - * - * @private - * @param {Array} array The array to inspect. - * @param {Function} predicate The function invoked per iteration. - * @param {number} fromIndex The index to search from. - * @param {boolean} [fromRight] Specify iterating from right to left. - * @returns {number} Returns the index of the matched value, else `-1`. - */ - function baseFindIndex(array, predicate, fromIndex, fromRight) { - var length = array.length, - index = fromIndex + (fromRight ? 1 : -1); - - while ((fromRight ? index-- : ++index < length)) { - if (predicate(array[index], index, array)) { - return index; - } - } - return -1; - } - - /** - * The base implementation of `_.indexOf` without `fromIndex` bounds checks. - * - * @private - * @param {Array} array The array to inspect. - * @param {*} value The value to search for. - * @param {number} fromIndex The index to search from. - * @returns {number} Returns the index of the matched value, else `-1`. - */ - function baseIndexOf(array, value, fromIndex) { - return value === value - ? strictIndexOf(array, value, fromIndex) - : baseFindIndex(array, baseIsNaN, fromIndex); - } - - /** - * This function is like `baseIndexOf` except that it accepts a comparator. - * - * @private - * @param {Array} array The array to inspect. - * @param {*} value The value to search for. - * @param {number} fromIndex The index to search from. - * @param {Function} comparator The comparator invoked per element. - * @returns {number} Returns the index of the matched value, else `-1`. - */ - function baseIndexOfWith(array, value, fromIndex, comparator) { - var index = fromIndex - 1, - length = array.length; - - while (++index < length) { - if (comparator(array[index], value)) { - return index; - } - } - return -1; - } - - /** - * The base implementation of `_.isNaN` without support for number objects. - * - * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`. - */ - function baseIsNaN(value) { - return value !== value; - } - - /** - * The base implementation of `_.mean` and `_.meanBy` without support for - * iteratee shorthands. - * - * @private - * @param {Array} array The array to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @returns {number} Returns the mean. - */ - function baseMean(array, iteratee) { - var length = array == null ? 0 : array.length; - return length ? (baseSum(array, iteratee) / length) : NAN; - } - - /** - * The base implementation of `_.property` without support for deep paths. - * - * @private - * @param {string} key The key of the property to get. - * @returns {Function} Returns the new accessor function. - */ - function baseProperty(key) { - return function(object) { - return object == null ? undefined : object[key]; - }; - } - - /** - * The base implementation of `_.propertyOf` without support for deep paths. - * - * @private - * @param {Object} object The object to query. - * @returns {Function} Returns the new accessor function. - */ - function basePropertyOf(object) { - return function(key) { - return object == null ? undefined : object[key]; - }; - } - - /** - * The base implementation of `_.reduce` and `_.reduceRight`, without support - * for iteratee shorthands, which iterates over `collection` using `eachFunc`. - * - * @private - * @param {Array|Object} collection The collection to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @param {*} accumulator The initial value. - * @param {boolean} initAccum Specify using the first or last element of - * `collection` as the initial value. - * @param {Function} eachFunc The function to iterate over `collection`. - * @returns {*} Returns the accumulated value. - */ - function baseReduce(collection, iteratee, accumulator, initAccum, eachFunc) { - eachFunc(collection, function(value, index, collection) { - accumulator = initAccum - ? (initAccum = false, value) - : iteratee(accumulator, value, index, collection); - }); - return accumulator; - } - - /** - * The base implementation of `_.sortBy` which uses `comparer` to define the - * sort order of `array` and replaces criteria objects with their corresponding - * values. - * - * @private - * @param {Array} array The array to sort. - * @param {Function} comparer The function to define sort order. - * @returns {Array} Returns `array`. - */ - function baseSortBy(array, comparer) { - var length = array.length; - - array.sort(comparer); - while (length--) { - array[length] = array[length].value; - } - return array; - } - - /** - * The base implementation of `_.sum` and `_.sumBy` without support for - * iteratee shorthands. - * - * @private - * @param {Array} array The array to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @returns {number} Returns the sum. - */ - function baseSum(array, iteratee) { - var result, - index = -1, - length = array.length; - - while (++index < length) { - var current = iteratee(array[index]); - if (current !== undefined) { - result = result === undefined ? current : (result + current); - } - } - return result; - } - - /** - * The base implementation of `_.times` without support for iteratee shorthands - * or max array length checks. - * - * @private - * @param {number} n The number of times to invoke `iteratee`. - * @param {Function} iteratee The function invoked per iteration. - * @returns {Array} Returns the array of results. - */ - function baseTimes(n, iteratee) { - var index = -1, - result = Array(n); - - while (++index < n) { - result[index] = iteratee(index); - } - return result; - } - - /** - * The base implementation of `_.toPairs` and `_.toPairsIn` which creates an array - * of key-value pairs for `object` corresponding to the property names of `props`. - * - * @private - * @param {Object} object The object to query. - * @param {Array} props The property names to get values for. - * @returns {Object} Returns the key-value pairs. - */ - function baseToPairs(object, props) { - return arrayMap(props, function(key) { - return [key, object[key]]; - }); - } - - /** - * The base implementation of `_.unary` without support for storing metadata. - * - * @private - * @param {Function} func The function to cap arguments for. - * @returns {Function} Returns the new capped function. - */ - function baseUnary(func) { - return function(value) { - return func(value); - }; - } - - /** - * The base implementation of `_.values` and `_.valuesIn` which creates an - * array of `object` property values corresponding to the property names - * of `props`. - * - * @private - * @param {Object} object The object to query. - * @param {Array} props The property names to get values for. - * @returns {Object} Returns the array of property values. - */ - function baseValues(object, props) { - return arrayMap(props, function(key) { - return object[key]; - }); - } - - /** - * Checks if a `cache` value for `key` exists. - * - * @private - * @param {Object} cache The cache to query. - * @param {string} key The key of the entry to check. - * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. - */ - function cacheHas(cache, key) { - return cache.has(key); - } - - /** - * Used by `_.trim` and `_.trimStart` to get the index of the first string symbol - * that is not found in the character symbols. - * - * @private - * @param {Array} strSymbols The string symbols to inspect. - * @param {Array} chrSymbols The character symbols to find. - * @returns {number} Returns the index of the first unmatched string symbol. - */ - function charsStartIndex(strSymbols, chrSymbols) { - var index = -1, - length = strSymbols.length; - - while (++index < length && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {} - return index; - } - - /** - * Used by `_.trim` and `_.trimEnd` to get the index of the last string symbol - * that is not found in the character symbols. - * - * @private - * @param {Array} strSymbols The string symbols to inspect. - * @param {Array} chrSymbols The character symbols to find. - * @returns {number} Returns the index of the last unmatched string symbol. - */ - function charsEndIndex(strSymbols, chrSymbols) { - var index = strSymbols.length; - - while (index-- && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {} - return index; - } - - /** - * Gets the number of `placeholder` occurrences in `array`. - * - * @private - * @param {Array} array The array to inspect. - * @param {*} placeholder The placeholder to search for. - * @returns {number} Returns the placeholder count. - */ - function countHolders(array, placeholder) { - var length = array.length, - result = 0; - - while (length--) { - if (array[length] === placeholder) { - ++result; - } - } - return result; - } - - /** - * Used by `_.deburr` to convert Latin-1 Supplement and Latin Extended-A - * letters to basic Latin letters. - * - * @private - * @param {string} letter The matched letter to deburr. - * @returns {string} Returns the deburred letter. - */ - var deburrLetter = basePropertyOf(deburredLetters); - - /** - * Used by `_.escape` to convert characters to HTML entities. - * - * @private - * @param {string} chr The matched character to escape. - * @returns {string} Returns the escaped character. - */ - var escapeHtmlChar = basePropertyOf(htmlEscapes); - - /** - * Used by `_.template` to escape characters for inclusion in compiled string literals. - * - * @private - * @param {string} chr The matched character to escape. - * @returns {string} Returns the escaped character. - */ - function escapeStringChar(chr) { - return '\\' + stringEscapes[chr]; - } - - /** - * Gets the value at `key` of `object`. - * - * @private - * @param {Object} [object] The object to query. - * @param {string} key The key of the property to get. - * @returns {*} Returns the property value. - */ - function getValue(object, key) { - return object == null ? undefined : object[key]; - } - - /** - * Checks if `string` contains Unicode symbols. - * - * @private - * @param {string} string The string to inspect. - * @returns {boolean} Returns `true` if a symbol is found, else `false`. - */ - function hasUnicode(string) { - return reHasUnicode.test(string); - } - - /** - * Checks if `string` contains a word composed of Unicode symbols. - * - * @private - * @param {string} string The string to inspect. - * @returns {boolean} Returns `true` if a word is found, else `false`. - */ - function hasUnicodeWord(string) { - return reHasUnicodeWord.test(string); - } - - /** - * Converts `iterator` to an array. - * - * @private - * @param {Object} iterator The iterator to convert. - * @returns {Array} Returns the converted array. - */ - function iteratorToArray(iterator) { - var data, - result = []; - - while (!(data = iterator.next()).done) { - result.push(data.value); - } - return result; - } - - /** - * Converts `map` to its key-value pairs. - * - * @private - * @param {Object} map The map to convert. - * @returns {Array} Returns the key-value pairs. - */ - function mapToArray(map) { - var index = -1, - result = Array(map.size); - - map.forEach(function(value, key) { - result[++index] = [key, value]; - }); - return result; - } - - /** - * Creates a unary function that invokes `func` with its argument transformed. - * - * @private - * @param {Function} func The function to wrap. - * @param {Function} transform The argument transform. - * @returns {Function} Returns the new function. - */ - function overArg(func, transform) { - return function(arg) { - return func(transform(arg)); - }; - } - - /** - * Replaces all `placeholder` elements in `array` with an internal placeholder - * and returns an array of their indexes. - * - * @private - * @param {Array} array The array to modify. - * @param {*} placeholder The placeholder to replace. - * @returns {Array} Returns the new array of placeholder indexes. - */ - function replaceHolders(array, placeholder) { - var index = -1, - length = array.length, - resIndex = 0, - result = []; - - while (++index < length) { - var value = array[index]; - if (value === placeholder || value === PLACEHOLDER) { - array[index] = PLACEHOLDER; - result[resIndex++] = index; - } - } - return result; - } - - /** - * Converts `set` to an array of its values. - * - * @private - * @param {Object} set The set to convert. - * @returns {Array} Returns the values. - */ - function setToArray(set) { - var index = -1, - result = Array(set.size); - - set.forEach(function(value) { - result[++index] = value; - }); - return result; - } - - /** - * Converts `set` to its value-value pairs. - * - * @private - * @param {Object} set The set to convert. - * @returns {Array} Returns the value-value pairs. - */ - function setToPairs(set) { - var index = -1, - result = Array(set.size); - - set.forEach(function(value) { - result[++index] = [value, value]; - }); - return result; - } - - /** - * A specialized version of `_.indexOf` which performs strict equality - * comparisons of values, i.e. `===`. - * - * @private - * @param {Array} array The array to inspect. - * @param {*} value The value to search for. - * @param {number} fromIndex The index to search from. - * @returns {number} Returns the index of the matched value, else `-1`. - */ - function strictIndexOf(array, value, fromIndex) { - var index = fromIndex - 1, - length = array.length; - - while (++index < length) { - if (array[index] === value) { - return index; - } - } - return -1; - } - - /** - * A specialized version of `_.lastIndexOf` which performs strict equality - * comparisons of values, i.e. `===`. - * - * @private - * @param {Array} array The array to inspect. - * @param {*} value The value to search for. - * @param {number} fromIndex The index to search from. - * @returns {number} Returns the index of the matched value, else `-1`. - */ - function strictLastIndexOf(array, value, fromIndex) { - var index = fromIndex + 1; - while (index--) { - if (array[index] === value) { - return index; - } - } - return index; - } - - /** - * Gets the number of symbols in `string`. - * - * @private - * @param {string} string The string to inspect. - * @returns {number} Returns the string size. - */ - function stringSize(string) { - return hasUnicode(string) - ? unicodeSize(string) - : asciiSize(string); - } - - /** - * Converts `string` to an array. - * - * @private - * @param {string} string The string to convert. - * @returns {Array} Returns the converted array. - */ - function stringToArray(string) { - return hasUnicode(string) - ? unicodeToArray(string) - : asciiToArray(string); - } - - /** - * Used by `_.unescape` to convert HTML entities to characters. - * - * @private - * @param {string} chr The matched character to unescape. - * @returns {string} Returns the unescaped character. - */ - var unescapeHtmlChar = basePropertyOf(htmlUnescapes); - - /** - * Gets the size of a Unicode `string`. - * - * @private - * @param {string} string The string inspect. - * @returns {number} Returns the string size. - */ - function unicodeSize(string) { - var result = reUnicode.lastIndex = 0; - while (reUnicode.test(string)) { - ++result; - } - return result; - } - - /** - * Converts a Unicode `string` to an array. - * - * @private - * @param {string} string The string to convert. - * @returns {Array} Returns the converted array. - */ - function unicodeToArray(string) { - return string.match(reUnicode) || []; - } - - /** - * Splits a Unicode `string` into an array of its words. - * - * @private - * @param {string} The string to inspect. - * @returns {Array} Returns the words of `string`. - */ - function unicodeWords(string) { - return string.match(reUnicodeWord) || []; - } - - /*--------------------------------------------------------------------------*/ - - /** - * Create a new pristine `lodash` function using the `context` object. - * - * @static - * @memberOf _ - * @since 1.1.0 - * @category Util - * @param {Object} [context=root] The context object. - * @returns {Function} Returns a new `lodash` function. - * @example - * - * _.mixin({ 'foo': _.constant('foo') }); - * - * var lodash = _.runInContext(); - * lodash.mixin({ 'bar': lodash.constant('bar') }); - * - * _.isFunction(_.foo); - * // => true - * _.isFunction(_.bar); - * // => false - * - * lodash.isFunction(lodash.foo); - * // => false - * lodash.isFunction(lodash.bar); - * // => true - * - * // Create a suped-up `defer` in Node.js. - * var defer = _.runInContext({ 'setTimeout': setImmediate }).defer; - */ - var runInContext = (function runInContext(context) { - context = context == null ? root : _.defaults(root.Object(), context, _.pick(root, contextProps)); - - /** Built-in constructor references. */ - var Array = context.Array, - Date = context.Date, - Error = context.Error, - Function = context.Function, - Math = context.Math, - Object = context.Object, - RegExp = context.RegExp, - String = context.String, - TypeError = context.TypeError; - - /** Used for built-in method references. */ - var arrayProto = Array.prototype, - funcProto = Function.prototype, - objectProto = Object.prototype; - - /** Used to detect overreaching core-js shims. */ - var coreJsData = context['__core-js_shared__']; - - /** Used to resolve the decompiled source of functions. */ - var funcToString = funcProto.toString; - - /** Used to check objects for own properties. */ - var hasOwnProperty = objectProto.hasOwnProperty; - - /** Used to generate unique IDs. */ - var idCounter = 0; - - /** Used to detect methods masquerading as native. */ - var maskSrcKey = (function() { - var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || ''); - return uid ? ('Symbol(src)_1.' + uid) : ''; - }()); - - /** - * Used to resolve the - * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) - * of values. - */ - var nativeObjectToString = objectProto.toString; - - /** Used to infer the `Object` constructor. */ - var objectCtorString = funcToString.call(Object); - - /** Used to restore the original `_` reference in `_.noConflict`. */ - var oldDash = root._; - - /** Used to detect if a method is native. */ - var reIsNative = RegExp('^' + - funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&') - .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$' - ); - - /** Built-in value references. */ - var Buffer = moduleExports ? context.Buffer : undefined, - Symbol = context.Symbol, - Uint8Array = context.Uint8Array, - allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined, - getPrototype = overArg(Object.getPrototypeOf, Object), - objectCreate = Object.create, - propertyIsEnumerable = objectProto.propertyIsEnumerable, - splice = arrayProto.splice, - spreadableSymbol = Symbol ? Symbol.isConcatSpreadable : undefined, - symIterator = Symbol ? Symbol.iterator : undefined, - symToStringTag = Symbol ? Symbol.toStringTag : undefined; - - var defineProperty = (function() { - try { - var func = getNative(Object, 'defineProperty'); - func({}, '', {}); - return func; - } catch (e) {} - }()); - - /** Mocked built-ins. */ - var ctxClearTimeout = context.clearTimeout !== root.clearTimeout && context.clearTimeout, - ctxNow = Date && Date.now !== root.Date.now && Date.now, - ctxSetTimeout = context.setTimeout !== root.setTimeout && context.setTimeout; - - /* Built-in method references for those with the same name as other `lodash` methods. */ - var nativeCeil = Math.ceil, - nativeFloor = Math.floor, - nativeGetSymbols = Object.getOwnPropertySymbols, - nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined, - nativeIsFinite = context.isFinite, - nativeJoin = arrayProto.join, - nativeKeys = overArg(Object.keys, Object), - nativeMax = Math.max, - nativeMin = Math.min, - nativeNow = Date.now, - nativeParseInt = context.parseInt, - nativeRandom = Math.random, - nativeReverse = arrayProto.reverse; - - /* Built-in method references that are verified to be native. */ - var DataView = getNative(context, 'DataView'), - Map = getNative(context, 'Map'), - Promise = getNative(context, 'Promise'), - Set = getNative(context, 'Set'), - WeakMap = getNative(context, 'WeakMap'), - nativeCreate = getNative(Object, 'create'); - - /** Used to store function metadata. */ - var metaMap = WeakMap && new WeakMap; - - /** Used to lookup unminified function names. */ - var realNames = {}; - - /** Used to detect maps, sets, and weakmaps. */ - var dataViewCtorString = toSource(DataView), - mapCtorString = toSource(Map), - promiseCtorString = toSource(Promise), - setCtorString = toSource(Set), - weakMapCtorString = toSource(WeakMap); - - /** Used to convert symbols to primitives and strings. */ - var symbolProto = Symbol ? Symbol.prototype : undefined, - symbolValueOf = symbolProto ? symbolProto.valueOf : undefined, - symbolToString = symbolProto ? symbolProto.toString : undefined; - - /*------------------------------------------------------------------------*/ - - /** - * Creates a `lodash` object which wraps `value` to enable implicit method - * chain sequences. Methods that operate on and return arrays, collections, - * and functions can be chained together. Methods that retrieve a single value - * or may return a primitive value will automatically end the chain sequence - * and return the unwrapped value. Otherwise, the value must be unwrapped - * with `_#value`. - * - * Explicit chain sequences, which must be unwrapped with `_#value`, may be - * enabled using `_.chain`. - * - * The execution of chained methods is lazy, that is, it's deferred until - * `_#value` is implicitly or explicitly called. - * - * Lazy evaluation allows several methods to support shortcut fusion. - * Shortcut fusion is an optimization to merge iteratee calls; this avoids - * the creation of intermediate arrays and can greatly reduce the number of - * iteratee executions. Sections of a chain sequence qualify for shortcut - * fusion if the section is applied to an array and iteratees accept only - * one argument. The heuristic for whether a section qualifies for shortcut - * fusion is subject to change. - * - * Chaining is supported in custom builds as long as the `_#value` method is - * directly or indirectly included in the build. - * - * In addition to lodash methods, wrappers have `Array` and `String` methods. - * - * The wrapper `Array` methods are: - * `concat`, `join`, `pop`, `push`, `shift`, `sort`, `splice`, and `unshift` - * - * The wrapper `String` methods are: - * `replace` and `split` - * - * The wrapper methods that support shortcut fusion are: - * `at`, `compact`, `drop`, `dropRight`, `dropWhile`, `filter`, `find`, - * `findLast`, `head`, `initial`, `last`, `map`, `reject`, `reverse`, `slice`, - * `tail`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, and `toArray` - * - * The chainable wrapper methods are: - * `after`, `ary`, `assign`, `assignIn`, `assignInWith`, `assignWith`, `at`, - * `before`, `bind`, `bindAll`, `bindKey`, `castArray`, `chain`, `chunk`, - * `commit`, `compact`, `concat`, `conforms`, `constant`, `countBy`, `create`, - * `curry`, `debounce`, `defaults`, `defaultsDeep`, `defer`, `delay`, - * `difference`, `differenceBy`, `differenceWith`, `drop`, `dropRight`, - * `dropRightWhile`, `dropWhile`, `extend`, `extendWith`, `fill`, `filter`, - * `flatMap`, `flatMapDeep`, `flatMapDepth`, `flatten`, `flattenDeep`, - * `flattenDepth`, `flip`, `flow`, `flowRight`, `fromPairs`, `functions`, - * `functionsIn`, `groupBy`, `initial`, `intersection`, `intersectionBy`, - * `intersectionWith`, `invert`, `invertBy`, `invokeMap`, `iteratee`, `keyBy`, - * `keys`, `keysIn`, `map`, `mapKeys`, `mapValues`, `matches`, `matchesProperty`, - * `memoize`, `merge`, `mergeWith`, `method`, `methodOf`, `mixin`, `negate`, - * `nthArg`, `omit`, `omitBy`, `once`, `orderBy`, `over`, `overArgs`, - * `overEvery`, `overSome`, `partial`, `partialRight`, `partition`, `pick`, - * `pickBy`, `plant`, `property`, `propertyOf`, `pull`, `pullAll`, `pullAllBy`, - * `pullAllWith`, `pullAt`, `push`, `range`, `rangeRight`, `rearg`, `reject`, - * `remove`, `rest`, `reverse`, `sampleSize`, `set`, `setWith`, `shuffle`, - * `slice`, `sort`, `sortBy`, `splice`, `spread`, `tail`, `take`, `takeRight`, - * `takeRightWhile`, `takeWhile`, `tap`, `throttle`, `thru`, `toArray`, - * `toPairs`, `toPairsIn`, `toPath`, `toPlainObject`, `transform`, `unary`, - * `union`, `unionBy`, `unionWith`, `uniq`, `uniqBy`, `uniqWith`, `unset`, - * `unshift`, `unzip`, `unzipWith`, `update`, `updateWith`, `values`, - * `valuesIn`, `without`, `wrap`, `xor`, `xorBy`, `xorWith`, `zip`, - * `zipObject`, `zipObjectDeep`, and `zipWith` - * - * The wrapper methods that are **not** chainable by default are: - * `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clamp`, `clone`, - * `cloneDeep`, `cloneDeepWith`, `cloneWith`, `conformsTo`, `deburr`, - * `defaultTo`, `divide`, `each`, `eachRight`, `endsWith`, `eq`, `escape`, - * `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`, `findLast`, - * `findLastIndex`, `findLastKey`, `first`, `floor`, `forEach`, `forEachRight`, - * `forIn`, `forInRight`, `forOwn`, `forOwnRight`, `get`, `gt`, `gte`, `has`, - * `hasIn`, `head`, `identity`, `includes`, `indexOf`, `inRange`, `invoke`, - * `isArguments`, `isArray`, `isArrayBuffer`, `isArrayLike`, `isArrayLikeObject`, - * `isBoolean`, `isBuffer`, `isDate`, `isElement`, `isEmpty`, `isEqual`, - * `isEqualWith`, `isError`, `isFinite`, `isFunction`, `isInteger`, `isLength`, - * `isMap`, `isMatch`, `isMatchWith`, `isNaN`, `isNative`, `isNil`, `isNull`, - * `isNumber`, `isObject`, `isObjectLike`, `isPlainObject`, `isRegExp`, - * `isSafeInteger`, `isSet`, `isString`, `isUndefined`, `isTypedArray`, - * `isWeakMap`, `isWeakSet`, `join`, `kebabCase`, `last`, `lastIndexOf`, - * `lowerCase`, `lowerFirst`, `lt`, `lte`, `max`, `maxBy`, `mean`, `meanBy`, - * `min`, `minBy`, `multiply`, `noConflict`, `noop`, `now`, `nth`, `pad`, - * `padEnd`, `padStart`, `parseInt`, `pop`, `random`, `reduce`, `reduceRight`, - * `repeat`, `result`, `round`, `runInContext`, `sample`, `shift`, `size`, - * `snakeCase`, `some`, `sortedIndex`, `sortedIndexBy`, `sortedLastIndex`, - * `sortedLastIndexBy`, `startCase`, `startsWith`, `stubArray`, `stubFalse`, - * `stubObject`, `stubString`, `stubTrue`, `subtract`, `sum`, `sumBy`, - * `template`, `times`, `toFinite`, `toInteger`, `toJSON`, `toLength`, - * `toLower`, `toNumber`, `toSafeInteger`, `toString`, `toUpper`, `trim`, - * `trimEnd`, `trimStart`, `truncate`, `unescape`, `uniqueId`, `upperCase`, - * `upperFirst`, `value`, and `words` - * - * @name _ - * @constructor - * @category Seq - * @param {*} value The value to wrap in a `lodash` instance. - * @returns {Object} Returns the new `lodash` wrapper instance. - * @example - * - * function square(n) { - * return n * n; - * } - * - * var wrapped = _([1, 2, 3]); - * - * // Returns an unwrapped value. - * wrapped.reduce(_.add); - * // => 6 - * - * // Returns a wrapped value. - * var squares = wrapped.map(square); - * - * _.isArray(squares); - * // => false - * - * _.isArray(squares.value()); - * // => true - */ - function lodash(value) { - if (isObjectLike(value) && !isArray(value) && !(value instanceof LazyWrapper)) { - if (value instanceof LodashWrapper) { - return value; - } - if (hasOwnProperty.call(value, '__wrapped__')) { - return wrapperClone(value); - } - } - return new LodashWrapper(value); - } - - /** - * The base implementation of `_.create` without support for assigning - * properties to the created object. - * - * @private - * @param {Object} proto The object to inherit from. - * @returns {Object} Returns the new object. - */ - var baseCreate = (function() { - function object() {} - return function(proto) { - if (!isObject(proto)) { - return {}; - } - if (objectCreate) { - return objectCreate(proto); - } - object.prototype = proto; - var result = new object; - object.prototype = undefined; - return result; - }; - }()); - - /** - * The function whose prototype chain sequence wrappers inherit from. - * - * @private - */ - function baseLodash() { - // No operation performed. - } - - /** - * The base constructor for creating `lodash` wrapper objects. - * - * @private - * @param {*} value The value to wrap. - * @param {boolean} [chainAll] Enable explicit method chain sequences. - */ - function LodashWrapper(value, chainAll) { - this.__wrapped__ = value; - this.__actions__ = []; - this.__chain__ = !!chainAll; - this.__index__ = 0; - this.__values__ = undefined; - } - - /** - * By default, the template delimiters used by lodash are like those in - * embedded Ruby (ERB) as well as ES2015 template strings. Change the - * following template settings to use alternative delimiters. - * - * @static - * @memberOf _ - * @type {Object} - */ - lodash.templateSettings = { - - /** - * Used to detect `data` property values to be HTML-escaped. - * - * @memberOf _.templateSettings - * @type {RegExp} - */ - 'escape': reEscape, - - /** - * Used to detect code to be evaluated. - * - * @memberOf _.templateSettings - * @type {RegExp} - */ - 'evaluate': reEvaluate, - - /** - * Used to detect `data` property values to inject. - * - * @memberOf _.templateSettings - * @type {RegExp} - */ - 'interpolate': reInterpolate, - - /** - * Used to reference the data object in the template text. - * - * @memberOf _.templateSettings - * @type {string} - */ - 'variable': '', - - /** - * Used to import variables into the compiled template. - * - * @memberOf _.templateSettings - * @type {Object} - */ - 'imports': { - - /** - * A reference to the `lodash` function. - * - * @memberOf _.templateSettings.imports - * @type {Function} - */ - '_': lodash - } - }; - - // Ensure wrappers are instances of `baseLodash`. - lodash.prototype = baseLodash.prototype; - lodash.prototype.constructor = lodash; - - LodashWrapper.prototype = baseCreate(baseLodash.prototype); - LodashWrapper.prototype.constructor = LodashWrapper; - - /*------------------------------------------------------------------------*/ - - /** - * Creates a lazy wrapper object which wraps `value` to enable lazy evaluation. - * - * @private - * @constructor - * @param {*} value The value to wrap. - */ - function LazyWrapper(value) { - this.__wrapped__ = value; - this.__actions__ = []; - this.__dir__ = 1; - this.__filtered__ = false; - this.__iteratees__ = []; - this.__takeCount__ = MAX_ARRAY_LENGTH; - this.__views__ = []; - } - - /** - * Creates a clone of the lazy wrapper object. - * - * @private - * @name clone - * @memberOf LazyWrapper - * @returns {Object} Returns the cloned `LazyWrapper` object. - */ - function lazyClone() { - var result = new LazyWrapper(this.__wrapped__); - result.__actions__ = copyArray(this.__actions__); - result.__dir__ = this.__dir__; - result.__filtered__ = this.__filtered__; - result.__iteratees__ = copyArray(this.__iteratees__); - result.__takeCount__ = this.__takeCount__; - result.__views__ = copyArray(this.__views__); - return result; - } - - /** - * Reverses the direction of lazy iteration. - * - * @private - * @name reverse - * @memberOf LazyWrapper - * @returns {Object} Returns the new reversed `LazyWrapper` object. - */ - function lazyReverse() { - if (this.__filtered__) { - var result = new LazyWrapper(this); - result.__dir__ = -1; - result.__filtered__ = true; - } else { - result = this.clone(); - result.__dir__ *= -1; - } - return result; - } - - /** - * Extracts the unwrapped value from its lazy wrapper. - * - * @private - * @name value - * @memberOf LazyWrapper - * @returns {*} Returns the unwrapped value. - */ - function lazyValue() { - var array = this.__wrapped__.value(), - dir = this.__dir__, - isArr = isArray(array), - isRight = dir < 0, - arrLength = isArr ? array.length : 0, - view = getView(0, arrLength, this.__views__), - start = view.start, - end = view.end, - length = end - start, - index = isRight ? end : (start - 1), - iteratees = this.__iteratees__, - iterLength = iteratees.length, - resIndex = 0, - takeCount = nativeMin(length, this.__takeCount__); - - if (!isArr || (!isRight && arrLength == length && takeCount == length)) { - return baseWrapperValue(array, this.__actions__); - } - var result = []; - - outer: - while (length-- && resIndex < takeCount) { - index += dir; - - var iterIndex = -1, - value = array[index]; - - while (++iterIndex < iterLength) { - var data = iteratees[iterIndex], - iteratee = data.iteratee, - type = data.type, - computed = iteratee(value); - - if (type == LAZY_MAP_FLAG) { - value = computed; - } else if (!computed) { - if (type == LAZY_FILTER_FLAG) { - continue outer; - } else { - break outer; - } - } - } - result[resIndex++] = value; - } - return result; - } - - // Ensure `LazyWrapper` is an instance of `baseLodash`. - LazyWrapper.prototype = baseCreate(baseLodash.prototype); - LazyWrapper.prototype.constructor = LazyWrapper; - - /*------------------------------------------------------------------------*/ - - /** - * Creates a hash object. - * - * @private - * @constructor - * @param {Array} [entries] The key-value pairs to cache. - */ - function Hash(entries) { - var index = -1, - length = entries == null ? 0 : entries.length; - - this.clear(); - while (++index < length) { - var entry = entries[index]; - this.set(entry[0], entry[1]); - } - } - - /** - * Removes all key-value entries from the hash. - * - * @private - * @name clear - * @memberOf Hash - */ - function hashClear() { - this.__data__ = nativeCreate ? nativeCreate(null) : {}; - this.size = 0; - } - - /** - * Removes `key` and its value from the hash. - * - * @private - * @name delete - * @memberOf Hash - * @param {Object} hash The hash to modify. - * @param {string} key The key of the value to remove. - * @returns {boolean} Returns `true` if the entry was removed, else `false`. - */ - function hashDelete(key) { - var result = this.has(key) && delete this.__data__[key]; - this.size -= result ? 1 : 0; - return result; - } - - /** - * Gets the hash value for `key`. - * - * @private - * @name get - * @memberOf Hash - * @param {string} key The key of the value to get. - * @returns {*} Returns the entry value. - */ - function hashGet(key) { - var data = this.__data__; - if (nativeCreate) { - var result = data[key]; - return result === HASH_UNDEFINED ? undefined : result; - } - return hasOwnProperty.call(data, key) ? data[key] : undefined; - } - - /** - * Checks if a hash value for `key` exists. - * - * @private - * @name has - * @memberOf Hash - * @param {string} key The key of the entry to check. - * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. - */ - function hashHas(key) { - var data = this.__data__; - return nativeCreate ? (data[key] !== undefined) : hasOwnProperty.call(data, key); - } - - /** - * Sets the hash `key` to `value`. - * - * @private - * @name set - * @memberOf Hash - * @param {string} key The key of the value to set. - * @param {*} value The value to set. - * @returns {Object} Returns the hash instance. - */ - function hashSet(key, value) { - var data = this.__data__; - this.size += this.has(key) ? 0 : 1; - data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value; - return this; - } - - // Add methods to `Hash`. - Hash.prototype.clear = hashClear; - Hash.prototype['delete'] = hashDelete; - Hash.prototype.get = hashGet; - Hash.prototype.has = hashHas; - Hash.prototype.set = hashSet; - - /*------------------------------------------------------------------------*/ - - /** - * Creates an list cache object. - * - * @private - * @constructor - * @param {Array} [entries] The key-value pairs to cache. - */ - function ListCache(entries) { - var index = -1, - length = entries == null ? 0 : entries.length; - - this.clear(); - while (++index < length) { - var entry = entries[index]; - this.set(entry[0], entry[1]); - } - } - - /** - * Removes all key-value entries from the list cache. - * - * @private - * @name clear - * @memberOf ListCache - */ - function listCacheClear() { - this.__data__ = []; - this.size = 0; - } - - /** - * Removes `key` and its value from the list cache. - * - * @private - * @name delete - * @memberOf ListCache - * @param {string} key The key of the value to remove. - * @returns {boolean} Returns `true` if the entry was removed, else `false`. - */ - function listCacheDelete(key) { - var data = this.__data__, - index = assocIndexOf(data, key); - - if (index < 0) { - return false; - } - var lastIndex = data.length - 1; - if (index == lastIndex) { - data.pop(); - } else { - splice.call(data, index, 1); - } - --this.size; - return true; - } - - /** - * Gets the list cache value for `key`. - * - * @private - * @name get - * @memberOf ListCache - * @param {string} key The key of the value to get. - * @returns {*} Returns the entry value. - */ - function listCacheGet(key) { - var data = this.__data__, - index = assocIndexOf(data, key); - - return index < 0 ? undefined : data[index][1]; - } - - /** - * Checks if a list cache value for `key` exists. - * - * @private - * @name has - * @memberOf ListCache - * @param {string} key The key of the entry to check. - * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. - */ - function listCacheHas(key) { - return assocIndexOf(this.__data__, key) > -1; - } - - /** - * Sets the list cache `key` to `value`. - * - * @private - * @name set - * @memberOf ListCache - * @param {string} key The key of the value to set. - * @param {*} value The value to set. - * @returns {Object} Returns the list cache instance. - */ - function listCacheSet(key, value) { - var data = this.__data__, - index = assocIndexOf(data, key); - - if (index < 0) { - ++this.size; - data.push([key, value]); - } else { - data[index][1] = value; - } - return this; - } - - // Add methods to `ListCache`. - ListCache.prototype.clear = listCacheClear; - ListCache.prototype['delete'] = listCacheDelete; - ListCache.prototype.get = listCacheGet; - ListCache.prototype.has = listCacheHas; - ListCache.prototype.set = listCacheSet; - - /*------------------------------------------------------------------------*/ - - /** - * Creates a map cache object to store key-value pairs. - * - * @private - * @constructor - * @param {Array} [entries] The key-value pairs to cache. - */ - function MapCache(entries) { - var index = -1, - length = entries == null ? 0 : entries.length; - - this.clear(); - while (++index < length) { - var entry = entries[index]; - this.set(entry[0], entry[1]); - } - } - - /** - * Removes all key-value entries from the map. - * - * @private - * @name clear - * @memberOf MapCache - */ - function mapCacheClear() { - this.size = 0; - this.__data__ = { - 'hash': new Hash, - 'map': new (Map || ListCache), - 'string': new Hash - }; - } - - /** - * Removes `key` and its value from the map. - * - * @private - * @name delete - * @memberOf MapCache - * @param {string} key The key of the value to remove. - * @returns {boolean} Returns `true` if the entry was removed, else `false`. - */ - function mapCacheDelete(key) { - var result = getMapData(this, key)['delete'](key); - this.size -= result ? 1 : 0; - return result; - } - - /** - * Gets the map value for `key`. - * - * @private - * @name get - * @memberOf MapCache - * @param {string} key The key of the value to get. - * @returns {*} Returns the entry value. - */ - function mapCacheGet(key) { - return getMapData(this, key).get(key); - } - - /** - * Checks if a map value for `key` exists. - * - * @private - * @name has - * @memberOf MapCache - * @param {string} key The key of the entry to check. - * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. - */ - function mapCacheHas(key) { - return getMapData(this, key).has(key); - } - - /** - * Sets the map `key` to `value`. - * - * @private - * @name set - * @memberOf MapCache - * @param {string} key The key of the value to set. - * @param {*} value The value to set. - * @returns {Object} Returns the map cache instance. - */ - function mapCacheSet(key, value) { - var data = getMapData(this, key), - size = data.size; - - data.set(key, value); - this.size += data.size == size ? 0 : 1; - return this; - } - - // Add methods to `MapCache`. - MapCache.prototype.clear = mapCacheClear; - MapCache.prototype['delete'] = mapCacheDelete; - MapCache.prototype.get = mapCacheGet; - MapCache.prototype.has = mapCacheHas; - MapCache.prototype.set = mapCacheSet; - - /*------------------------------------------------------------------------*/ - - /** - * - * Creates an array cache object to store unique values. - * - * @private - * @constructor - * @param {Array} [values] The values to cache. - */ - function SetCache(values) { - var index = -1, - length = values == null ? 0 : values.length; - - this.__data__ = new MapCache; - while (++index < length) { - this.add(values[index]); - } - } - - /** - * Adds `value` to the array cache. - * - * @private - * @name add - * @memberOf SetCache - * @alias push - * @param {*} value The value to cache. - * @returns {Object} Returns the cache instance. - */ - function setCacheAdd(value) { - this.__data__.set(value, HASH_UNDEFINED); - return this; - } - - /** - * Checks if `value` is in the array cache. - * - * @private - * @name has - * @memberOf SetCache - * @param {*} value The value to search for. - * @returns {number} Returns `true` if `value` is found, else `false`. - */ - function setCacheHas(value) { - return this.__data__.has(value); - } - - // Add methods to `SetCache`. - SetCache.prototype.add = SetCache.prototype.push = setCacheAdd; - SetCache.prototype.has = setCacheHas; - - /*------------------------------------------------------------------------*/ - - /** - * Creates a stack cache object to store key-value pairs. - * - * @private - * @constructor - * @param {Array} [entries] The key-value pairs to cache. - */ - function Stack(entries) { - var data = this.__data__ = new ListCache(entries); - this.size = data.size; - } - - /** - * Removes all key-value entries from the stack. - * - * @private - * @name clear - * @memberOf Stack - */ - function stackClear() { - this.__data__ = new ListCache; - this.size = 0; - } - - /** - * Removes `key` and its value from the stack. - * - * @private - * @name delete - * @memberOf Stack - * @param {string} key The key of the value to remove. - * @returns {boolean} Returns `true` if the entry was removed, else `false`. - */ - function stackDelete(key) { - var data = this.__data__, - result = data['delete'](key); - - this.size = data.size; - return result; - } - - /** - * Gets the stack value for `key`. - * - * @private - * @name get - * @memberOf Stack - * @param {string} key The key of the value to get. - * @returns {*} Returns the entry value. - */ - function stackGet(key) { - return this.__data__.get(key); - } - - /** - * Checks if a stack value for `key` exists. - * - * @private - * @name has - * @memberOf Stack - * @param {string} key The key of the entry to check. - * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. - */ - function stackHas(key) { - return this.__data__.has(key); - } - - /** - * Sets the stack `key` to `value`. - * - * @private - * @name set - * @memberOf Stack - * @param {string} key The key of the value to set. - * @param {*} value The value to set. - * @returns {Object} Returns the stack cache instance. - */ - function stackSet(key, value) { - var data = this.__data__; - if (data instanceof ListCache) { - var pairs = data.__data__; - if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) { - pairs.push([key, value]); - this.size = ++data.size; - return this; - } - data = this.__data__ = new MapCache(pairs); - } - data.set(key, value); - this.size = data.size; - return this; - } - - // Add methods to `Stack`. - Stack.prototype.clear = stackClear; - Stack.prototype['delete'] = stackDelete; - Stack.prototype.get = stackGet; - Stack.prototype.has = stackHas; - Stack.prototype.set = stackSet; - - /*------------------------------------------------------------------------*/ - - /** - * Creates an array of the enumerable property names of the array-like `value`. - * - * @private - * @param {*} value The value to query. - * @param {boolean} inherited Specify returning inherited property names. - * @returns {Array} Returns the array of property names. - */ - function arrayLikeKeys(value, inherited) { - var isArr = isArray(value), - isArg = !isArr && isArguments(value), - isBuff = !isArr && !isArg && isBuffer(value), - isType = !isArr && !isArg && !isBuff && isTypedArray(value), - skipIndexes = isArr || isArg || isBuff || isType, - result = skipIndexes ? baseTimes(value.length, String) : [], - length = result.length; - - for (var key in value) { - if ((inherited || hasOwnProperty.call(value, key)) && - !(skipIndexes && ( - // Safari 9 has enumerable `arguments.length` in strict mode. - key == 'length' || - // Node.js 0.10 has enumerable non-index properties on buffers. - (isBuff && (key == 'offset' || key == 'parent')) || - // PhantomJS 2 has enumerable non-index properties on typed arrays. - (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) || - // Skip index properties. - isIndex(key, length) - ))) { - result.push(key); - } - } - return result; - } - - /** - * A specialized version of `_.sample` for arrays. - * - * @private - * @param {Array} array The array to sample. - * @returns {*} Returns the random element. - */ - function arraySample(array) { - var length = array.length; - return length ? array[baseRandom(0, length - 1)] : undefined; - } - - /** - * A specialized version of `_.sampleSize` for arrays. - * - * @private - * @param {Array} array The array to sample. - * @param {number} n The number of elements to sample. - * @returns {Array} Returns the random elements. - */ - function arraySampleSize(array, n) { - return shuffleSelf(copyArray(array), baseClamp(n, 0, array.length)); - } - - /** - * A specialized version of `_.shuffle` for arrays. - * - * @private - * @param {Array} array The array to shuffle. - * @returns {Array} Returns the new shuffled array. - */ - function arrayShuffle(array) { - return shuffleSelf(copyArray(array)); - } - - /** - * This function is like `assignValue` except that it doesn't assign - * `undefined` values. - * - * @private - * @param {Object} object The object to modify. - * @param {string} key The key of the property to assign. - * @param {*} value The value to assign. - */ - function assignMergeValue(object, key, value) { - if ((value !== undefined && !eq(object[key], value)) || - (value === undefined && !(key in object))) { - baseAssignValue(object, key, value); - } - } - - /** - * Assigns `value` to `key` of `object` if the existing value is not equivalent - * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) - * for equality comparisons. - * - * @private - * @param {Object} object The object to modify. - * @param {string} key The key of the property to assign. - * @param {*} value The value to assign. - */ - function assignValue(object, key, value) { - var objValue = object[key]; - if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) || - (value === undefined && !(key in object))) { - baseAssignValue(object, key, value); - } - } - - /** - * Gets the index at which the `key` is found in `array` of key-value pairs. - * - * @private - * @param {Array} array The array to inspect. - * @param {*} key The key to search for. - * @returns {number} Returns the index of the matched value, else `-1`. - */ - function assocIndexOf(array, key) { - var length = array.length; - while (length--) { - if (eq(array[length][0], key)) { - return length; - } - } - return -1; - } - - /** - * Aggregates elements of `collection` on `accumulator` with keys transformed - * by `iteratee` and values set by `setter`. - * - * @private - * @param {Array|Object} collection The collection to iterate over. - * @param {Function} setter The function to set `accumulator` values. - * @param {Function} iteratee The iteratee to transform keys. - * @param {Object} accumulator The initial aggregated object. - * @returns {Function} Returns `accumulator`. - */ - function baseAggregator(collection, setter, iteratee, accumulator) { - baseEach(collection, function(value, key, collection) { - setter(accumulator, value, iteratee(value), collection); - }); - return accumulator; - } - - /** - * The base implementation of `_.assign` without support for multiple sources - * or `customizer` functions. - * - * @private - * @param {Object} object The destination object. - * @param {Object} source The source object. - * @returns {Object} Returns `object`. - */ - function baseAssign(object, source) { - return object && copyObject(source, keys(source), object); - } - - /** - * The base implementation of `_.assignIn` without support for multiple sources - * or `customizer` functions. - * - * @private - * @param {Object} object The destination object. - * @param {Object} source The source object. - * @returns {Object} Returns `object`. - */ - function baseAssignIn(object, source) { - return object && copyObject(source, keysIn(source), object); - } - - /** - * The base implementation of `assignValue` and `assignMergeValue` without - * value checks. - * - * @private - * @param {Object} object The object to modify. - * @param {string} key The key of the property to assign. - * @param {*} value The value to assign. - */ - function baseAssignValue(object, key, value) { - if (key == '__proto__' && defineProperty) { - defineProperty(object, key, { - 'configurable': true, - 'enumerable': true, - 'value': value, - 'writable': true - }); - } else { - object[key] = value; - } - } - - /** - * The base implementation of `_.at` without support for individual paths. - * - * @private - * @param {Object} object The object to iterate over. - * @param {string[]} paths The property paths to pick. - * @returns {Array} Returns the picked elements. - */ - function baseAt(object, paths) { - var index = -1, - length = paths.length, - result = Array(length), - skip = object == null; - - while (++index < length) { - result[index] = skip ? undefined : get(object, paths[index]); - } - return result; - } - - /** - * The base implementation of `_.clamp` which doesn't coerce arguments. - * - * @private - * @param {number} number The number to clamp. - * @param {number} [lower] The lower bound. - * @param {number} upper The upper bound. - * @returns {number} Returns the clamped number. - */ - function baseClamp(number, lower, upper) { - if (number === number) { - if (upper !== undefined) { - number = number <= upper ? number : upper; - } - if (lower !== undefined) { - number = number >= lower ? number : lower; - } - } - return number; - } - - /** - * The base implementation of `_.clone` and `_.cloneDeep` which tracks - * traversed objects. - * - * @private - * @param {*} value The value to clone. - * @param {boolean} bitmask The bitmask flags. - * 1 - Deep clone - * 2 - Flatten inherited properties - * 4 - Clone symbols - * @param {Function} [customizer] The function to customize cloning. - * @param {string} [key] The key of `value`. - * @param {Object} [object] The parent object of `value`. - * @param {Object} [stack] Tracks traversed objects and their clone counterparts. - * @returns {*} Returns the cloned value. - */ - function baseClone(value, bitmask, customizer, key, object, stack) { - var result, - isDeep = bitmask & CLONE_DEEP_FLAG, - isFlat = bitmask & CLONE_FLAT_FLAG, - isFull = bitmask & CLONE_SYMBOLS_FLAG; - - if (customizer) { - result = object ? customizer(value, key, object, stack) : customizer(value); - } - if (result !== undefined) { - return result; - } - if (!isObject(value)) { - return value; - } - var isArr = isArray(value); - if (isArr) { - result = initCloneArray(value); - if (!isDeep) { - return copyArray(value, result); - } - } else { - var tag = getTag(value), - isFunc = tag == funcTag || tag == genTag; - - if (isBuffer(value)) { - return cloneBuffer(value, isDeep); - } - if (tag == objectTag || tag == argsTag || (isFunc && !object)) { - result = (isFlat || isFunc) ? {} : initCloneObject(value); - if (!isDeep) { - return isFlat - ? copySymbolsIn(value, baseAssignIn(result, value)) - : copySymbols(value, baseAssign(result, value)); - } - } else { - if (!cloneableTags[tag]) { - return object ? value : {}; - } - result = initCloneByTag(value, tag, baseClone, isDeep); - } - } - // Check for circular references and return its corresponding clone. - stack || (stack = new Stack); - var stacked = stack.get(value); - if (stacked) { - return stacked; - } - stack.set(value, result); - - var keysFunc = isFull - ? (isFlat ? getAllKeysIn : getAllKeys) - : (isFlat ? keysIn : keys); - - var props = isArr ? undefined : keysFunc(value); - arrayEach(props || value, function(subValue, key) { - if (props) { - key = subValue; - subValue = value[key]; - } - // Recursively populate clone (susceptible to call stack limits). - assignValue(result, key, baseClone(subValue, bitmask, customizer, key, value, stack)); - }); - return result; - } - - /** - * The base implementation of `_.conforms` which doesn't clone `source`. - * - * @private - * @param {Object} source The object of property predicates to conform to. - * @returns {Function} Returns the new spec function. - */ - function baseConforms(source) { - var props = keys(source); - return function(object) { - return baseConformsTo(object, source, props); - }; - } - - /** - * The base implementation of `_.conformsTo` which accepts `props` to check. - * - * @private - * @param {Object} object The object to inspect. - * @param {Object} source The object of property predicates to conform to. - * @returns {boolean} Returns `true` if `object` conforms, else `false`. - */ - function baseConformsTo(object, source, props) { - var length = props.length; - if (object == null) { - return !length; - } - object = Object(object); - while (length--) { - var key = props[length], - predicate = source[key], - value = object[key]; - - if ((value === undefined && !(key in object)) || !predicate(value)) { - return false; - } - } - return true; - } - - /** - * The base implementation of `_.delay` and `_.defer` which accepts `args` - * to provide to `func`. - * - * @private - * @param {Function} func The function to delay. - * @param {number} wait The number of milliseconds to delay invocation. - * @param {Array} args The arguments to provide to `func`. - * @returns {number|Object} Returns the timer id or timeout object. - */ - function baseDelay(func, wait, args) { - if (typeof func != 'function') { - throw new TypeError(FUNC_ERROR_TEXT); - } - return setTimeout(function() { func.apply(undefined, args); }, wait); - } - - /** - * The base implementation of methods like `_.difference` without support - * for excluding multiple arrays or iteratee shorthands. - * - * @private - * @param {Array} array The array to inspect. - * @param {Array} values The values to exclude. - * @param {Function} [iteratee] The iteratee invoked per element. - * @param {Function} [comparator] The comparator invoked per element. - * @returns {Array} Returns the new array of filtered values. - */ - function baseDifference(array, values, iteratee, comparator) { - var index = -1, - includes = arrayIncludes, - isCommon = true, - length = array.length, - result = [], - valuesLength = values.length; - - if (!length) { - return result; - } - if (iteratee) { - values = arrayMap(values, baseUnary(iteratee)); - } - if (comparator) { - includes = arrayIncludesWith; - isCommon = false; - } - else if (values.length >= LARGE_ARRAY_SIZE) { - includes = cacheHas; - isCommon = false; - values = new SetCache(values); - } - outer: - while (++index < length) { - var value = array[index], - computed = iteratee == null ? value : iteratee(value); - - value = (comparator || value !== 0) ? value : 0; - if (isCommon && computed === computed) { - var valuesIndex = valuesLength; - while (valuesIndex--) { - if (values[valuesIndex] === computed) { - continue outer; - } - } - result.push(value); - } - else if (!includes(values, computed, comparator)) { - result.push(value); - } - } - return result; - } - - /** - * The base implementation of `_.forEach` without support for iteratee shorthands. - * - * @private - * @param {Array|Object} collection The collection to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @returns {Array|Object} Returns `collection`. - */ - var baseEach = createBaseEach(baseForOwn); - - /** - * The base implementation of `_.forEachRight` without support for iteratee shorthands. - * - * @private - * @param {Array|Object} collection The collection to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @returns {Array|Object} Returns `collection`. - */ - var baseEachRight = createBaseEach(baseForOwnRight, true); - - /** - * The base implementation of `_.every` without support for iteratee shorthands. - * - * @private - * @param {Array|Object} collection The collection to iterate over. - * @param {Function} predicate The function invoked per iteration. - * @returns {boolean} Returns `true` if all elements pass the predicate check, - * else `false` - */ - function baseEvery(collection, predicate) { - var result = true; - baseEach(collection, function(value, index, collection) { - result = !!predicate(value, index, collection); - return result; - }); - return result; - } - - /** - * The base implementation of methods like `_.max` and `_.min` which accepts a - * `comparator` to determine the extremum value. - * - * @private - * @param {Array} array The array to iterate over. - * @param {Function} iteratee The iteratee invoked per iteration. - * @param {Function} comparator The comparator used to compare values. - * @returns {*} Returns the extremum value. - */ - function baseExtremum(array, iteratee, comparator) { - var index = -1, - length = array.length; - - while (++index < length) { - var value = array[index], - current = iteratee(value); - - if (current != null && (computed === undefined - ? (current === current && !isSymbol(current)) - : comparator(current, computed) - )) { - var computed = current, - result = value; - } - } - return result; - } - - /** - * The base implementation of `_.fill` without an iteratee call guard. - * - * @private - * @param {Array} array The array to fill. - * @param {*} value The value to fill `array` with. - * @param {number} [start=0] The start position. - * @param {number} [end=array.length] The end position. - * @returns {Array} Returns `array`. - */ - function baseFill(array, value, start, end) { - var length = array.length; - - start = toInteger(start); - if (start < 0) { - start = -start > length ? 0 : (length + start); - } - end = (end === undefined || end > length) ? length : toInteger(end); - if (end < 0) { - end += length; - } - end = start > end ? 0 : toLength(end); - while (start < end) { - array[start++] = value; - } - return array; - } - - /** - * The base implementation of `_.filter` without support for iteratee shorthands. - * - * @private - * @param {Array|Object} collection The collection to iterate over. - * @param {Function} predicate The function invoked per iteration. - * @returns {Array} Returns the new filtered array. - */ - function baseFilter(collection, predicate) { - var result = []; - baseEach(collection, function(value, index, collection) { - if (predicate(value, index, collection)) { - result.push(value); - } - }); - return result; - } - - /** - * The base implementation of `_.flatten` with support for restricting flattening. - * - * @private - * @param {Array} array The array to flatten. - * @param {number} depth The maximum recursion depth. - * @param {boolean} [predicate=isFlattenable] The function invoked per iteration. - * @param {boolean} [isStrict] Restrict to values that pass `predicate` checks. - * @param {Array} [result=[]] The initial result value. - * @returns {Array} Returns the new flattened array. - */ - function baseFlatten(array, depth, predicate, isStrict, result) { - var index = -1, - length = array.length; - - predicate || (predicate = isFlattenable); - result || (result = []); - - while (++index < length) { - var value = array[index]; - if (depth > 0 && predicate(value)) { - if (depth > 1) { - // Recursively flatten arrays (susceptible to call stack limits). - baseFlatten(value, depth - 1, predicate, isStrict, result); - } else { - arrayPush(result, value); - } - } else if (!isStrict) { - result[result.length] = value; - } - } - return result; - } - - /** - * The base implementation of `baseForOwn` which iterates over `object` - * properties returned by `keysFunc` and invokes `iteratee` for each property. - * Iteratee functions may exit iteration early by explicitly returning `false`. - * - * @private - * @param {Object} object The object to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @param {Function} keysFunc The function to get the keys of `object`. - * @returns {Object} Returns `object`. - */ - var baseFor = createBaseFor(); - - /** - * This function is like `baseFor` except that it iterates over properties - * in the opposite order. - * - * @private - * @param {Object} object The object to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @param {Function} keysFunc The function to get the keys of `object`. - * @returns {Object} Returns `object`. - */ - var baseForRight = createBaseFor(true); - - /** - * The base implementation of `_.forOwn` without support for iteratee shorthands. - * - * @private - * @param {Object} object The object to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @returns {Object} Returns `object`. - */ - function baseForOwn(object, iteratee) { - return object && baseFor(object, iteratee, keys); - } - - /** - * The base implementation of `_.forOwnRight` without support for iteratee shorthands. - * - * @private - * @param {Object} object The object to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @returns {Object} Returns `object`. - */ - function baseForOwnRight(object, iteratee) { - return object && baseForRight(object, iteratee, keys); - } - - /** - * The base implementation of `_.functions` which creates an array of - * `object` function property names filtered from `props`. - * - * @private - * @param {Object} object The object to inspect. - * @param {Array} props The property names to filter. - * @returns {Array} Returns the function names. - */ - function baseFunctions(object, props) { - return arrayFilter(props, function(key) { - return isFunction(object[key]); - }); - } - - /** - * The base implementation of `_.get` without support for default values. - * - * @private - * @param {Object} object The object to query. - * @param {Array|string} path The path of the property to get. - * @returns {*} Returns the resolved value. - */ - function baseGet(object, path) { - path = castPath(path, object); - - var index = 0, - length = path.length; - - while (object != null && index < length) { - object = object[toKey(path[index++])]; - } - return (index && index == length) ? object : undefined; - } - - /** - * The base implementation of `getAllKeys` and `getAllKeysIn` which uses - * `keysFunc` and `symbolsFunc` to get the enumerable property names and - * symbols of `object`. - * - * @private - * @param {Object} object The object to query. - * @param {Function} keysFunc The function to get the keys of `object`. - * @param {Function} symbolsFunc The function to get the symbols of `object`. - * @returns {Array} Returns the array of property names and symbols. - */ - function baseGetAllKeys(object, keysFunc, symbolsFunc) { - var result = keysFunc(object); - return isArray(object) ? result : arrayPush(result, symbolsFunc(object)); - } - - /** - * The base implementation of `getTag` without fallbacks for buggy environments. - * - * @private - * @param {*} value The value to query. - * @returns {string} Returns the `toStringTag`. - */ - function baseGetTag(value) { - if (value == null) { - return value === undefined ? undefinedTag : nullTag; - } - return (symToStringTag && symToStringTag in Object(value)) - ? getRawTag(value) - : objectToString(value); - } - - /** - * The base implementation of `_.gt` which doesn't coerce arguments. - * - * @private - * @param {*} value The value to compare. - * @param {*} other The other value to compare. - * @returns {boolean} Returns `true` if `value` is greater than `other`, - * else `false`. - */ - function baseGt(value, other) { - return value > other; - } - - /** - * The base implementation of `_.has` without support for deep paths. - * - * @private - * @param {Object} [object] The object to query. - * @param {Array|string} key The key to check. - * @returns {boolean} Returns `true` if `key` exists, else `false`. - */ - function baseHas(object, key) { - return object != null && hasOwnProperty.call(object, key); - } - - /** - * The base implementation of `_.hasIn` without support for deep paths. - * - * @private - * @param {Object} [object] The object to query. - * @param {Array|string} key The key to check. - * @returns {boolean} Returns `true` if `key` exists, else `false`. - */ - function baseHasIn(object, key) { - return object != null && key in Object(object); - } - - /** - * The base implementation of `_.inRange` which doesn't coerce arguments. - * - * @private - * @param {number} number The number to check. - * @param {number} start The start of the range. - * @param {number} end The end of the range. - * @returns {boolean} Returns `true` if `number` is in the range, else `false`. - */ - function baseInRange(number, start, end) { - return number >= nativeMin(start, end) && number < nativeMax(start, end); - } - - /** - * The base implementation of methods like `_.intersection`, without support - * for iteratee shorthands, that accepts an array of arrays to inspect. - * - * @private - * @param {Array} arrays The arrays to inspect. - * @param {Function} [iteratee] The iteratee invoked per element. - * @param {Function} [comparator] The comparator invoked per element. - * @returns {Array} Returns the new array of shared values. - */ - function baseIntersection(arrays, iteratee, comparator) { - var includes = comparator ? arrayIncludesWith : arrayIncludes, - length = arrays[0].length, - othLength = arrays.length, - othIndex = othLength, - caches = Array(othLength), - maxLength = Infinity, - result = []; - - while (othIndex--) { - var array = arrays[othIndex]; - if (othIndex && iteratee) { - array = arrayMap(array, baseUnary(iteratee)); - } - maxLength = nativeMin(array.length, maxLength); - caches[othIndex] = !comparator && (iteratee || (length >= 120 && array.length >= 120)) - ? new SetCache(othIndex && array) - : undefined; - } - array = arrays[0]; - - var index = -1, - seen = caches[0]; - - outer: - while (++index < length && result.length < maxLength) { - var value = array[index], - computed = iteratee ? iteratee(value) : value; - - value = (comparator || value !== 0) ? value : 0; - if (!(seen - ? cacheHas(seen, computed) - : includes(result, computed, comparator) - )) { - othIndex = othLength; - while (--othIndex) { - var cache = caches[othIndex]; - if (!(cache - ? cacheHas(cache, computed) - : includes(arrays[othIndex], computed, comparator)) - ) { - continue outer; - } - } - if (seen) { - seen.push(computed); - } - result.push(value); - } - } - return result; - } - - /** - * The base implementation of `_.invert` and `_.invertBy` which inverts - * `object` with values transformed by `iteratee` and set by `setter`. - * - * @private - * @param {Object} object The object to iterate over. - * @param {Function} setter The function to set `accumulator` values. - * @param {Function} iteratee The iteratee to transform values. - * @param {Object} accumulator The initial inverted object. - * @returns {Function} Returns `accumulator`. - */ - function baseInverter(object, setter, iteratee, accumulator) { - baseForOwn(object, function(value, key, object) { - setter(accumulator, iteratee(value), key, object); - }); - return accumulator; - } - - /** - * The base implementation of `_.invoke` without support for individual - * method arguments. - * - * @private - * @param {Object} object The object to query. - * @param {Array|string} path The path of the method to invoke. - * @param {Array} args The arguments to invoke the method with. - * @returns {*} Returns the result of the invoked method. - */ - function baseInvoke(object, path, args) { - path = castPath(path, object); - object = parent(object, path); - var func = object == null ? object : object[toKey(last(path))]; - return func == null ? undefined : apply(func, object, args); - } - - /** - * The base implementation of `_.isArguments`. - * - * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is an `arguments` object, - */ - function baseIsArguments(value) { - return isObjectLike(value) && baseGetTag(value) == argsTag; - } - - /** - * The base implementation of `_.isArrayBuffer` without Node.js optimizations. - * - * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`. - */ - function baseIsArrayBuffer(value) { - return isObjectLike(value) && baseGetTag(value) == arrayBufferTag; - } - - /** - * The base implementation of `_.isDate` without Node.js optimizations. - * - * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a date object, else `false`. - */ - function baseIsDate(value) { - return isObjectLike(value) && baseGetTag(value) == dateTag; - } - - /** - * The base implementation of `_.isEqual` which supports partial comparisons - * and tracks traversed objects. - * - * @private - * @param {*} value The value to compare. - * @param {*} other The other value to compare. - * @param {boolean} bitmask The bitmask flags. - * 1 - Unordered comparison - * 2 - Partial comparison - * @param {Function} [customizer] The function to customize comparisons. - * @param {Object} [stack] Tracks traversed `value` and `other` objects. - * @returns {boolean} Returns `true` if the values are equivalent, else `false`. - */ - function baseIsEqual(value, other, bitmask, customizer, stack) { - if (value === other) { - return true; - } - if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) { - return value !== value && other !== other; - } - return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack); - } - - /** - * A specialized version of `baseIsEqual` for arrays and objects which performs - * deep comparisons and tracks traversed objects enabling objects with circular - * references to be compared. - * - * @private - * @param {Object} object The object to compare. - * @param {Object} other The other object to compare. - * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. - * @param {Function} customizer The function to customize comparisons. - * @param {Function} equalFunc The function to determine equivalents of values. - * @param {Object} [stack] Tracks traversed `object` and `other` objects. - * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. - */ - function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) { - var objIsArr = isArray(object), - othIsArr = isArray(other), - objTag = objIsArr ? arrayTag : getTag(object), - othTag = othIsArr ? arrayTag : getTag(other); - - objTag = objTag == argsTag ? objectTag : objTag; - othTag = othTag == argsTag ? objectTag : othTag; - - var objIsObj = objTag == objectTag, - othIsObj = othTag == objectTag, - isSameTag = objTag == othTag; - - if (isSameTag && isBuffer(object)) { - if (!isBuffer(other)) { - return false; - } - objIsArr = true; - objIsObj = false; - } - if (isSameTag && !objIsObj) { - stack || (stack = new Stack); - return (objIsArr || isTypedArray(object)) - ? equalArrays(object, other, bitmask, customizer, equalFunc, stack) - : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack); - } - if (!(bitmask & COMPARE_PARTIAL_FLAG)) { - var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'), - othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__'); - - if (objIsWrapped || othIsWrapped) { - var objUnwrapped = objIsWrapped ? object.value() : object, - othUnwrapped = othIsWrapped ? other.value() : other; - - stack || (stack = new Stack); - return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack); - } - } - if (!isSameTag) { - return false; - } - stack || (stack = new Stack); - return equalObjects(object, other, bitmask, customizer, equalFunc, stack); - } - - /** - * The base implementation of `_.isMap` without Node.js optimizations. - * - * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a map, else `false`. - */ - function baseIsMap(value) { - return isObjectLike(value) && getTag(value) == mapTag; - } - - /** - * The base implementation of `_.isMatch` without support for iteratee shorthands. - * - * @private - * @param {Object} object The object to inspect. - * @param {Object} source The object of property values to match. - * @param {Array} matchData The property names, values, and compare flags to match. - * @param {Function} [customizer] The function to customize comparisons. - * @returns {boolean} Returns `true` if `object` is a match, else `false`. - */ - function baseIsMatch(object, source, matchData, customizer) { - var index = matchData.length, - length = index, - noCustomizer = !customizer; - - if (object == null) { - return !length; - } - object = Object(object); - while (index--) { - var data = matchData[index]; - if ((noCustomizer && data[2]) - ? data[1] !== object[data[0]] - : !(data[0] in object) - ) { - return false; - } - } - while (++index < length) { - data = matchData[index]; - var key = data[0], - objValue = object[key], - srcValue = data[1]; - - if (noCustomizer && data[2]) { - if (objValue === undefined && !(key in object)) { - return false; - } - } else { - var stack = new Stack; - if (customizer) { - var result = customizer(objValue, srcValue, key, object, source, stack); - } - if (!(result === undefined - ? baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG, customizer, stack) - : result - )) { - return false; - } - } - } - return true; - } - - /** - * The base implementation of `_.isNative` without bad shim checks. - * - * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a native function, - * else `false`. - */ - function baseIsNative(value) { - if (!isObject(value) || isMasked(value)) { - return false; - } - var pattern = isFunction(value) ? reIsNative : reIsHostCtor; - return pattern.test(toSource(value)); - } - - /** - * The base implementation of `_.isRegExp` without Node.js optimizations. - * - * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a regexp, else `false`. - */ - function baseIsRegExp(value) { - return isObjectLike(value) && baseGetTag(value) == regexpTag; - } - - /** - * The base implementation of `_.isSet` without Node.js optimizations. - * - * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a set, else `false`. - */ - function baseIsSet(value) { - return isObjectLike(value) && getTag(value) == setTag; - } - - /** - * The base implementation of `_.isTypedArray` without Node.js optimizations. - * - * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a typed array, else `false`. - */ - function baseIsTypedArray(value) { - return isObjectLike(value) && - isLength(value.length) && !!typedArrayTags[baseGetTag(value)]; - } - - /** - * The base implementation of `_.iteratee`. - * - * @private - * @param {*} [value=_.identity] The value to convert to an iteratee. - * @returns {Function} Returns the iteratee. - */ - function baseIteratee(value) { - // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9. - // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details. - if (typeof value == 'function') { - return value; - } - if (value == null) { - return identity; - } - if (typeof value == 'object') { - return isArray(value) - ? baseMatchesProperty(value[0], value[1]) - : baseMatches(value); - } - return property(value); - } - - /** - * The base implementation of `_.keys` which doesn't treat sparse arrays as dense. - * - * @private - * @param {Object} object The object to query. - * @returns {Array} Returns the array of property names. - */ - function baseKeys(object) { - if (!isPrototype(object)) { - return nativeKeys(object); - } - var result = []; - for (var key in Object(object)) { - if (hasOwnProperty.call(object, key) && key != 'constructor') { - result.push(key); - } - } - return result; - } - - /** - * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense. - * - * @private - * @param {Object} object The object to query. - * @returns {Array} Returns the array of property names. - */ - function baseKeysIn(object) { - if (!isObject(object)) { - return nativeKeysIn(object); - } - var isProto = isPrototype(object), - result = []; - - for (var key in object) { - if (!(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) { - result.push(key); - } - } - return result; - } - - /** - * The base implementation of `_.lt` which doesn't coerce arguments. - * - * @private - * @param {*} value The value to compare. - * @param {*} other The other value to compare. - * @returns {boolean} Returns `true` if `value` is less than `other`, - * else `false`. - */ - function baseLt(value, other) { - return value < other; - } - - /** - * The base implementation of `_.map` without support for iteratee shorthands. - * - * @private - * @param {Array|Object} collection The collection to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @returns {Array} Returns the new mapped array. - */ - function baseMap(collection, iteratee) { - var index = -1, - result = isArrayLike(collection) ? Array(collection.length) : []; - - baseEach(collection, function(value, key, collection) { - result[++index] = iteratee(value, key, collection); - }); - return result; - } - - /** - * The base implementation of `_.matches` which doesn't clone `source`. - * - * @private - * @param {Object} source The object of property values to match. - * @returns {Function} Returns the new spec function. - */ - function baseMatches(source) { - var matchData = getMatchData(source); - if (matchData.length == 1 && matchData[0][2]) { - return matchesStrictComparable(matchData[0][0], matchData[0][1]); - } - return function(object) { - return object === source || baseIsMatch(object, source, matchData); - }; - } - - /** - * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`. - * - * @private - * @param {string} path The path of the property to get. - * @param {*} srcValue The value to match. - * @returns {Function} Returns the new spec function. - */ - function baseMatchesProperty(path, srcValue) { - if (isKey(path) && isStrictComparable(srcValue)) { - return matchesStrictComparable(toKey(path), srcValue); - } - return function(object) { - var objValue = get(object, path); - return (objValue === undefined && objValue === srcValue) - ? hasIn(object, path) - : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG); - }; - } - - /** - * The base implementation of `_.merge` without support for multiple sources. - * - * @private - * @param {Object} object The destination object. - * @param {Object} source The source object. - * @param {number} srcIndex The index of `source`. - * @param {Function} [customizer] The function to customize merged values. - * @param {Object} [stack] Tracks traversed source values and their merged - * counterparts. - */ - function baseMerge(object, source, srcIndex, customizer, stack) { - if (object === source) { - return; - } - baseFor(source, function(srcValue, key) { - if (isObject(srcValue)) { - stack || (stack = new Stack); - baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack); - } - else { - var newValue = customizer - ? customizer(object[key], srcValue, (key + ''), object, source, stack) - : undefined; - - if (newValue === undefined) { - newValue = srcValue; - } - assignMergeValue(object, key, newValue); - } - }, keysIn); - } - - /** - * A specialized version of `baseMerge` for arrays and objects which performs - * deep merges and tracks traversed objects enabling objects with circular - * references to be merged. - * - * @private - * @param {Object} object The destination object. - * @param {Object} source The source object. - * @param {string} key The key of the value to merge. - * @param {number} srcIndex The index of `source`. - * @param {Function} mergeFunc The function to merge values. - * @param {Function} [customizer] The function to customize assigned values. - * @param {Object} [stack] Tracks traversed source values and their merged - * counterparts. - */ - function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) { - var objValue = object[key], - srcValue = source[key], - stacked = stack.get(srcValue); - - if (stacked) { - assignMergeValue(object, key, stacked); - return; - } - var newValue = customizer - ? customizer(objValue, srcValue, (key + ''), object, source, stack) - : undefined; - - var isCommon = newValue === undefined; - - if (isCommon) { - var isArr = isArray(srcValue), - isBuff = !isArr && isBuffer(srcValue), - isTyped = !isArr && !isBuff && isTypedArray(srcValue); - - newValue = srcValue; - if (isArr || isBuff || isTyped) { - if (isArray(objValue)) { - newValue = objValue; - } - else if (isArrayLikeObject(objValue)) { - newValue = copyArray(objValue); - } - else if (isBuff) { - isCommon = false; - newValue = cloneBuffer(srcValue, true); - } - else if (isTyped) { - isCommon = false; - newValue = cloneTypedArray(srcValue, true); - } - else { - newValue = []; - } - } - else if (isPlainObject(srcValue) || isArguments(srcValue)) { - newValue = objValue; - if (isArguments(objValue)) { - newValue = toPlainObject(objValue); - } - else if (!isObject(objValue) || (srcIndex && isFunction(objValue))) { - newValue = initCloneObject(srcValue); - } - } - else { - isCommon = false; - } - } - if (isCommon) { - // Recursively merge objects and arrays (susceptible to call stack limits). - stack.set(srcValue, newValue); - mergeFunc(newValue, srcValue, srcIndex, customizer, stack); - stack['delete'](srcValue); - } - assignMergeValue(object, key, newValue); - } - - /** - * The base implementation of `_.nth` which doesn't coerce arguments. - * - * @private - * @param {Array} array The array to query. - * @param {number} n The index of the element to return. - * @returns {*} Returns the nth element of `array`. - */ - function baseNth(array, n) { - var length = array.length; - if (!length) { - return; - } - n += n < 0 ? length : 0; - return isIndex(n, length) ? array[n] : undefined; - } - - /** - * The base implementation of `_.orderBy` without param guards. - * - * @private - * @param {Array|Object} collection The collection to iterate over. - * @param {Function[]|Object[]|string[]} iteratees The iteratees to sort by. - * @param {string[]} orders The sort orders of `iteratees`. - * @returns {Array} Returns the new sorted array. - */ - function baseOrderBy(collection, iteratees, orders) { - var index = -1; - iteratees = arrayMap(iteratees.length ? iteratees : [identity], baseUnary(getIteratee())); - - var result = baseMap(collection, function(value, key, collection) { - var criteria = arrayMap(iteratees, function(iteratee) { - return iteratee(value); - }); - return { 'criteria': criteria, 'index': ++index, 'value': value }; - }); - - return baseSortBy(result, function(object, other) { - return compareMultiple(object, other, orders); - }); - } - - /** - * The base implementation of `_.pick` without support for individual - * property identifiers. - * - * @private - * @param {Object} object The source object. - * @param {string[]} paths The property paths to pick. - * @returns {Object} Returns the new object. - */ - function basePick(object, paths) { - return basePickBy(object, paths, function(value, path) { - return hasIn(object, path); - }); - } - - /** - * The base implementation of `_.pickBy` without support for iteratee shorthands. - * - * @private - * @param {Object} object The source object. - * @param {string[]} paths The property paths to pick. - * @param {Function} predicate The function invoked per property. - * @returns {Object} Returns the new object. - */ - function basePickBy(object, paths, predicate) { - var index = -1, - length = paths.length, - result = {}; - - while (++index < length) { - var path = paths[index], - value = baseGet(object, path); - - if (predicate(value, path)) { - baseSet(result, castPath(path, object), value); - } - } - return result; - } - - /** - * A specialized version of `baseProperty` which supports deep paths. - * - * @private - * @param {Array|string} path The path of the property to get. - * @returns {Function} Returns the new accessor function. - */ - function basePropertyDeep(path) { - return function(object) { - return baseGet(object, path); - }; - } - - /** - * The base implementation of `_.pullAllBy` without support for iteratee - * shorthands. - * - * @private - * @param {Array} array The array to modify. - * @param {Array} values The values to remove. - * @param {Function} [iteratee] The iteratee invoked per element. - * @param {Function} [comparator] The comparator invoked per element. - * @returns {Array} Returns `array`. - */ - function basePullAll(array, values, iteratee, comparator) { - var indexOf = comparator ? baseIndexOfWith : baseIndexOf, - index = -1, - length = values.length, - seen = array; - - if (array === values) { - values = copyArray(values); - } - if (iteratee) { - seen = arrayMap(array, baseUnary(iteratee)); - } - while (++index < length) { - var fromIndex = 0, - value = values[index], - computed = iteratee ? iteratee(value) : value; - - while ((fromIndex = indexOf(seen, computed, fromIndex, comparator)) > -1) { - if (seen !== array) { - splice.call(seen, fromIndex, 1); - } - splice.call(array, fromIndex, 1); - } - } - return array; - } - - /** - * The base implementation of `_.pullAt` without support for individual - * indexes or capturing the removed elements. - * - * @private - * @param {Array} array The array to modify. - * @param {number[]} indexes The indexes of elements to remove. - * @returns {Array} Returns `array`. - */ - function basePullAt(array, indexes) { - var length = array ? indexes.length : 0, - lastIndex = length - 1; - - while (length--) { - var index = indexes[length]; - if (length == lastIndex || index !== previous) { - var previous = index; - if (isIndex(index)) { - splice.call(array, index, 1); - } else { - baseUnset(array, index); - } - } - } - return array; - } - - /** - * The base implementation of `_.random` without support for returning - * floating-point numbers. - * - * @private - * @param {number} lower The lower bound. - * @param {number} upper The upper bound. - * @returns {number} Returns the random number. - */ - function baseRandom(lower, upper) { - return lower + nativeFloor(nativeRandom() * (upper - lower + 1)); - } - - /** - * The base implementation of `_.range` and `_.rangeRight` which doesn't - * coerce arguments. - * - * @private - * @param {number} start The start of the range. - * @param {number} end The end of the range. - * @param {number} step The value to increment or decrement by. - * @param {boolean} [fromRight] Specify iterating from right to left. - * @returns {Array} Returns the range of numbers. - */ - function baseRange(start, end, step, fromRight) { - var index = -1, - length = nativeMax(nativeCeil((end - start) / (step || 1)), 0), - result = Array(length); - - while (length--) { - result[fromRight ? length : ++index] = start; - start += step; - } - return result; - } - - /** - * The base implementation of `_.repeat` which doesn't coerce arguments. - * - * @private - * @param {string} string The string to repeat. - * @param {number} n The number of times to repeat the string. - * @returns {string} Returns the repeated string. - */ - function baseRepeat(string, n) { - var result = ''; - if (!string || n < 1 || n > MAX_SAFE_INTEGER) { - return result; - } - // Leverage the exponentiation by squaring algorithm for a faster repeat. - // See https://en.wikipedia.org/wiki/Exponentiation_by_squaring for more details. - do { - if (n % 2) { - result += string; - } - n = nativeFloor(n / 2); - if (n) { - string += string; - } - } while (n); - - return result; - } - - /** - * The base implementation of `_.rest` which doesn't validate or coerce arguments. - * - * @private - * @param {Function} func The function to apply a rest parameter to. - * @param {number} [start=func.length-1] The start position of the rest parameter. - * @returns {Function} Returns the new function. - */ - function baseRest(func, start) { - return setToString(overRest(func, start, identity), func + ''); - } - - /** - * The base implementation of `_.sample`. - * - * @private - * @param {Array|Object} collection The collection to sample. - * @returns {*} Returns the random element. - */ - function baseSample(collection) { - return arraySample(values(collection)); - } - - /** - * The base implementation of `_.sampleSize` without param guards. - * - * @private - * @param {Array|Object} collection The collection to sample. - * @param {number} n The number of elements to sample. - * @returns {Array} Returns the random elements. - */ - function baseSampleSize(collection, n) { - var array = values(collection); - return shuffleSelf(array, baseClamp(n, 0, array.length)); - } - - /** - * The base implementation of `_.set`. - * - * @private - * @param {Object} object The object to modify. - * @param {Array|string} path The path of the property to set. - * @param {*} value The value to set. - * @param {Function} [customizer] The function to customize path creation. - * @returns {Object} Returns `object`. - */ - function baseSet(object, path, value, customizer) { - if (!isObject(object)) { - return object; - } - path = castPath(path, object); - - var index = -1, - length = path.length, - lastIndex = length - 1, - nested = object; - - while (nested != null && ++index < length) { - var key = toKey(path[index]), - newValue = value; - - if (index != lastIndex) { - var objValue = nested[key]; - newValue = customizer ? customizer(objValue, key, nested) : undefined; - if (newValue === undefined) { - newValue = isObject(objValue) - ? objValue - : (isIndex(path[index + 1]) ? [] : {}); - } - } - assignValue(nested, key, newValue); - nested = nested[key]; - } - return object; - } - - /** - * The base implementation of `setData` without support for hot loop shorting. - * - * @private - * @param {Function} func The function to associate metadata with. - * @param {*} data The metadata. - * @returns {Function} Returns `func`. - */ - var baseSetData = !metaMap ? identity : function(func, data) { - metaMap.set(func, data); - return func; - }; - - /** - * The base implementation of `setToString` without support for hot loop shorting. - * - * @private - * @param {Function} func The function to modify. - * @param {Function} string The `toString` result. - * @returns {Function} Returns `func`. - */ - var baseSetToString = !defineProperty ? identity : function(func, string) { - return defineProperty(func, 'toString', { - 'configurable': true, - 'enumerable': false, - 'value': constant(string), - 'writable': true - }); - }; - - /** - * The base implementation of `_.shuffle`. - * - * @private - * @param {Array|Object} collection The collection to shuffle. - * @returns {Array} Returns the new shuffled array. - */ - function baseShuffle(collection) { - return shuffleSelf(values(collection)); - } - - /** - * The base implementation of `_.slice` without an iteratee call guard. - * - * @private - * @param {Array} array The array to slice. - * @param {number} [start=0] The start position. - * @param {number} [end=array.length] The end position. - * @returns {Array} Returns the slice of `array`. - */ - function baseSlice(array, start, end) { - var index = -1, - length = array.length; - - if (start < 0) { - start = -start > length ? 0 : (length + start); - } - end = end > length ? length : end; - if (end < 0) { - end += length; - } - length = start > end ? 0 : ((end - start) >>> 0); - start >>>= 0; - - var result = Array(length); - while (++index < length) { - result[index] = array[index + start]; - } - return result; - } - - /** - * The base implementation of `_.some` without support for iteratee shorthands. - * - * @private - * @param {Array|Object} collection The collection to iterate over. - * @param {Function} predicate The function invoked per iteration. - * @returns {boolean} Returns `true` if any element passes the predicate check, - * else `false`. - */ - function baseSome(collection, predicate) { - var result; - - baseEach(collection, function(value, index, collection) { - result = predicate(value, index, collection); - return !result; - }); - return !!result; - } - - /** - * The base implementation of `_.sortedIndex` and `_.sortedLastIndex` which - * performs a binary search of `array` to determine the index at which `value` - * should be inserted into `array` in order to maintain its sort order. - * - * @private - * @param {Array} array The sorted array to inspect. - * @param {*} value The value to evaluate. - * @param {boolean} [retHighest] Specify returning the highest qualified index. - * @returns {number} Returns the index at which `value` should be inserted - * into `array`. - */ - function baseSortedIndex(array, value, retHighest) { - var low = 0, - high = array == null ? low : array.length; - - if (typeof value == 'number' && value === value && high <= HALF_MAX_ARRAY_LENGTH) { - while (low < high) { - var mid = (low + high) >>> 1, - computed = array[mid]; - - if (computed !== null && !isSymbol(computed) && - (retHighest ? (computed <= value) : (computed < value))) { - low = mid + 1; - } else { - high = mid; - } - } - return high; - } - return baseSortedIndexBy(array, value, identity, retHighest); - } - - /** - * The base implementation of `_.sortedIndexBy` and `_.sortedLastIndexBy` - * which invokes `iteratee` for `value` and each element of `array` to compute - * their sort ranking. The iteratee is invoked with one argument; (value). - * - * @private - * @param {Array} array The sorted array to inspect. - * @param {*} value The value to evaluate. - * @param {Function} iteratee The iteratee invoked per element. - * @param {boolean} [retHighest] Specify returning the highest qualified index. - * @returns {number} Returns the index at which `value` should be inserted - * into `array`. - */ - function baseSortedIndexBy(array, value, iteratee, retHighest) { - value = iteratee(value); - - var low = 0, - high = array == null ? 0 : array.length, - valIsNaN = value !== value, - valIsNull = value === null, - valIsSymbol = isSymbol(value), - valIsUndefined = value === undefined; - - while (low < high) { - var mid = nativeFloor((low + high) / 2), - computed = iteratee(array[mid]), - othIsDefined = computed !== undefined, - othIsNull = computed === null, - othIsReflexive = computed === computed, - othIsSymbol = isSymbol(computed); - - if (valIsNaN) { - var setLow = retHighest || othIsReflexive; - } else if (valIsUndefined) { - setLow = othIsReflexive && (retHighest || othIsDefined); - } else if (valIsNull) { - setLow = othIsReflexive && othIsDefined && (retHighest || !othIsNull); - } else if (valIsSymbol) { - setLow = othIsReflexive && othIsDefined && !othIsNull && (retHighest || !othIsSymbol); - } else if (othIsNull || othIsSymbol) { - setLow = false; - } else { - setLow = retHighest ? (computed <= value) : (computed < value); - } - if (setLow) { - low = mid + 1; - } else { - high = mid; - } - } - return nativeMin(high, MAX_ARRAY_INDEX); - } - - /** - * The base implementation of `_.sortedUniq` and `_.sortedUniqBy` without - * support for iteratee shorthands. - * - * @private - * @param {Array} array The array to inspect. - * @param {Function} [iteratee] The iteratee invoked per element. - * @returns {Array} Returns the new duplicate free array. - */ - function baseSortedUniq(array, iteratee) { - var index = -1, - length = array.length, - resIndex = 0, - result = []; - - while (++index < length) { - var value = array[index], - computed = iteratee ? iteratee(value) : value; - - if (!index || !eq(computed, seen)) { - var seen = computed; - result[resIndex++] = value === 0 ? 0 : value; - } - } - return result; - } - - /** - * The base implementation of `_.toNumber` which doesn't ensure correct - * conversions of binary, hexadecimal, or octal string values. - * - * @private - * @param {*} value The value to process. - * @returns {number} Returns the number. - */ - function baseToNumber(value) { - if (typeof value == 'number') { - return value; - } - if (isSymbol(value)) { - return NAN; - } - return +value; - } - - /** - * The base implementation of `_.toString` which doesn't convert nullish - * values to empty strings. - * - * @private - * @param {*} value The value to process. - * @returns {string} Returns the string. - */ - function baseToString(value) { - // Exit early for strings to avoid a performance hit in some environments. - if (typeof value == 'string') { - return value; - } - if (isArray(value)) { - // Recursively convert values (susceptible to call stack limits). - return arrayMap(value, baseToString) + ''; - } - if (isSymbol(value)) { - return symbolToString ? symbolToString.call(value) : ''; - } - var result = (value + ''); - return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result; - } - - /** - * The base implementation of `_.uniqBy` without support for iteratee shorthands. - * - * @private - * @param {Array} array The array to inspect. - * @param {Function} [iteratee] The iteratee invoked per element. - * @param {Function} [comparator] The comparator invoked per element. - * @returns {Array} Returns the new duplicate free array. - */ - function baseUniq(array, iteratee, comparator) { - var index = -1, - includes = arrayIncludes, - length = array.length, - isCommon = true, - result = [], - seen = result; - - if (comparator) { - isCommon = false; - includes = arrayIncludesWith; - } - else if (length >= LARGE_ARRAY_SIZE) { - var set = iteratee ? null : createSet(array); - if (set) { - return setToArray(set); - } - isCommon = false; - includes = cacheHas; - seen = new SetCache; - } - else { - seen = iteratee ? [] : result; - } - outer: - while (++index < length) { - var value = array[index], - computed = iteratee ? iteratee(value) : value; - - value = (comparator || value !== 0) ? value : 0; - if (isCommon && computed === computed) { - var seenIndex = seen.length; - while (seenIndex--) { - if (seen[seenIndex] === computed) { - continue outer; - } - } - if (iteratee) { - seen.push(computed); - } - result.push(value); - } - else if (!includes(seen, computed, comparator)) { - if (seen !== result) { - seen.push(computed); - } - result.push(value); - } - } - return result; - } - - /** - * The base implementation of `_.unset`. - * - * @private - * @param {Object} object The object to modify. - * @param {Array|string} path The property path to unset. - * @returns {boolean} Returns `true` if the property is deleted, else `false`. - */ - function baseUnset(object, path) { - path = castPath(path, object); - object = parent(object, path); - return object == null || delete object[toKey(last(path))]; - } - - /** - * The base implementation of `_.update`. - * - * @private - * @param {Object} object The object to modify. - * @param {Array|string} path The path of the property to update. - * @param {Function} updater The function to produce the updated value. - * @param {Function} [customizer] The function to customize path creation. - * @returns {Object} Returns `object`. - */ - function baseUpdate(object, path, updater, customizer) { - return baseSet(object, path, updater(baseGet(object, path)), customizer); - } - - /** - * The base implementation of methods like `_.dropWhile` and `_.takeWhile` - * without support for iteratee shorthands. - * - * @private - * @param {Array} array The array to query. - * @param {Function} predicate The function invoked per iteration. - * @param {boolean} [isDrop] Specify dropping elements instead of taking them. - * @param {boolean} [fromRight] Specify iterating from right to left. - * @returns {Array} Returns the slice of `array`. - */ - function baseWhile(array, predicate, isDrop, fromRight) { - var length = array.length, - index = fromRight ? length : -1; - - while ((fromRight ? index-- : ++index < length) && - predicate(array[index], index, array)) {} - - return isDrop - ? baseSlice(array, (fromRight ? 0 : index), (fromRight ? index + 1 : length)) - : baseSlice(array, (fromRight ? index + 1 : 0), (fromRight ? length : index)); - } - - /** - * The base implementation of `wrapperValue` which returns the result of - * performing a sequence of actions on the unwrapped `value`, where each - * successive action is supplied the return value of the previous. - * - * @private - * @param {*} value The unwrapped value. - * @param {Array} actions Actions to perform to resolve the unwrapped value. - * @returns {*} Returns the resolved value. - */ - function baseWrapperValue(value, actions) { - var result = value; - if (result instanceof LazyWrapper) { - result = result.value(); - } - return arrayReduce(actions, function(result, action) { - return action.func.apply(action.thisArg, arrayPush([result], action.args)); - }, result); - } - - /** - * The base implementation of methods like `_.xor`, without support for - * iteratee shorthands, that accepts an array of arrays to inspect. - * - * @private - * @param {Array} arrays The arrays to inspect. - * @param {Function} [iteratee] The iteratee invoked per element. - * @param {Function} [comparator] The comparator invoked per element. - * @returns {Array} Returns the new array of values. - */ - function baseXor(arrays, iteratee, comparator) { - var length = arrays.length; - if (length < 2) { - return length ? baseUniq(arrays[0]) : []; - } - var index = -1, - result = Array(length); - - while (++index < length) { - var array = arrays[index], - othIndex = -1; - - while (++othIndex < length) { - if (othIndex != index) { - result[index] = baseDifference(result[index] || array, arrays[othIndex], iteratee, comparator); - } - } - } - return baseUniq(baseFlatten(result, 1), iteratee, comparator); - } - - /** - * This base implementation of `_.zipObject` which assigns values using `assignFunc`. - * - * @private - * @param {Array} props The property identifiers. - * @param {Array} values The property values. - * @param {Function} assignFunc The function to assign values. - * @returns {Object} Returns the new object. - */ - function baseZipObject(props, values, assignFunc) { - var index = -1, - length = props.length, - valsLength = values.length, - result = {}; - - while (++index < length) { - var value = index < valsLength ? values[index] : undefined; - assignFunc(result, props[index], value); - } - return result; - } - - /** - * Casts `value` to an empty array if it's not an array like object. - * - * @private - * @param {*} value The value to inspect. - * @returns {Array|Object} Returns the cast array-like object. - */ - function castArrayLikeObject(value) { - return isArrayLikeObject(value) ? value : []; - } - - /** - * Casts `value` to `identity` if it's not a function. - * - * @private - * @param {*} value The value to inspect. - * @returns {Function} Returns cast function. - */ - function castFunction(value) { - return typeof value == 'function' ? value : identity; - } - - /** - * Casts `value` to a path array if it's not one. - * - * @private - * @param {*} value The value to inspect. - * @param {Object} [object] The object to query keys on. - * @returns {Array} Returns the cast property path array. - */ - function castPath(value, object) { - if (isArray(value)) { - return value; - } - return isKey(value, object) ? [value] : stringToPath(toString(value)); - } - - /** - * A `baseRest` alias which can be replaced with `identity` by module - * replacement plugins. - * - * @private - * @type {Function} - * @param {Function} func The function to apply a rest parameter to. - * @returns {Function} Returns the new function. - */ - var castRest = baseRest; - - /** - * Casts `array` to a slice if it's needed. - * - * @private - * @param {Array} array The array to inspect. - * @param {number} start The start position. - * @param {number} [end=array.length] The end position. - * @returns {Array} Returns the cast slice. - */ - function castSlice(array, start, end) { - var length = array.length; - end = end === undefined ? length : end; - return (!start && end >= length) ? array : baseSlice(array, start, end); - } - - /** - * A simple wrapper around the global [`clearTimeout`](https://mdn.io/clearTimeout). - * - * @private - * @param {number|Object} id The timer id or timeout object of the timer to clear. - */ - var clearTimeout = ctxClearTimeout || function(id) { - return root.clearTimeout(id); - }; - - /** - * Creates a clone of `buffer`. - * - * @private - * @param {Buffer} buffer The buffer to clone. - * @param {boolean} [isDeep] Specify a deep clone. - * @returns {Buffer} Returns the cloned buffer. - */ - function cloneBuffer(buffer, isDeep) { - if (isDeep) { - return buffer.slice(); - } - var length = buffer.length, - result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length); - - buffer.copy(result); - return result; - } - - /** - * Creates a clone of `arrayBuffer`. - * - * @private - * @param {ArrayBuffer} arrayBuffer The array buffer to clone. - * @returns {ArrayBuffer} Returns the cloned array buffer. - */ - function cloneArrayBuffer(arrayBuffer) { - var result = new arrayBuffer.constructor(arrayBuffer.byteLength); - new Uint8Array(result).set(new Uint8Array(arrayBuffer)); - return result; - } - - /** - * Creates a clone of `dataView`. - * - * @private - * @param {Object} dataView The data view to clone. - * @param {boolean} [isDeep] Specify a deep clone. - * @returns {Object} Returns the cloned data view. - */ - function cloneDataView(dataView, isDeep) { - var buffer = isDeep ? cloneArrayBuffer(dataView.buffer) : dataView.buffer; - return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength); - } - - /** - * Creates a clone of `map`. - * - * @private - * @param {Object} map The map to clone. - * @param {Function} cloneFunc The function to clone values. - * @param {boolean} [isDeep] Specify a deep clone. - * @returns {Object} Returns the cloned map. - */ - function cloneMap(map, isDeep, cloneFunc) { - var array = isDeep ? cloneFunc(mapToArray(map), CLONE_DEEP_FLAG) : mapToArray(map); - return arrayReduce(array, addMapEntry, new map.constructor); - } - - /** - * Creates a clone of `regexp`. - * - * @private - * @param {Object} regexp The regexp to clone. - * @returns {Object} Returns the cloned regexp. - */ - function cloneRegExp(regexp) { - var result = new regexp.constructor(regexp.source, reFlags.exec(regexp)); - result.lastIndex = regexp.lastIndex; - return result; - } - - /** - * Creates a clone of `set`. - * - * @private - * @param {Object} set The set to clone. - * @param {Function} cloneFunc The function to clone values. - * @param {boolean} [isDeep] Specify a deep clone. - * @returns {Object} Returns the cloned set. - */ - function cloneSet(set, isDeep, cloneFunc) { - var array = isDeep ? cloneFunc(setToArray(set), CLONE_DEEP_FLAG) : setToArray(set); - return arrayReduce(array, addSetEntry, new set.constructor); - } - - /** - * Creates a clone of the `symbol` object. - * - * @private - * @param {Object} symbol The symbol object to clone. - * @returns {Object} Returns the cloned symbol object. - */ - function cloneSymbol(symbol) { - return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {}; - } - - /** - * Creates a clone of `typedArray`. - * - * @private - * @param {Object} typedArray The typed array to clone. - * @param {boolean} [isDeep] Specify a deep clone. - * @returns {Object} Returns the cloned typed array. - */ - function cloneTypedArray(typedArray, isDeep) { - var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer; - return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length); - } - - /** - * Compares values to sort them in ascending order. - * - * @private - * @param {*} value The value to compare. - * @param {*} other The other value to compare. - * @returns {number} Returns the sort order indicator for `value`. - */ - function compareAscending(value, other) { - if (value !== other) { - var valIsDefined = value !== undefined, - valIsNull = value === null, - valIsReflexive = value === value, - valIsSymbol = isSymbol(value); - - var othIsDefined = other !== undefined, - othIsNull = other === null, - othIsReflexive = other === other, - othIsSymbol = isSymbol(other); - - if ((!othIsNull && !othIsSymbol && !valIsSymbol && value > other) || - (valIsSymbol && othIsDefined && othIsReflexive && !othIsNull && !othIsSymbol) || - (valIsNull && othIsDefined && othIsReflexive) || - (!valIsDefined && othIsReflexive) || - !valIsReflexive) { - return 1; - } - if ((!valIsNull && !valIsSymbol && !othIsSymbol && value < other) || - (othIsSymbol && valIsDefined && valIsReflexive && !valIsNull && !valIsSymbol) || - (othIsNull && valIsDefined && valIsReflexive) || - (!othIsDefined && valIsReflexive) || - !othIsReflexive) { - return -1; - } - } - return 0; - } - - /** - * Used by `_.orderBy` to compare multiple properties of a value to another - * and stable sort them. - * - * If `orders` is unspecified, all values are sorted in ascending order. Otherwise, - * specify an order of "desc" for descending or "asc" for ascending sort order - * of corresponding values. - * - * @private - * @param {Object} object The object to compare. - * @param {Object} other The other object to compare. - * @param {boolean[]|string[]} orders The order to sort by for each property. - * @returns {number} Returns the sort order indicator for `object`. - */ - function compareMultiple(object, other, orders) { - var index = -1, - objCriteria = object.criteria, - othCriteria = other.criteria, - length = objCriteria.length, - ordersLength = orders.length; - - while (++index < length) { - var result = compareAscending(objCriteria[index], othCriteria[index]); - if (result) { - if (index >= ordersLength) { - return result; - } - var order = orders[index]; - return result * (order == 'desc' ? -1 : 1); - } - } - // Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications - // that causes it, under certain circumstances, to provide the same value for - // `object` and `other`. See https://github.com/jashkenas/underscore/pull/1247 - // for more details. - // - // This also ensures a stable sort in V8 and other engines. - // See https://bugs.chromium.org/p/v8/issues/detail?id=90 for more details. - return object.index - other.index; - } - - /** - * Creates an array that is the composition of partially applied arguments, - * placeholders, and provided arguments into a single array of arguments. - * - * @private - * @param {Array} args The provided arguments. - * @param {Array} partials The arguments to prepend to those provided. - * @param {Array} holders The `partials` placeholder indexes. - * @params {boolean} [isCurried] Specify composing for a curried function. - * @returns {Array} Returns the new array of composed arguments. - */ - function composeArgs(args, partials, holders, isCurried) { - var argsIndex = -1, - argsLength = args.length, - holdersLength = holders.length, - leftIndex = -1, - leftLength = partials.length, - rangeLength = nativeMax(argsLength - holdersLength, 0), - result = Array(leftLength + rangeLength), - isUncurried = !isCurried; - - while (++leftIndex < leftLength) { - result[leftIndex] = partials[leftIndex]; - } - while (++argsIndex < holdersLength) { - if (isUncurried || argsIndex < argsLength) { - result[holders[argsIndex]] = args[argsIndex]; - } - } - while (rangeLength--) { - result[leftIndex++] = args[argsIndex++]; - } - return result; - } - - /** - * This function is like `composeArgs` except that the arguments composition - * is tailored for `_.partialRight`. - * - * @private - * @param {Array} args The provided arguments. - * @param {Array} partials The arguments to append to those provided. - * @param {Array} holders The `partials` placeholder indexes. - * @params {boolean} [isCurried] Specify composing for a curried function. - * @returns {Array} Returns the new array of composed arguments. - */ - function composeArgsRight(args, partials, holders, isCurried) { - var argsIndex = -1, - argsLength = args.length, - holdersIndex = -1, - holdersLength = holders.length, - rightIndex = -1, - rightLength = partials.length, - rangeLength = nativeMax(argsLength - holdersLength, 0), - result = Array(rangeLength + rightLength), - isUncurried = !isCurried; - - while (++argsIndex < rangeLength) { - result[argsIndex] = args[argsIndex]; - } - var offset = argsIndex; - while (++rightIndex < rightLength) { - result[offset + rightIndex] = partials[rightIndex]; - } - while (++holdersIndex < holdersLength) { - if (isUncurried || argsIndex < argsLength) { - result[offset + holders[holdersIndex]] = args[argsIndex++]; - } - } - return result; - } - - /** - * Copies the values of `source` to `array`. - * - * @private - * @param {Array} source The array to copy values from. - * @param {Array} [array=[]] The array to copy values to. - * @returns {Array} Returns `array`. - */ - function copyArray(source, array) { - var index = -1, - length = source.length; - - array || (array = Array(length)); - while (++index < length) { - array[index] = source[index]; - } - return array; - } - - /** - * Copies properties of `source` to `object`. - * - * @private - * @param {Object} source The object to copy properties from. - * @param {Array} props The property identifiers to copy. - * @param {Object} [object={}] The object to copy properties to. - * @param {Function} [customizer] The function to customize copied values. - * @returns {Object} Returns `object`. - */ - function copyObject(source, props, object, customizer) { - var isNew = !object; - object || (object = {}); - - var index = -1, - length = props.length; - - while (++index < length) { - var key = props[index]; - - var newValue = customizer - ? customizer(object[key], source[key], key, object, source) - : undefined; - - if (newValue === undefined) { - newValue = source[key]; - } - if (isNew) { - baseAssignValue(object, key, newValue); - } else { - assignValue(object, key, newValue); - } - } - return object; - } - - /** - * Copies own symbols of `source` to `object`. - * - * @private - * @param {Object} source The object to copy symbols from. - * @param {Object} [object={}] The object to copy symbols to. - * @returns {Object} Returns `object`. - */ - function copySymbols(source, object) { - return copyObject(source, getSymbols(source), object); - } - - /** - * Copies own and inherited symbols of `source` to `object`. - * - * @private - * @param {Object} source The object to copy symbols from. - * @param {Object} [object={}] The object to copy symbols to. - * @returns {Object} Returns `object`. - */ - function copySymbolsIn(source, object) { - return copyObject(source, getSymbolsIn(source), object); - } - - /** - * Creates a function like `_.groupBy`. - * - * @private - * @param {Function} setter The function to set accumulator values. - * @param {Function} [initializer] The accumulator object initializer. - * @returns {Function} Returns the new aggregator function. - */ - function createAggregator(setter, initializer) { - return function(collection, iteratee) { - var func = isArray(collection) ? arrayAggregator : baseAggregator, - accumulator = initializer ? initializer() : {}; - - return func(collection, setter, getIteratee(iteratee, 2), accumulator); - }; - } - - /** - * Creates a function like `_.assign`. - * - * @private - * @param {Function} assigner The function to assign values. - * @returns {Function} Returns the new assigner function. - */ - function createAssigner(assigner) { - return baseRest(function(object, sources) { - var index = -1, - length = sources.length, - customizer = length > 1 ? sources[length - 1] : undefined, - guard = length > 2 ? sources[2] : undefined; - - customizer = (assigner.length > 3 && typeof customizer == 'function') - ? (length--, customizer) - : undefined; - - if (guard && isIterateeCall(sources[0], sources[1], guard)) { - customizer = length < 3 ? undefined : customizer; - length = 1; - } - object = Object(object); - while (++index < length) { - var source = sources[index]; - if (source) { - assigner(object, source, index, customizer); - } - } - return object; - }); - } - - /** - * Creates a `baseEach` or `baseEachRight` function. - * - * @private - * @param {Function} eachFunc The function to iterate over a collection. - * @param {boolean} [fromRight] Specify iterating from right to left. - * @returns {Function} Returns the new base function. - */ - function createBaseEach(eachFunc, fromRight) { - return function(collection, iteratee) { - if (collection == null) { - return collection; - } - if (!isArrayLike(collection)) { - return eachFunc(collection, iteratee); - } - var length = collection.length, - index = fromRight ? length : -1, - iterable = Object(collection); - - while ((fromRight ? index-- : ++index < length)) { - if (iteratee(iterable[index], index, iterable) === false) { - break; - } - } - return collection; - }; - } - - /** - * Creates a base function for methods like `_.forIn` and `_.forOwn`. - * - * @private - * @param {boolean} [fromRight] Specify iterating from right to left. - * @returns {Function} Returns the new base function. - */ - function createBaseFor(fromRight) { - return function(object, iteratee, keysFunc) { - var index = -1, - iterable = Object(object), - props = keysFunc(object), - length = props.length; - - while (length--) { - var key = props[fromRight ? length : ++index]; - if (iteratee(iterable[key], key, iterable) === false) { - break; - } - } - return object; - }; - } - - /** - * Creates a function that wraps `func` to invoke it with the optional `this` - * binding of `thisArg`. - * - * @private - * @param {Function} func The function to wrap. - * @param {number} bitmask The bitmask flags. See `createWrap` for more details. - * @param {*} [thisArg] The `this` binding of `func`. - * @returns {Function} Returns the new wrapped function. - */ - function createBind(func, bitmask, thisArg) { - var isBind = bitmask & WRAP_BIND_FLAG, - Ctor = createCtor(func); - - function wrapper() { - var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func; - return fn.apply(isBind ? thisArg : this, arguments); - } - return wrapper; - } - - /** - * Creates a function like `_.lowerFirst`. - * - * @private - * @param {string} methodName The name of the `String` case method to use. - * @returns {Function} Returns the new case function. - */ - function createCaseFirst(methodName) { - return function(string) { - string = toString(string); - - var strSymbols = hasUnicode(string) - ? stringToArray(string) - : undefined; - - var chr = strSymbols - ? strSymbols[0] - : string.charAt(0); - - var trailing = strSymbols - ? castSlice(strSymbols, 1).join('') - : string.slice(1); - - return chr[methodName]() + trailing; - }; - } - - /** - * Creates a function like `_.camelCase`. - * - * @private - * @param {Function} callback The function to combine each word. - * @returns {Function} Returns the new compounder function. - */ - function createCompounder(callback) { - return function(string) { - return arrayReduce(words(deburr(string).replace(reApos, '')), callback, ''); - }; - } - - /** - * Creates a function that produces an instance of `Ctor` regardless of - * whether it was invoked as part of a `new` expression or by `call` or `apply`. - * - * @private - * @param {Function} Ctor The constructor to wrap. - * @returns {Function} Returns the new wrapped function. - */ - function createCtor(Ctor) { - return function() { - // Use a `switch` statement to work with class constructors. See - // http://ecma-international.org/ecma-262/7.0/#sec-ecmascript-function-objects-call-thisargument-argumentslist - // for more details. - var args = arguments; - switch (args.length) { - case 0: return new Ctor; - case 1: return new Ctor(args[0]); - case 2: return new Ctor(args[0], args[1]); - case 3: return new Ctor(args[0], args[1], args[2]); - case 4: return new Ctor(args[0], args[1], args[2], args[3]); - case 5: return new Ctor(args[0], args[1], args[2], args[3], args[4]); - case 6: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5]); - case 7: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5], args[6]); - } - var thisBinding = baseCreate(Ctor.prototype), - result = Ctor.apply(thisBinding, args); - - // Mimic the constructor's `return` behavior. - // See https://es5.github.io/#x13.2.2 for more details. - return isObject(result) ? result : thisBinding; - }; - } - - /** - * Creates a function that wraps `func` to enable currying. - * - * @private - * @param {Function} func The function to wrap. - * @param {number} bitmask The bitmask flags. See `createWrap` for more details. - * @param {number} arity The arity of `func`. - * @returns {Function} Returns the new wrapped function. - */ - function createCurry(func, bitmask, arity) { - var Ctor = createCtor(func); - - function wrapper() { - var length = arguments.length, - args = Array(length), - index = length, - placeholder = getHolder(wrapper); - - while (index--) { - args[index] = arguments[index]; - } - var holders = (length < 3 && args[0] !== placeholder && args[length - 1] !== placeholder) - ? [] - : replaceHolders(args, placeholder); - - length -= holders.length; - if (length < arity) { - return createRecurry( - func, bitmask, createHybrid, wrapper.placeholder, undefined, - args, holders, undefined, undefined, arity - length); - } - var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func; - return apply(fn, this, args); - } - return wrapper; - } - - /** - * Creates a `_.find` or `_.findLast` function. - * - * @private - * @param {Function} findIndexFunc The function to find the collection index. - * @returns {Function} Returns the new find function. - */ - function createFind(findIndexFunc) { - return function(collection, predicate, fromIndex) { - var iterable = Object(collection); - if (!isArrayLike(collection)) { - var iteratee = getIteratee(predicate, 3); - collection = keys(collection); - predicate = function(key) { return iteratee(iterable[key], key, iterable); }; - } - var index = findIndexFunc(collection, predicate, fromIndex); - return index > -1 ? iterable[iteratee ? collection[index] : index] : undefined; - }; - } - - /** - * Creates a `_.flow` or `_.flowRight` function. - * - * @private - * @param {boolean} [fromRight] Specify iterating from right to left. - * @returns {Function} Returns the new flow function. - */ - function createFlow(fromRight) { - return flatRest(function(funcs) { - var length = funcs.length, - index = length, - prereq = LodashWrapper.prototype.thru; - - if (fromRight) { - funcs.reverse(); - } - while (index--) { - var func = funcs[index]; - if (typeof func != 'function') { - throw new TypeError(FUNC_ERROR_TEXT); - } - if (prereq && !wrapper && getFuncName(func) == 'wrapper') { - var wrapper = new LodashWrapper([], true); - } - } - index = wrapper ? index : length; - while (++index < length) { - func = funcs[index]; - - var funcName = getFuncName(func), - data = funcName == 'wrapper' ? getData(func) : undefined; - - if (data && isLaziable(data[0]) && - data[1] == (WRAP_ARY_FLAG | WRAP_CURRY_FLAG | WRAP_PARTIAL_FLAG | WRAP_REARG_FLAG) && - !data[4].length && data[9] == 1 - ) { - wrapper = wrapper[getFuncName(data[0])].apply(wrapper, data[3]); - } else { - wrapper = (func.length == 1 && isLaziable(func)) - ? wrapper[funcName]() - : wrapper.thru(func); - } - } - return function() { - var args = arguments, - value = args[0]; - - if (wrapper && args.length == 1 && isArray(value)) { - return wrapper.plant(value).value(); - } - var index = 0, - result = length ? funcs[index].apply(this, args) : value; - - while (++index < length) { - result = funcs[index].call(this, result); - } - return result; - }; - }); - } - - /** - * Creates a function that wraps `func` to invoke it with optional `this` - * binding of `thisArg`, partial application, and currying. - * - * @private - * @param {Function|string} func The function or method name to wrap. - * @param {number} bitmask The bitmask flags. See `createWrap` for more details. - * @param {*} [thisArg] The `this` binding of `func`. - * @param {Array} [partials] The arguments to prepend to those provided to - * the new function. - * @param {Array} [holders] The `partials` placeholder indexes. - * @param {Array} [partialsRight] The arguments to append to those provided - * to the new function. - * @param {Array} [holdersRight] The `partialsRight` placeholder indexes. - * @param {Array} [argPos] The argument positions of the new function. - * @param {number} [ary] The arity cap of `func`. - * @param {number} [arity] The arity of `func`. - * @returns {Function} Returns the new wrapped function. - */ - function createHybrid(func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity) { - var isAry = bitmask & WRAP_ARY_FLAG, - isBind = bitmask & WRAP_BIND_FLAG, - isBindKey = bitmask & WRAP_BIND_KEY_FLAG, - isCurried = bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG), - isFlip = bitmask & WRAP_FLIP_FLAG, - Ctor = isBindKey ? undefined : createCtor(func); - - function wrapper() { - var length = arguments.length, - args = Array(length), - index = length; - - while (index--) { - args[index] = arguments[index]; - } - if (isCurried) { - var placeholder = getHolder(wrapper), - holdersCount = countHolders(args, placeholder); - } - if (partials) { - args = composeArgs(args, partials, holders, isCurried); - } - if (partialsRight) { - args = composeArgsRight(args, partialsRight, holdersRight, isCurried); - } - length -= holdersCount; - if (isCurried && length < arity) { - var newHolders = replaceHolders(args, placeholder); - return createRecurry( - func, bitmask, createHybrid, wrapper.placeholder, thisArg, - args, newHolders, argPos, ary, arity - length - ); - } - var thisBinding = isBind ? thisArg : this, - fn = isBindKey ? thisBinding[func] : func; - - length = args.length; - if (argPos) { - args = reorder(args, argPos); - } else if (isFlip && length > 1) { - args.reverse(); - } - if (isAry && ary < length) { - args.length = ary; - } - if (this && this !== root && this instanceof wrapper) { - fn = Ctor || createCtor(fn); - } - return fn.apply(thisBinding, args); - } - return wrapper; - } - - /** - * Creates a function like `_.invertBy`. - * - * @private - * @param {Function} setter The function to set accumulator values. - * @param {Function} toIteratee The function to resolve iteratees. - * @returns {Function} Returns the new inverter function. - */ - function createInverter(setter, toIteratee) { - return function(object, iteratee) { - return baseInverter(object, setter, toIteratee(iteratee), {}); - }; - } - - /** - * Creates a function that performs a mathematical operation on two values. - * - * @private - * @param {Function} operator The function to perform the operation. - * @param {number} [defaultValue] The value used for `undefined` arguments. - * @returns {Function} Returns the new mathematical operation function. - */ - function createMathOperation(operator, defaultValue) { - return function(value, other) { - var result; - if (value === undefined && other === undefined) { - return defaultValue; - } - if (value !== undefined) { - result = value; - } - if (other !== undefined) { - if (result === undefined) { - return other; - } - if (typeof value == 'string' || typeof other == 'string') { - value = baseToString(value); - other = baseToString(other); - } else { - value = baseToNumber(value); - other = baseToNumber(other); - } - result = operator(value, other); - } - return result; - }; - } - - /** - * Creates a function like `_.over`. - * - * @private - * @param {Function} arrayFunc The function to iterate over iteratees. - * @returns {Function} Returns the new over function. - */ - function createOver(arrayFunc) { - return flatRest(function(iteratees) { - iteratees = arrayMap(iteratees, baseUnary(getIteratee())); - return baseRest(function(args) { - var thisArg = this; - return arrayFunc(iteratees, function(iteratee) { - return apply(iteratee, thisArg, args); - }); - }); - }); - } - - /** - * Creates the padding for `string` based on `length`. The `chars` string - * is truncated if the number of characters exceeds `length`. - * - * @private - * @param {number} length The padding length. - * @param {string} [chars=' '] The string used as padding. - * @returns {string} Returns the padding for `string`. - */ - function createPadding(length, chars) { - chars = chars === undefined ? ' ' : baseToString(chars); - - var charsLength = chars.length; - if (charsLength < 2) { - return charsLength ? baseRepeat(chars, length) : chars; - } - var result = baseRepeat(chars, nativeCeil(length / stringSize(chars))); - return hasUnicode(chars) - ? castSlice(stringToArray(result), 0, length).join('') - : result.slice(0, length); - } - - /** - * Creates a function that wraps `func` to invoke it with the `this` binding - * of `thisArg` and `partials` prepended to the arguments it receives. - * - * @private - * @param {Function} func The function to wrap. - * @param {number} bitmask The bitmask flags. See `createWrap` for more details. - * @param {*} thisArg The `this` binding of `func`. - * @param {Array} partials The arguments to prepend to those provided to - * the new function. - * @returns {Function} Returns the new wrapped function. - */ - function createPartial(func, bitmask, thisArg, partials) { - var isBind = bitmask & WRAP_BIND_FLAG, - Ctor = createCtor(func); - - function wrapper() { - var argsIndex = -1, - argsLength = arguments.length, - leftIndex = -1, - leftLength = partials.length, - args = Array(leftLength + argsLength), - fn = (this && this !== root && this instanceof wrapper) ? Ctor : func; - - while (++leftIndex < leftLength) { - args[leftIndex] = partials[leftIndex]; - } - while (argsLength--) { - args[leftIndex++] = arguments[++argsIndex]; - } - return apply(fn, isBind ? thisArg : this, args); - } - return wrapper; - } - - /** - * Creates a `_.range` or `_.rangeRight` function. - * - * @private - * @param {boolean} [fromRight] Specify iterating from right to left. - * @returns {Function} Returns the new range function. - */ - function createRange(fromRight) { - return function(start, end, step) { - if (step && typeof step != 'number' && isIterateeCall(start, end, step)) { - end = step = undefined; - } - // Ensure the sign of `-0` is preserved. - start = toFinite(start); - if (end === undefined) { - end = start; - start = 0; - } else { - end = toFinite(end); - } - step = step === undefined ? (start < end ? 1 : -1) : toFinite(step); - return baseRange(start, end, step, fromRight); - }; - } - - /** - * Creates a function that performs a relational operation on two values. - * - * @private - * @param {Function} operator The function to perform the operation. - * @returns {Function} Returns the new relational operation function. - */ - function createRelationalOperation(operator) { - return function(value, other) { - if (!(typeof value == 'string' && typeof other == 'string')) { - value = toNumber(value); - other = toNumber(other); - } - return operator(value, other); - }; - } - - /** - * Creates a function that wraps `func` to continue currying. - * - * @private - * @param {Function} func The function to wrap. - * @param {number} bitmask The bitmask flags. See `createWrap` for more details. - * @param {Function} wrapFunc The function to create the `func` wrapper. - * @param {*} placeholder The placeholder value. - * @param {*} [thisArg] The `this` binding of `func`. - * @param {Array} [partials] The arguments to prepend to those provided to - * the new function. - * @param {Array} [holders] The `partials` placeholder indexes. - * @param {Array} [argPos] The argument positions of the new function. - * @param {number} [ary] The arity cap of `func`. - * @param {number} [arity] The arity of `func`. - * @returns {Function} Returns the new wrapped function. - */ - function createRecurry(func, bitmask, wrapFunc, placeholder, thisArg, partials, holders, argPos, ary, arity) { - var isCurry = bitmask & WRAP_CURRY_FLAG, - newHolders = isCurry ? holders : undefined, - newHoldersRight = isCurry ? undefined : holders, - newPartials = isCurry ? partials : undefined, - newPartialsRight = isCurry ? undefined : partials; - - bitmask |= (isCurry ? WRAP_PARTIAL_FLAG : WRAP_PARTIAL_RIGHT_FLAG); - bitmask &= ~(isCurry ? WRAP_PARTIAL_RIGHT_FLAG : WRAP_PARTIAL_FLAG); - - if (!(bitmask & WRAP_CURRY_BOUND_FLAG)) { - bitmask &= ~(WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG); - } - var newData = [ - func, bitmask, thisArg, newPartials, newHolders, newPartialsRight, - newHoldersRight, argPos, ary, arity - ]; - - var result = wrapFunc.apply(undefined, newData); - if (isLaziable(func)) { - setData(result, newData); - } - result.placeholder = placeholder; - return setWrapToString(result, func, bitmask); - } - - /** - * Creates a function like `_.round`. - * - * @private - * @param {string} methodName The name of the `Math` method to use when rounding. - * @returns {Function} Returns the new round function. - */ - function createRound(methodName) { - var func = Math[methodName]; - return function(number, precision) { - number = toNumber(number); - precision = precision == null ? 0 : nativeMin(toInteger(precision), 292); - if (precision) { - // Shift with exponential notation to avoid floating-point issues. - // See [MDN](https://mdn.io/round#Examples) for more details. - var pair = (toString(number) + 'e').split('e'), - value = func(pair[0] + 'e' + (+pair[1] + precision)); - - pair = (toString(value) + 'e').split('e'); - return +(pair[0] + 'e' + (+pair[1] - precision)); - } - return func(number); - }; - } - - /** - * Creates a set object of `values`. - * - * @private - * @param {Array} values The values to add to the set. - * @returns {Object} Returns the new set. - */ - var createSet = !(Set && (1 / setToArray(new Set([,-0]))[1]) == INFINITY) ? noop : function(values) { - return new Set(values); - }; - - /** - * Creates a `_.toPairs` or `_.toPairsIn` function. - * - * @private - * @param {Function} keysFunc The function to get the keys of a given object. - * @returns {Function} Returns the new pairs function. - */ - function createToPairs(keysFunc) { - return function(object) { - var tag = getTag(object); - if (tag == mapTag) { - return mapToArray(object); - } - if (tag == setTag) { - return setToPairs(object); - } - return baseToPairs(object, keysFunc(object)); - }; - } - - /** - * Creates a function that either curries or invokes `func` with optional - * `this` binding and partially applied arguments. - * - * @private - * @param {Function|string} func The function or method name to wrap. - * @param {number} bitmask The bitmask flags. - * 1 - `_.bind` - * 2 - `_.bindKey` - * 4 - `_.curry` or `_.curryRight` of a bound function - * 8 - `_.curry` - * 16 - `_.curryRight` - * 32 - `_.partial` - * 64 - `_.partialRight` - * 128 - `_.rearg` - * 256 - `_.ary` - * 512 - `_.flip` - * @param {*} [thisArg] The `this` binding of `func`. - * @param {Array} [partials] The arguments to be partially applied. - * @param {Array} [holders] The `partials` placeholder indexes. - * @param {Array} [argPos] The argument positions of the new function. - * @param {number} [ary] The arity cap of `func`. - * @param {number} [arity] The arity of `func`. - * @returns {Function} Returns the new wrapped function. - */ - function createWrap(func, bitmask, thisArg, partials, holders, argPos, ary, arity) { - var isBindKey = bitmask & WRAP_BIND_KEY_FLAG; - if (!isBindKey && typeof func != 'function') { - throw new TypeError(FUNC_ERROR_TEXT); - } - var length = partials ? partials.length : 0; - if (!length) { - bitmask &= ~(WRAP_PARTIAL_FLAG | WRAP_PARTIAL_RIGHT_FLAG); - partials = holders = undefined; - } - ary = ary === undefined ? ary : nativeMax(toInteger(ary), 0); - arity = arity === undefined ? arity : toInteger(arity); - length -= holders ? holders.length : 0; - - if (bitmask & WRAP_PARTIAL_RIGHT_FLAG) { - var partialsRight = partials, - holdersRight = holders; - - partials = holders = undefined; - } - var data = isBindKey ? undefined : getData(func); - - var newData = [ - func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, - argPos, ary, arity - ]; - - if (data) { - mergeData(newData, data); - } - func = newData[0]; - bitmask = newData[1]; - thisArg = newData[2]; - partials = newData[3]; - holders = newData[4]; - arity = newData[9] = newData[9] === undefined - ? (isBindKey ? 0 : func.length) - : nativeMax(newData[9] - length, 0); - - if (!arity && bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG)) { - bitmask &= ~(WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG); - } - if (!bitmask || bitmask == WRAP_BIND_FLAG) { - var result = createBind(func, bitmask, thisArg); - } else if (bitmask == WRAP_CURRY_FLAG || bitmask == WRAP_CURRY_RIGHT_FLAG) { - result = createCurry(func, bitmask, arity); - } else if ((bitmask == WRAP_PARTIAL_FLAG || bitmask == (WRAP_BIND_FLAG | WRAP_PARTIAL_FLAG)) && !holders.length) { - result = createPartial(func, bitmask, thisArg, partials); - } else { - result = createHybrid.apply(undefined, newData); - } - var setter = data ? baseSetData : setData; - return setWrapToString(setter(result, newData), func, bitmask); - } - - /** - * Used by `_.defaults` to customize its `_.assignIn` use to assign properties - * of source objects to the destination object for all destination properties - * that resolve to `undefined`. - * - * @private - * @param {*} objValue The destination value. - * @param {*} srcValue The source value. - * @param {string} key The key of the property to assign. - * @param {Object} object The parent object of `objValue`. - * @returns {*} Returns the value to assign. - */ - function customDefaultsAssignIn(objValue, srcValue, key, object) { - if (objValue === undefined || - (eq(objValue, objectProto[key]) && !hasOwnProperty.call(object, key))) { - return srcValue; - } - return objValue; - } - - /** - * Used by `_.defaultsDeep` to customize its `_.merge` use to merge source - * objects into destination objects that are passed thru. - * - * @private - * @param {*} objValue The destination value. - * @param {*} srcValue The source value. - * @param {string} key The key of the property to merge. - * @param {Object} object The parent object of `objValue`. - * @param {Object} source The parent object of `srcValue`. - * @param {Object} [stack] Tracks traversed source values and their merged - * counterparts. - * @returns {*} Returns the value to assign. - */ - function customDefaultsMerge(objValue, srcValue, key, object, source, stack) { - if (isObject(objValue) && isObject(srcValue)) { - // Recursively merge objects and arrays (susceptible to call stack limits). - stack.set(srcValue, objValue); - baseMerge(objValue, srcValue, undefined, customDefaultsMerge, stack); - stack['delete'](srcValue); - } - return objValue; - } - - /** - * Used by `_.omit` to customize its `_.cloneDeep` use to only clone plain - * objects. - * - * @private - * @param {*} value The value to inspect. - * @param {string} key The key of the property to inspect. - * @returns {*} Returns the uncloned value or `undefined` to defer cloning to `_.cloneDeep`. - */ - function customOmitClone(value) { - return isPlainObject(value) ? undefined : value; - } - - /** - * A specialized version of `baseIsEqualDeep` for arrays with support for - * partial deep comparisons. - * - * @private - * @param {Array} array The array to compare. - * @param {Array} other The other array to compare. - * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. - * @param {Function} customizer The function to customize comparisons. - * @param {Function} equalFunc The function to determine equivalents of values. - * @param {Object} stack Tracks traversed `array` and `other` objects. - * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`. - */ - function equalArrays(array, other, bitmask, customizer, equalFunc, stack) { - var isPartial = bitmask & COMPARE_PARTIAL_FLAG, - arrLength = array.length, - othLength = other.length; - - if (arrLength != othLength && !(isPartial && othLength > arrLength)) { - return false; - } - // Assume cyclic values are equal. - var stacked = stack.get(array); - if (stacked && stack.get(other)) { - return stacked == other; - } - var index = -1, - result = true, - seen = (bitmask & COMPARE_UNORDERED_FLAG) ? new SetCache : undefined; - - stack.set(array, other); - stack.set(other, array); - - // Ignore non-index properties. - while (++index < arrLength) { - var arrValue = array[index], - othValue = other[index]; - - if (customizer) { - var compared = isPartial - ? customizer(othValue, arrValue, index, other, array, stack) - : customizer(arrValue, othValue, index, array, other, stack); - } - if (compared !== undefined) { - if (compared) { - continue; - } - result = false; - break; - } - // Recursively compare arrays (susceptible to call stack limits). - if (seen) { - if (!arraySome(other, function(othValue, othIndex) { - if (!cacheHas(seen, othIndex) && - (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) { - return seen.push(othIndex); - } - })) { - result = false; - break; - } - } else if (!( - arrValue === othValue || - equalFunc(arrValue, othValue, bitmask, customizer, stack) - )) { - result = false; - break; - } - } - stack['delete'](array); - stack['delete'](other); - return result; - } - - /** - * A specialized version of `baseIsEqualDeep` for comparing objects of - * the same `toStringTag`. - * - * **Note:** This function only supports comparing values with tags of - * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`. - * - * @private - * @param {Object} object The object to compare. - * @param {Object} other The other object to compare. - * @param {string} tag The `toStringTag` of the objects to compare. - * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. - * @param {Function} customizer The function to customize comparisons. - * @param {Function} equalFunc The function to determine equivalents of values. - * @param {Object} stack Tracks traversed `object` and `other` objects. - * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. - */ - function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) { - switch (tag) { - case dataViewTag: - if ((object.byteLength != other.byteLength) || - (object.byteOffset != other.byteOffset)) { - return false; - } - object = object.buffer; - other = other.buffer; - - case arrayBufferTag: - if ((object.byteLength != other.byteLength) || - !equalFunc(new Uint8Array(object), new Uint8Array(other))) { - return false; - } - return true; - - case boolTag: - case dateTag: - case numberTag: - // Coerce booleans to `1` or `0` and dates to milliseconds. - // Invalid dates are coerced to `NaN`. - return eq(+object, +other); - - case errorTag: - return object.name == other.name && object.message == other.message; - - case regexpTag: - case stringTag: - // Coerce regexes to strings and treat strings, primitives and objects, - // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring - // for more details. - return object == (other + ''); - - case mapTag: - var convert = mapToArray; - - case setTag: - var isPartial = bitmask & COMPARE_PARTIAL_FLAG; - convert || (convert = setToArray); - - if (object.size != other.size && !isPartial) { - return false; - } - // Assume cyclic values are equal. - var stacked = stack.get(object); - if (stacked) { - return stacked == other; - } - bitmask |= COMPARE_UNORDERED_FLAG; - - // Recursively compare objects (susceptible to call stack limits). - stack.set(object, other); - var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack); - stack['delete'](object); - return result; - - case symbolTag: - if (symbolValueOf) { - return symbolValueOf.call(object) == symbolValueOf.call(other); - } - } - return false; - } - - /** - * A specialized version of `baseIsEqualDeep` for objects with support for - * partial deep comparisons. - * - * @private - * @param {Object} object The object to compare. - * @param {Object} other The other object to compare. - * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. - * @param {Function} customizer The function to customize comparisons. - * @param {Function} equalFunc The function to determine equivalents of values. - * @param {Object} stack Tracks traversed `object` and `other` objects. - * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. - */ - function equalObjects(object, other, bitmask, customizer, equalFunc, stack) { - var isPartial = bitmask & COMPARE_PARTIAL_FLAG, - objProps = getAllKeys(object), - objLength = objProps.length, - othProps = getAllKeys(other), - othLength = othProps.length; - - if (objLength != othLength && !isPartial) { - return false; - } - var index = objLength; - while (index--) { - var key = objProps[index]; - if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) { - return false; - } - } - // Assume cyclic values are equal. - var stacked = stack.get(object); - if (stacked && stack.get(other)) { - return stacked == other; - } - var result = true; - stack.set(object, other); - stack.set(other, object); - - var skipCtor = isPartial; - while (++index < objLength) { - key = objProps[index]; - var objValue = object[key], - othValue = other[key]; - - if (customizer) { - var compared = isPartial - ? customizer(othValue, objValue, key, other, object, stack) - : customizer(objValue, othValue, key, object, other, stack); - } - // Recursively compare objects (susceptible to call stack limits). - if (!(compared === undefined - ? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack)) - : compared - )) { - result = false; - break; - } - skipCtor || (skipCtor = key == 'constructor'); - } - if (result && !skipCtor) { - var objCtor = object.constructor, - othCtor = other.constructor; - - // Non `Object` object instances with different constructors are not equal. - if (objCtor != othCtor && - ('constructor' in object && 'constructor' in other) && - !(typeof objCtor == 'function' && objCtor instanceof objCtor && - typeof othCtor == 'function' && othCtor instanceof othCtor)) { - result = false; - } - } - stack['delete'](object); - stack['delete'](other); - return result; - } - - /** - * A specialized version of `baseRest` which flattens the rest array. - * - * @private - * @param {Function} func The function to apply a rest parameter to. - * @returns {Function} Returns the new function. - */ - function flatRest(func) { - return setToString(overRest(func, undefined, flatten), func + ''); - } - - /** - * Creates an array of own enumerable property names and symbols of `object`. - * - * @private - * @param {Object} object The object to query. - * @returns {Array} Returns the array of property names and symbols. - */ - function getAllKeys(object) { - return baseGetAllKeys(object, keys, getSymbols); - } - - /** - * Creates an array of own and inherited enumerable property names and - * symbols of `object`. - * - * @private - * @param {Object} object The object to query. - * @returns {Array} Returns the array of property names and symbols. - */ - function getAllKeysIn(object) { - return baseGetAllKeys(object, keysIn, getSymbolsIn); - } - - /** - * Gets metadata for `func`. - * - * @private - * @param {Function} func The function to query. - * @returns {*} Returns the metadata for `func`. - */ - var getData = !metaMap ? noop : function(func) { - return metaMap.get(func); - }; - - /** - * Gets the name of `func`. - * - * @private - * @param {Function} func The function to query. - * @returns {string} Returns the function name. - */ - function getFuncName(func) { - var result = (func.name + ''), - array = realNames[result], - length = hasOwnProperty.call(realNames, result) ? array.length : 0; - - while (length--) { - var data = array[length], - otherFunc = data.func; - if (otherFunc == null || otherFunc == func) { - return data.name; - } - } - return result; - } - - /** - * Gets the argument placeholder value for `func`. - * - * @private - * @param {Function} func The function to inspect. - * @returns {*} Returns the placeholder value. - */ - function getHolder(func) { - var object = hasOwnProperty.call(lodash, 'placeholder') ? lodash : func; - return object.placeholder; - } - - /** - * Gets the appropriate "iteratee" function. If `_.iteratee` is customized, - * this function returns the custom method, otherwise it returns `baseIteratee`. - * If arguments are provided, the chosen function is invoked with them and - * its result is returned. - * - * @private - * @param {*} [value] The value to convert to an iteratee. - * @param {number} [arity] The arity of the created iteratee. - * @returns {Function} Returns the chosen function or its result. - */ - function getIteratee() { - var result = lodash.iteratee || iteratee; - result = result === iteratee ? baseIteratee : result; - return arguments.length ? result(arguments[0], arguments[1]) : result; - } - - /** - * Gets the data for `map`. - * - * @private - * @param {Object} map The map to query. - * @param {string} key The reference key. - * @returns {*} Returns the map data. - */ - function getMapData(map, key) { - var data = map.__data__; - return isKeyable(key) - ? data[typeof key == 'string' ? 'string' : 'hash'] - : data.map; - } - - /** - * Gets the property names, values, and compare flags of `object`. - * - * @private - * @param {Object} object The object to query. - * @returns {Array} Returns the match data of `object`. - */ - function getMatchData(object) { - var result = keys(object), - length = result.length; - - while (length--) { - var key = result[length], - value = object[key]; - - result[length] = [key, value, isStrictComparable(value)]; - } - return result; - } - - /** - * Gets the native function at `key` of `object`. - * - * @private - * @param {Object} object The object to query. - * @param {string} key The key of the method to get. - * @returns {*} Returns the function if it's native, else `undefined`. - */ - function getNative(object, key) { - var value = getValue(object, key); - return baseIsNative(value) ? value : undefined; - } - - /** - * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values. - * - * @private - * @param {*} value The value to query. - * @returns {string} Returns the raw `toStringTag`. - */ - function getRawTag(value) { - var isOwn = hasOwnProperty.call(value, symToStringTag), - tag = value[symToStringTag]; - - try { - value[symToStringTag] = undefined; - var unmasked = true; - } catch (e) {} - - var result = nativeObjectToString.call(value); - if (unmasked) { - if (isOwn) { - value[symToStringTag] = tag; - } else { - delete value[symToStringTag]; - } - } - return result; - } - - /** - * Creates an array of the own enumerable symbols of `object`. - * - * @private - * @param {Object} object The object to query. - * @returns {Array} Returns the array of symbols. - */ - var getSymbols = !nativeGetSymbols ? stubArray : function(object) { - if (object == null) { - return []; - } - object = Object(object); - return arrayFilter(nativeGetSymbols(object), function(symbol) { - return propertyIsEnumerable.call(object, symbol); - }); - }; - - /** - * Creates an array of the own and inherited enumerable symbols of `object`. - * - * @private - * @param {Object} object The object to query. - * @returns {Array} Returns the array of symbols. - */ - var getSymbolsIn = !nativeGetSymbols ? stubArray : function(object) { - var result = []; - while (object) { - arrayPush(result, getSymbols(object)); - object = getPrototype(object); - } - return result; - }; - - /** - * Gets the `toStringTag` of `value`. - * - * @private - * @param {*} value The value to query. - * @returns {string} Returns the `toStringTag`. - */ - var getTag = baseGetTag; - - // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6. - if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) || - (Map && getTag(new Map) != mapTag) || - (Promise && getTag(Promise.resolve()) != promiseTag) || - (Set && getTag(new Set) != setTag) || - (WeakMap && getTag(new WeakMap) != weakMapTag)) { - getTag = function(value) { - var result = baseGetTag(value), - Ctor = result == objectTag ? value.constructor : undefined, - ctorString = Ctor ? toSource(Ctor) : ''; - - if (ctorString) { - switch (ctorString) { - case dataViewCtorString: return dataViewTag; - case mapCtorString: return mapTag; - case promiseCtorString: return promiseTag; - case setCtorString: return setTag; - case weakMapCtorString: return weakMapTag; - } - } - return result; - }; - } - - /** - * Gets the view, applying any `transforms` to the `start` and `end` positions. - * - * @private - * @param {number} start The start of the view. - * @param {number} end The end of the view. - * @param {Array} transforms The transformations to apply to the view. - * @returns {Object} Returns an object containing the `start` and `end` - * positions of the view. - */ - function getView(start, end, transforms) { - var index = -1, - length = transforms.length; - - while (++index < length) { - var data = transforms[index], - size = data.size; - - switch (data.type) { - case 'drop': start += size; break; - case 'dropRight': end -= size; break; - case 'take': end = nativeMin(end, start + size); break; - case 'takeRight': start = nativeMax(start, end - size); break; - } - } - return { 'start': start, 'end': end }; - } - - /** - * Extracts wrapper details from the `source` body comment. - * - * @private - * @param {string} source The source to inspect. - * @returns {Array} Returns the wrapper details. - */ - function getWrapDetails(source) { - var match = source.match(reWrapDetails); - return match ? match[1].split(reSplitDetails) : []; - } - - /** - * Checks if `path` exists on `object`. - * - * @private - * @param {Object} object The object to query. - * @param {Array|string} path The path to check. - * @param {Function} hasFunc The function to check properties. - * @returns {boolean} Returns `true` if `path` exists, else `false`. - */ - function hasPath(object, path, hasFunc) { - path = castPath(path, object); - - var index = -1, - length = path.length, - result = false; - - while (++index < length) { - var key = toKey(path[index]); - if (!(result = object != null && hasFunc(object, key))) { - break; - } - object = object[key]; - } - if (result || ++index != length) { - return result; - } - length = object == null ? 0 : object.length; - return !!length && isLength(length) && isIndex(key, length) && - (isArray(object) || isArguments(object)); - } - - /** - * Initializes an array clone. - * - * @private - * @param {Array} array The array to clone. - * @returns {Array} Returns the initialized clone. - */ - function initCloneArray(array) { - var length = array.length, - result = array.constructor(length); - - // Add properties assigned by `RegExp#exec`. - if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) { - result.index = array.index; - result.input = array.input; - } - return result; - } - - /** - * Initializes an object clone. - * - * @private - * @param {Object} object The object to clone. - * @returns {Object} Returns the initialized clone. - */ - function initCloneObject(object) { - return (typeof object.constructor == 'function' && !isPrototype(object)) - ? baseCreate(getPrototype(object)) - : {}; - } - - /** - * Initializes an object clone based on its `toStringTag`. - * - * **Note:** This function only supports cloning values with tags of - * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`. - * - * @private - * @param {Object} object The object to clone. - * @param {string} tag The `toStringTag` of the object to clone. - * @param {Function} cloneFunc The function to clone values. - * @param {boolean} [isDeep] Specify a deep clone. - * @returns {Object} Returns the initialized clone. - */ - function initCloneByTag(object, tag, cloneFunc, isDeep) { - var Ctor = object.constructor; - switch (tag) { - case arrayBufferTag: - return cloneArrayBuffer(object); - - case boolTag: - case dateTag: - return new Ctor(+object); - - case dataViewTag: - return cloneDataView(object, isDeep); - - case float32Tag: case float64Tag: - case int8Tag: case int16Tag: case int32Tag: - case uint8Tag: case uint8ClampedTag: case uint16Tag: case uint32Tag: - return cloneTypedArray(object, isDeep); - - case mapTag: - return cloneMap(object, isDeep, cloneFunc); - - case numberTag: - case stringTag: - return new Ctor(object); - - case regexpTag: - return cloneRegExp(object); - - case setTag: - return cloneSet(object, isDeep, cloneFunc); - - case symbolTag: - return cloneSymbol(object); - } - } - - /** - * Inserts wrapper `details` in a comment at the top of the `source` body. - * - * @private - * @param {string} source The source to modify. - * @returns {Array} details The details to insert. - * @returns {string} Returns the modified source. - */ - function insertWrapDetails(source, details) { - var length = details.length; - if (!length) { - return source; - } - var lastIndex = length - 1; - details[lastIndex] = (length > 1 ? '& ' : '') + details[lastIndex]; - details = details.join(length > 2 ? ', ' : ' '); - return source.replace(reWrapComment, '{\n/* [wrapped with ' + details + '] */\n'); - } - - /** - * Checks if `value` is a flattenable `arguments` object or array. - * - * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is flattenable, else `false`. - */ - function isFlattenable(value) { - return isArray(value) || isArguments(value) || - !!(spreadableSymbol && value && value[spreadableSymbol]); - } - - /** - * Checks if `value` is a valid array-like index. - * - * @private - * @param {*} value The value to check. - * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index. - * @returns {boolean} Returns `true` if `value` is a valid index, else `false`. - */ - function isIndex(value, length) { - length = length == null ? MAX_SAFE_INTEGER : length; - return !!length && - (typeof value == 'number' || reIsUint.test(value)) && - (value > -1 && value % 1 == 0 && value < length); - } - - /** - * Checks if the given arguments are from an iteratee call. - * - * @private - * @param {*} value The potential iteratee value argument. - * @param {*} index The potential iteratee index or key argument. - * @param {*} object The potential iteratee object argument. - * @returns {boolean} Returns `true` if the arguments are from an iteratee call, - * else `false`. - */ - function isIterateeCall(value, index, object) { - if (!isObject(object)) { - return false; - } - var type = typeof index; - if (type == 'number' - ? (isArrayLike(object) && isIndex(index, object.length)) - : (type == 'string' && index in object) - ) { - return eq(object[index], value); - } - return false; - } - - /** - * Checks if `value` is a property name and not a property path. - * - * @private - * @param {*} value The value to check. - * @param {Object} [object] The object to query keys on. - * @returns {boolean} Returns `true` if `value` is a property name, else `false`. - */ - function isKey(value, object) { - if (isArray(value)) { - return false; - } - var type = typeof value; - if (type == 'number' || type == 'symbol' || type == 'boolean' || - value == null || isSymbol(value)) { - return true; - } - return reIsPlainProp.test(value) || !reIsDeepProp.test(value) || - (object != null && value in Object(object)); - } - - /** - * Checks if `value` is suitable for use as unique object key. - * - * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is suitable, else `false`. - */ - function isKeyable(value) { - var type = typeof value; - return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean') - ? (value !== '__proto__') - : (value === null); - } - - /** - * Checks if `func` has a lazy counterpart. - * - * @private - * @param {Function} func The function to check. - * @returns {boolean} Returns `true` if `func` has a lazy counterpart, - * else `false`. - */ - function isLaziable(func) { - var funcName = getFuncName(func), - other = lodash[funcName]; - - if (typeof other != 'function' || !(funcName in LazyWrapper.prototype)) { - return false; - } - if (func === other) { - return true; - } - var data = getData(other); - return !!data && func === data[0]; - } - - /** - * Checks if `func` has its source masked. - * - * @private - * @param {Function} func The function to check. - * @returns {boolean} Returns `true` if `func` is masked, else `false`. - */ - function isMasked(func) { - return !!maskSrcKey && (maskSrcKey in func); - } - - /** - * Checks if `func` is capable of being masked. - * - * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `func` is maskable, else `false`. - */ - var isMaskable = coreJsData ? isFunction : stubFalse; - - /** - * Checks if `value` is likely a prototype object. - * - * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a prototype, else `false`. - */ - function isPrototype(value) { - var Ctor = value && value.constructor, - proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto; - - return value === proto; - } - - /** - * Checks if `value` is suitable for strict equality comparisons, i.e. `===`. - * - * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` if suitable for strict - * equality comparisons, else `false`. - */ - function isStrictComparable(value) { - return value === value && !isObject(value); - } - - /** - * A specialized version of `matchesProperty` for source values suitable - * for strict equality comparisons, i.e. `===`. - * - * @private - * @param {string} key The key of the property to get. - * @param {*} srcValue The value to match. - * @returns {Function} Returns the new spec function. - */ - function matchesStrictComparable(key, srcValue) { - return function(object) { - if (object == null) { - return false; - } - return object[key] === srcValue && - (srcValue !== undefined || (key in Object(object))); - }; - } - - /** - * A specialized version of `_.memoize` which clears the memoized function's - * cache when it exceeds `MAX_MEMOIZE_SIZE`. - * - * @private - * @param {Function} func The function to have its output memoized. - * @returns {Function} Returns the new memoized function. - */ - function memoizeCapped(func) { - var result = memoize(func, function(key) { - if (cache.size === MAX_MEMOIZE_SIZE) { - cache.clear(); - } - return key; - }); - - var cache = result.cache; - return result; - } - - /** - * Merges the function metadata of `source` into `data`. - * - * Merging metadata reduces the number of wrappers used to invoke a function. - * This is possible because methods like `_.bind`, `_.curry`, and `_.partial` - * may be applied regardless of execution order. Methods like `_.ary` and - * `_.rearg` modify function arguments, making the order in which they are - * executed important, preventing the merging of metadata. However, we make - * an exception for a safe combined case where curried functions have `_.ary` - * and or `_.rearg` applied. - * - * @private - * @param {Array} data The destination metadata. - * @param {Array} source The source metadata. - * @returns {Array} Returns `data`. - */ - function mergeData(data, source) { - var bitmask = data[1], - srcBitmask = source[1], - newBitmask = bitmask | srcBitmask, - isCommon = newBitmask < (WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG | WRAP_ARY_FLAG); - - var isCombo = - ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_CURRY_FLAG)) || - ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_REARG_FLAG) && (data[7].length <= source[8])) || - ((srcBitmask == (WRAP_ARY_FLAG | WRAP_REARG_FLAG)) && (source[7].length <= source[8]) && (bitmask == WRAP_CURRY_FLAG)); - - // Exit early if metadata can't be merged. - if (!(isCommon || isCombo)) { - return data; - } - // Use source `thisArg` if available. - if (srcBitmask & WRAP_BIND_FLAG) { - data[2] = source[2]; - // Set when currying a bound function. - newBitmask |= bitmask & WRAP_BIND_FLAG ? 0 : WRAP_CURRY_BOUND_FLAG; - } - // Compose partial arguments. - var value = source[3]; - if (value) { - var partials = data[3]; - data[3] = partials ? composeArgs(partials, value, source[4]) : value; - data[4] = partials ? replaceHolders(data[3], PLACEHOLDER) : source[4]; - } - // Compose partial right arguments. - value = source[5]; - if (value) { - partials = data[5]; - data[5] = partials ? composeArgsRight(partials, value, source[6]) : value; - data[6] = partials ? replaceHolders(data[5], PLACEHOLDER) : source[6]; - } - // Use source `argPos` if available. - value = source[7]; - if (value) { - data[7] = value; - } - // Use source `ary` if it's smaller. - if (srcBitmask & WRAP_ARY_FLAG) { - data[8] = data[8] == null ? source[8] : nativeMin(data[8], source[8]); - } - // Use source `arity` if one is not provided. - if (data[9] == null) { - data[9] = source[9]; - } - // Use source `func` and merge bitmasks. - data[0] = source[0]; - data[1] = newBitmask; - - return data; - } - - /** - * This function is like - * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys) - * except that it includes inherited enumerable properties. - * - * @private - * @param {Object} object The object to query. - * @returns {Array} Returns the array of property names. - */ - function nativeKeysIn(object) { - var result = []; - if (object != null) { - for (var key in Object(object)) { - result.push(key); - } - } - return result; - } - - /** - * Converts `value` to a string using `Object.prototype.toString`. - * - * @private - * @param {*} value The value to convert. - * @returns {string} Returns the converted string. - */ - function objectToString(value) { - return nativeObjectToString.call(value); - } - - /** - * A specialized version of `baseRest` which transforms the rest array. - * - * @private - * @param {Function} func The function to apply a rest parameter to. - * @param {number} [start=func.length-1] The start position of the rest parameter. - * @param {Function} transform The rest array transform. - * @returns {Function} Returns the new function. - */ - function overRest(func, start, transform) { - start = nativeMax(start === undefined ? (func.length - 1) : start, 0); - return function() { - var args = arguments, - index = -1, - length = nativeMax(args.length - start, 0), - array = Array(length); - - while (++index < length) { - array[index] = args[start + index]; - } - index = -1; - var otherArgs = Array(start + 1); - while (++index < start) { - otherArgs[index] = args[index]; - } - otherArgs[start] = transform(array); - return apply(func, this, otherArgs); - }; - } - - /** - * Gets the parent value at `path` of `object`. - * - * @private - * @param {Object} object The object to query. - * @param {Array} path The path to get the parent value of. - * @returns {*} Returns the parent value. - */ - function parent(object, path) { - return path.length < 2 ? object : baseGet(object, baseSlice(path, 0, -1)); - } - - /** - * Reorder `array` according to the specified indexes where the element at - * the first index is assigned as the first element, the element at - * the second index is assigned as the second element, and so on. - * - * @private - * @param {Array} array The array to reorder. - * @param {Array} indexes The arranged array indexes. - * @returns {Array} Returns `array`. - */ - function reorder(array, indexes) { - var arrLength = array.length, - length = nativeMin(indexes.length, arrLength), - oldArray = copyArray(array); - - while (length--) { - var index = indexes[length]; - array[length] = isIndex(index, arrLength) ? oldArray[index] : undefined; - } - return array; - } - - /** - * Sets metadata for `func`. - * - * **Note:** If this function becomes hot, i.e. is invoked a lot in a short - * period of time, it will trip its breaker and transition to an identity - * function to avoid garbage collection pauses in V8. See - * [V8 issue 2070](https://bugs.chromium.org/p/v8/issues/detail?id=2070) - * for more details. - * - * @private - * @param {Function} func The function to associate metadata with. - * @param {*} data The metadata. - * @returns {Function} Returns `func`. - */ - var setData = shortOut(baseSetData); - - /** - * A simple wrapper around the global [`setTimeout`](https://mdn.io/setTimeout). - * - * @private - * @param {Function} func The function to delay. - * @param {number} wait The number of milliseconds to delay invocation. - * @returns {number|Object} Returns the timer id or timeout object. - */ - var setTimeout = ctxSetTimeout || function(func, wait) { - return root.setTimeout(func, wait); - }; - - /** - * Sets the `toString` method of `func` to return `string`. - * - * @private - * @param {Function} func The function to modify. - * @param {Function} string The `toString` result. - * @returns {Function} Returns `func`. - */ - var setToString = shortOut(baseSetToString); - - /** - * Sets the `toString` method of `wrapper` to mimic the source of `reference` - * with wrapper details in a comment at the top of the source body. - * - * @private - * @param {Function} wrapper The function to modify. - * @param {Function} reference The reference function. - * @param {number} bitmask The bitmask flags. See `createWrap` for more details. - * @returns {Function} Returns `wrapper`. - */ - function setWrapToString(wrapper, reference, bitmask) { - var source = (reference + ''); - return setToString(wrapper, insertWrapDetails(source, updateWrapDetails(getWrapDetails(source), bitmask))); - } - - /** - * Creates a function that'll short out and invoke `identity` instead - * of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN` - * milliseconds. - * - * @private - * @param {Function} func The function to restrict. - * @returns {Function} Returns the new shortable function. - */ - function shortOut(func) { - var count = 0, - lastCalled = 0; - - return function() { - var stamp = nativeNow(), - remaining = HOT_SPAN - (stamp - lastCalled); - - lastCalled = stamp; - if (remaining > 0) { - if (++count >= HOT_COUNT) { - return arguments[0]; - } - } else { - count = 0; - } - return func.apply(undefined, arguments); - }; - } - - /** - * A specialized version of `_.shuffle` which mutates and sets the size of `array`. - * - * @private - * @param {Array} array The array to shuffle. - * @param {number} [size=array.length] The size of `array`. - * @returns {Array} Returns `array`. - */ - function shuffleSelf(array, size) { - var index = -1, - length = array.length, - lastIndex = length - 1; - - size = size === undefined ? length : size; - while (++index < size) { - var rand = baseRandom(index, lastIndex), - value = array[rand]; - - array[rand] = array[index]; - array[index] = value; - } - array.length = size; - return array; - } - - /** - * Converts `string` to a property path array. - * - * @private - * @param {string} string The string to convert. - * @returns {Array} Returns the property path array. - */ - var stringToPath = memoizeCapped(function(string) { - var result = []; - if (reLeadingDot.test(string)) { - result.push(''); - } - string.replace(rePropName, function(match, number, quote, string) { - result.push(quote ? string.replace(reEscapeChar, '$1') : (number || match)); - }); - return result; - }); - - /** - * Converts `value` to a string key if it's not a string or symbol. - * - * @private - * @param {*} value The value to inspect. - * @returns {string|symbol} Returns the key. - */ - function toKey(value) { - if (typeof value == 'string' || isSymbol(value)) { - return value; - } - var result = (value + ''); - return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result; - } - - /** - * Converts `func` to its source code. - * - * @private - * @param {Function} func The function to convert. - * @returns {string} Returns the source code. - */ - function toSource(func) { - if (func != null) { - try { - return funcToString.call(func); - } catch (e) {} - try { - return (func + ''); - } catch (e) {} - } - return ''; - } - - /** - * Updates wrapper `details` based on `bitmask` flags. - * - * @private - * @returns {Array} details The details to modify. - * @param {number} bitmask The bitmask flags. See `createWrap` for more details. - * @returns {Array} Returns `details`. - */ - function updateWrapDetails(details, bitmask) { - arrayEach(wrapFlags, function(pair) { - var value = '_.' + pair[0]; - if ((bitmask & pair[1]) && !arrayIncludes(details, value)) { - details.push(value); - } - }); - return details.sort(); - } - - /** - * Creates a clone of `wrapper`. - * - * @private - * @param {Object} wrapper The wrapper to clone. - * @returns {Object} Returns the cloned wrapper. - */ - function wrapperClone(wrapper) { - if (wrapper instanceof LazyWrapper) { - return wrapper.clone(); - } - var result = new LodashWrapper(wrapper.__wrapped__, wrapper.__chain__); - result.__actions__ = copyArray(wrapper.__actions__); - result.__index__ = wrapper.__index__; - result.__values__ = wrapper.__values__; - return result; - } - - /*------------------------------------------------------------------------*/ - - /** - * Creates an array of elements split into groups the length of `size`. - * If `array` can't be split evenly, the final chunk will be the remaining - * elements. - * - * @static - * @memberOf _ - * @since 3.0.0 - * @category Array - * @param {Array} array The array to process. - * @param {number} [size=1] The length of each chunk - * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. - * @returns {Array} Returns the new array of chunks. - * @example - * - * _.chunk(['a', 'b', 'c', 'd'], 2); - * // => [['a', 'b'], ['c', 'd']] - * - * _.chunk(['a', 'b', 'c', 'd'], 3); - * // => [['a', 'b', 'c'], ['d']] - */ - function chunk(array, size, guard) { - if ((guard ? isIterateeCall(array, size, guard) : size === undefined)) { - size = 1; - } else { - size = nativeMax(toInteger(size), 0); - } - var length = array == null ? 0 : array.length; - if (!length || size < 1) { - return []; - } - var index = 0, - resIndex = 0, - result = Array(nativeCeil(length / size)); - - while (index < length) { - result[resIndex++] = baseSlice(array, index, (index += size)); - } - return result; - } - - /** - * Creates an array with all falsey values removed. The values `false`, `null`, - * `0`, `""`, `undefined`, and `NaN` are falsey. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Array - * @param {Array} array The array to compact. - * @returns {Array} Returns the new array of filtered values. - * @example - * - * _.compact([0, 1, false, 2, '', 3]); - * // => [1, 2, 3] - */ - function compact(array) { - var index = -1, - length = array == null ? 0 : array.length, - resIndex = 0, - result = []; - - while (++index < length) { - var value = array[index]; - if (value) { - result[resIndex++] = value; - } - } - return result; - } - - /** - * Creates a new array concatenating `array` with any additional arrays - * and/or values. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Array - * @param {Array} array The array to concatenate. - * @param {...*} [values] The values to concatenate. - * @returns {Array} Returns the new concatenated array. - * @example - * - * var array = [1]; - * var other = _.concat(array, 2, [3], [[4]]); - * - * console.log(other); - * // => [1, 2, 3, [4]] - * - * console.log(array); - * // => [1] - */ - function concat() { - var length = arguments.length; - if (!length) { - return []; - } - var args = Array(length - 1), - array = arguments[0], - index = length; - - while (index--) { - args[index - 1] = arguments[index]; - } - return arrayPush(isArray(array) ? copyArray(array) : [array], baseFlatten(args, 1)); - } - - /** - * Creates an array of `array` values not included in the other given arrays - * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) - * for equality comparisons. The order and references of result values are - * determined by the first array. - * - * **Note:** Unlike `_.pullAll`, this method returns a new array. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Array - * @param {Array} array The array to inspect. - * @param {...Array} [values] The values to exclude. - * @returns {Array} Returns the new array of filtered values. - * @see _.without, _.xor - * @example - * - * _.difference([2, 1], [2, 3]); - * // => [1] - */ - var difference = baseRest(function(array, values) { - return isArrayLikeObject(array) - ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true)) - : []; - }); - - /** - * This method is like `_.difference` except that it accepts `iteratee` which - * is invoked for each element of `array` and `values` to generate the criterion - * by which they're compared. The order and references of result values are - * determined by the first array. The iteratee is invoked with one argument: - * (value). - * - * **Note:** Unlike `_.pullAllBy`, this method returns a new array. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Array - * @param {Array} array The array to inspect. - * @param {...Array} [values] The values to exclude. - * @param {Function} [iteratee=_.identity] The iteratee invoked per element. - * @returns {Array} Returns the new array of filtered values. - * @example - * - * _.differenceBy([2.1, 1.2], [2.3, 3.4], Math.floor); - * // => [1.2] - * - * // The `_.property` iteratee shorthand. - * _.differenceBy([{ 'x': 2 }, { 'x': 1 }], [{ 'x': 1 }], 'x'); - * // => [{ 'x': 2 }] - */ - var differenceBy = baseRest(function(array, values) { - var iteratee = last(values); - if (isArrayLikeObject(iteratee)) { - iteratee = undefined; - } - return isArrayLikeObject(array) - ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), getIteratee(iteratee, 2)) - : []; - }); - - /** - * This method is like `_.difference` except that it accepts `comparator` - * which is invoked to compare elements of `array` to `values`. The order and - * references of result values are determined by the first array. The comparator - * is invoked with two arguments: (arrVal, othVal). - * - * **Note:** Unlike `_.pullAllWith`, this method returns a new array. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Array - * @param {Array} array The array to inspect. - * @param {...Array} [values] The values to exclude. - * @param {Function} [comparator] The comparator invoked per element. - * @returns {Array} Returns the new array of filtered values. - * @example - * - * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]; - * - * _.differenceWith(objects, [{ 'x': 1, 'y': 2 }], _.isEqual); - * // => [{ 'x': 2, 'y': 1 }] - */ - var differenceWith = baseRest(function(array, values) { - var comparator = last(values); - if (isArrayLikeObject(comparator)) { - comparator = undefined; - } - return isArrayLikeObject(array) - ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), undefined, comparator) - : []; - }); - - /** - * Creates a slice of `array` with `n` elements dropped from the beginning. - * - * @static - * @memberOf _ - * @since 0.5.0 - * @category Array - * @param {Array} array The array to query. - * @param {number} [n=1] The number of elements to drop. - * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. - * @returns {Array} Returns the slice of `array`. - * @example - * - * _.drop([1, 2, 3]); - * // => [2, 3] - * - * _.drop([1, 2, 3], 2); - * // => [3] - * - * _.drop([1, 2, 3], 5); - * // => [] - * - * _.drop([1, 2, 3], 0); - * // => [1, 2, 3] - */ - function drop(array, n, guard) { - var length = array == null ? 0 : array.length; - if (!length) { - return []; - } - n = (guard || n === undefined) ? 1 : toInteger(n); - return baseSlice(array, n < 0 ? 0 : n, length); - } - - /** - * Creates a slice of `array` with `n` elements dropped from the end. - * - * @static - * @memberOf _ - * @since 3.0.0 - * @category Array - * @param {Array} array The array to query. - * @param {number} [n=1] The number of elements to drop. - * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. - * @returns {Array} Returns the slice of `array`. - * @example - * - * _.dropRight([1, 2, 3]); - * // => [1, 2] - * - * _.dropRight([1, 2, 3], 2); - * // => [1] - * - * _.dropRight([1, 2, 3], 5); - * // => [] - * - * _.dropRight([1, 2, 3], 0); - * // => [1, 2, 3] - */ - function dropRight(array, n, guard) { - var length = array == null ? 0 : array.length; - if (!length) { - return []; - } - n = (guard || n === undefined) ? 1 : toInteger(n); - n = length - n; - return baseSlice(array, 0, n < 0 ? 0 : n); - } - - /** - * Creates a slice of `array` excluding elements dropped from the end. - * Elements are dropped until `predicate` returns falsey. The predicate is - * invoked with three arguments: (value, index, array). - * - * @static - * @memberOf _ - * @since 3.0.0 - * @category Array - * @param {Array} array The array to query. - * @param {Function} [predicate=_.identity] The function invoked per iteration. - * @returns {Array} Returns the slice of `array`. - * @example - * - * var users = [ - * { 'user': 'barney', 'active': true }, - * { 'user': 'fred', 'active': false }, - * { 'user': 'pebbles', 'active': false } - * ]; - * - * _.dropRightWhile(users, function(o) { return !o.active; }); - * // => objects for ['barney'] - * - * // The `_.matches` iteratee shorthand. - * _.dropRightWhile(users, { 'user': 'pebbles', 'active': false }); - * // => objects for ['barney', 'fred'] - * - * // The `_.matchesProperty` iteratee shorthand. - * _.dropRightWhile(users, ['active', false]); - * // => objects for ['barney'] - * - * // The `_.property` iteratee shorthand. - * _.dropRightWhile(users, 'active'); - * // => objects for ['barney', 'fred', 'pebbles'] - */ - function dropRightWhile(array, predicate) { - return (array && array.length) - ? baseWhile(array, getIteratee(predicate, 3), true, true) - : []; - } - - /** - * Creates a slice of `array` excluding elements dropped from the beginning. - * Elements are dropped until `predicate` returns falsey. The predicate is - * invoked with three arguments: (value, index, array). - * - * @static - * @memberOf _ - * @since 3.0.0 - * @category Array - * @param {Array} array The array to query. - * @param {Function} [predicate=_.identity] The function invoked per iteration. - * @returns {Array} Returns the slice of `array`. - * @example - * - * var users = [ - * { 'user': 'barney', 'active': false }, - * { 'user': 'fred', 'active': false }, - * { 'user': 'pebbles', 'active': true } - * ]; - * - * _.dropWhile(users, function(o) { return !o.active; }); - * // => objects for ['pebbles'] - * - * // The `_.matches` iteratee shorthand. - * _.dropWhile(users, { 'user': 'barney', 'active': false }); - * // => objects for ['fred', 'pebbles'] - * - * // The `_.matchesProperty` iteratee shorthand. - * _.dropWhile(users, ['active', false]); - * // => objects for ['pebbles'] - * - * // The `_.property` iteratee shorthand. - * _.dropWhile(users, 'active'); - * // => objects for ['barney', 'fred', 'pebbles'] - */ - function dropWhile(array, predicate) { - return (array && array.length) - ? baseWhile(array, getIteratee(predicate, 3), true) - : []; - } - - /** - * Fills elements of `array` with `value` from `start` up to, but not - * including, `end`. - * - * **Note:** This method mutates `array`. - * - * @static - * @memberOf _ - * @since 3.2.0 - * @category Array - * @param {Array} array The array to fill. - * @param {*} value The value to fill `array` with. - * @param {number} [start=0] The start position. - * @param {number} [end=array.length] The end position. - * @returns {Array} Returns `array`. - * @example - * - * var array = [1, 2, 3]; - * - * _.fill(array, 'a'); - * console.log(array); - * // => ['a', 'a', 'a'] - * - * _.fill(Array(3), 2); - * // => [2, 2, 2] - * - * _.fill([4, 6, 8, 10], '*', 1, 3); - * // => [4, '*', '*', 10] - */ - function fill(array, value, start, end) { - var length = array == null ? 0 : array.length; - if (!length) { - return []; - } - if (start && typeof start != 'number' && isIterateeCall(array, value, start)) { - start = 0; - end = length; - } - return baseFill(array, value, start, end); - } - - /** - * This method is like `_.find` except that it returns the index of the first - * element `predicate` returns truthy for instead of the element itself. - * - * @static - * @memberOf _ - * @since 1.1.0 - * @category Array - * @param {Array} array The array to inspect. - * @param {Function} [predicate=_.identity] The function invoked per iteration. - * @param {number} [fromIndex=0] The index to search from. - * @returns {number} Returns the index of the found element, else `-1`. - * @example - * - * var users = [ - * { 'user': 'barney', 'active': false }, - * { 'user': 'fred', 'active': false }, - * { 'user': 'pebbles', 'active': true } - * ]; - * - * _.findIndex(users, function(o) { return o.user == 'barney'; }); - * // => 0 - * - * // The `_.matches` iteratee shorthand. - * _.findIndex(users, { 'user': 'fred', 'active': false }); - * // => 1 - * - * // The `_.matchesProperty` iteratee shorthand. - * _.findIndex(users, ['active', false]); - * // => 0 - * - * // The `_.property` iteratee shorthand. - * _.findIndex(users, 'active'); - * // => 2 - */ - function findIndex(array, predicate, fromIndex) { - var length = array == null ? 0 : array.length; - if (!length) { - return -1; - } - var index = fromIndex == null ? 0 : toInteger(fromIndex); - if (index < 0) { - index = nativeMax(length + index, 0); - } - return baseFindIndex(array, getIteratee(predicate, 3), index); - } - - /** - * This method is like `_.findIndex` except that it iterates over elements - * of `collection` from right to left. - * - * @static - * @memberOf _ - * @since 2.0.0 - * @category Array - * @param {Array} array The array to inspect. - * @param {Function} [predicate=_.identity] The function invoked per iteration. - * @param {number} [fromIndex=array.length-1] The index to search from. - * @returns {number} Returns the index of the found element, else `-1`. - * @example - * - * var users = [ - * { 'user': 'barney', 'active': true }, - * { 'user': 'fred', 'active': false }, - * { 'user': 'pebbles', 'active': false } - * ]; - * - * _.findLastIndex(users, function(o) { return o.user == 'pebbles'; }); - * // => 2 - * - * // The `_.matches` iteratee shorthand. - * _.findLastIndex(users, { 'user': 'barney', 'active': true }); - * // => 0 - * - * // The `_.matchesProperty` iteratee shorthand. - * _.findLastIndex(users, ['active', false]); - * // => 2 - * - * // The `_.property` iteratee shorthand. - * _.findLastIndex(users, 'active'); - * // => 0 - */ - function findLastIndex(array, predicate, fromIndex) { - var length = array == null ? 0 : array.length; - if (!length) { - return -1; - } - var index = length - 1; - if (fromIndex !== undefined) { - index = toInteger(fromIndex); - index = fromIndex < 0 - ? nativeMax(length + index, 0) - : nativeMin(index, length - 1); - } - return baseFindIndex(array, getIteratee(predicate, 3), index, true); - } - - /** - * Flattens `array` a single level deep. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Array - * @param {Array} array The array to flatten. - * @returns {Array} Returns the new flattened array. - * @example - * - * _.flatten([1, [2, [3, [4]], 5]]); - * // => [1, 2, [3, [4]], 5] - */ - function flatten(array) { - var length = array == null ? 0 : array.length; - return length ? baseFlatten(array, 1) : []; - } - - /** - * Recursively flattens `array`. - * - * @static - * @memberOf _ - * @since 3.0.0 - * @category Array - * @param {Array} array The array to flatten. - * @returns {Array} Returns the new flattened array. - * @example - * - * _.flattenDeep([1, [2, [3, [4]], 5]]); - * // => [1, 2, 3, 4, 5] - */ - function flattenDeep(array) { - var length = array == null ? 0 : array.length; - return length ? baseFlatten(array, INFINITY) : []; - } - - /** - * Recursively flatten `array` up to `depth` times. - * - * @static - * @memberOf _ - * @since 4.4.0 - * @category Array - * @param {Array} array The array to flatten. - * @param {number} [depth=1] The maximum recursion depth. - * @returns {Array} Returns the new flattened array. - * @example - * - * var array = [1, [2, [3, [4]], 5]]; - * - * _.flattenDepth(array, 1); - * // => [1, 2, [3, [4]], 5] - * - * _.flattenDepth(array, 2); - * // => [1, 2, 3, [4], 5] - */ - function flattenDepth(array, depth) { - var length = array == null ? 0 : array.length; - if (!length) { - return []; - } - depth = depth === undefined ? 1 : toInteger(depth); - return baseFlatten(array, depth); - } - - /** - * The inverse of `_.toPairs`; this method returns an object composed - * from key-value `pairs`. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Array - * @param {Array} pairs The key-value pairs. - * @returns {Object} Returns the new object. - * @example - * - * _.fromPairs([['a', 1], ['b', 2]]); - * // => { 'a': 1, 'b': 2 } - */ - function fromPairs(pairs) { - var index = -1, - length = pairs == null ? 0 : pairs.length, - result = {}; - - while (++index < length) { - var pair = pairs[index]; - result[pair[0]] = pair[1]; - } - return result; - } - - /** - * Gets the first element of `array`. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @alias first - * @category Array - * @param {Array} array The array to query. - * @returns {*} Returns the first element of `array`. - * @example - * - * _.head([1, 2, 3]); - * // => 1 - * - * _.head([]); - * // => undefined - */ - function head(array) { - return (array && array.length) ? array[0] : undefined; - } - - /** - * Gets the index at which the first occurrence of `value` is found in `array` - * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) - * for equality comparisons. If `fromIndex` is negative, it's used as the - * offset from the end of `array`. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Array - * @param {Array} array The array to inspect. - * @param {*} value The value to search for. - * @param {number} [fromIndex=0] The index to search from. - * @returns {number} Returns the index of the matched value, else `-1`. - * @example - * - * _.indexOf([1, 2, 1, 2], 2); - * // => 1 - * - * // Search from the `fromIndex`. - * _.indexOf([1, 2, 1, 2], 2, 2); - * // => 3 - */ - function indexOf(array, value, fromIndex) { - var length = array == null ? 0 : array.length; - if (!length) { - return -1; - } - var index = fromIndex == null ? 0 : toInteger(fromIndex); - if (index < 0) { - index = nativeMax(length + index, 0); - } - return baseIndexOf(array, value, index); - } - - /** - * Gets all but the last element of `array`. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Array - * @param {Array} array The array to query. - * @returns {Array} Returns the slice of `array`. - * @example - * - * _.initial([1, 2, 3]); - * // => [1, 2] - */ - function initial(array) { - var length = array == null ? 0 : array.length; - return length ? baseSlice(array, 0, -1) : []; - } - - /** - * Creates an array of unique values that are included in all given arrays - * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) - * for equality comparisons. The order and references of result values are - * determined by the first array. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Array - * @param {...Array} [arrays] The arrays to inspect. - * @returns {Array} Returns the new array of intersecting values. - * @example - * - * _.intersection([2, 1], [2, 3]); - * // => [2] - */ - var intersection = baseRest(function(arrays) { - var mapped = arrayMap(arrays, castArrayLikeObject); - return (mapped.length && mapped[0] === arrays[0]) - ? baseIntersection(mapped) - : []; - }); - - /** - * This method is like `_.intersection` except that it accepts `iteratee` - * which is invoked for each element of each `arrays` to generate the criterion - * by which they're compared. The order and references of result values are - * determined by the first array. The iteratee is invoked with one argument: - * (value). - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Array - * @param {...Array} [arrays] The arrays to inspect. - * @param {Function} [iteratee=_.identity] The iteratee invoked per element. - * @returns {Array} Returns the new array of intersecting values. - * @example - * - * _.intersectionBy([2.1, 1.2], [2.3, 3.4], Math.floor); - * // => [2.1] - * - * // The `_.property` iteratee shorthand. - * _.intersectionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x'); - * // => [{ 'x': 1 }] - */ - var intersectionBy = baseRest(function(arrays) { - var iteratee = last(arrays), - mapped = arrayMap(arrays, castArrayLikeObject); - - if (iteratee === last(mapped)) { - iteratee = undefined; - } else { - mapped.pop(); - } - return (mapped.length && mapped[0] === arrays[0]) - ? baseIntersection(mapped, getIteratee(iteratee, 2)) - : []; - }); - - /** - * This method is like `_.intersection` except that it accepts `comparator` - * which is invoked to compare elements of `arrays`. The order and references - * of result values are determined by the first array. The comparator is - * invoked with two arguments: (arrVal, othVal). - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Array - * @param {...Array} [arrays] The arrays to inspect. - * @param {Function} [comparator] The comparator invoked per element. - * @returns {Array} Returns the new array of intersecting values. - * @example - * - * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]; - * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }]; - * - * _.intersectionWith(objects, others, _.isEqual); - * // => [{ 'x': 1, 'y': 2 }] - */ - var intersectionWith = baseRest(function(arrays) { - var comparator = last(arrays), - mapped = arrayMap(arrays, castArrayLikeObject); - - comparator = typeof comparator == 'function' ? comparator : undefined; - if (comparator) { - mapped.pop(); - } - return (mapped.length && mapped[0] === arrays[0]) - ? baseIntersection(mapped, undefined, comparator) - : []; - }); - - /** - * Converts all elements in `array` into a string separated by `separator`. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Array - * @param {Array} array The array to convert. - * @param {string} [separator=','] The element separator. - * @returns {string} Returns the joined string. - * @example - * - * _.join(['a', 'b', 'c'], '~'); - * // => 'a~b~c' - */ - function join(array, separator) { - return array == null ? '' : nativeJoin.call(array, separator); - } - - /** - * Gets the last element of `array`. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Array - * @param {Array} array The array to query. - * @returns {*} Returns the last element of `array`. - * @example - * - * _.last([1, 2, 3]); - * // => 3 - */ - function last(array) { - var length = array == null ? 0 : array.length; - return length ? array[length - 1] : undefined; - } - - /** - * This method is like `_.indexOf` except that it iterates over elements of - * `array` from right to left. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Array - * @param {Array} array The array to inspect. - * @param {*} value The value to search for. - * @param {number} [fromIndex=array.length-1] The index to search from. - * @returns {number} Returns the index of the matched value, else `-1`. - * @example - * - * _.lastIndexOf([1, 2, 1, 2], 2); - * // => 3 - * - * // Search from the `fromIndex`. - * _.lastIndexOf([1, 2, 1, 2], 2, 2); - * // => 1 - */ - function lastIndexOf(array, value, fromIndex) { - var length = array == null ? 0 : array.length; - if (!length) { - return -1; - } - var index = length; - if (fromIndex !== undefined) { - index = toInteger(fromIndex); - index = index < 0 ? nativeMax(length + index, 0) : nativeMin(index, length - 1); - } - return value === value - ? strictLastIndexOf(array, value, index) - : baseFindIndex(array, baseIsNaN, index, true); - } - - /** - * Gets the element at index `n` of `array`. If `n` is negative, the nth - * element from the end is returned. - * - * @static - * @memberOf _ - * @since 4.11.0 - * @category Array - * @param {Array} array The array to query. - * @param {number} [n=0] The index of the element to return. - * @returns {*} Returns the nth element of `array`. - * @example - * - * var array = ['a', 'b', 'c', 'd']; - * - * _.nth(array, 1); - * // => 'b' - * - * _.nth(array, -2); - * // => 'c'; - */ - function nth(array, n) { - return (array && array.length) ? baseNth(array, toInteger(n)) : undefined; - } - - /** - * Removes all given values from `array` using - * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) - * for equality comparisons. - * - * **Note:** Unlike `_.without`, this method mutates `array`. Use `_.remove` - * to remove elements from an array by predicate. - * - * @static - * @memberOf _ - * @since 2.0.0 - * @category Array - * @param {Array} array The array to modify. - * @param {...*} [values] The values to remove. - * @returns {Array} Returns `array`. - * @example - * - * var array = ['a', 'b', 'c', 'a', 'b', 'c']; - * - * _.pull(array, 'a', 'c'); - * console.log(array); - * // => ['b', 'b'] - */ - var pull = baseRest(pullAll); - - /** - * This method is like `_.pull` except that it accepts an array of values to remove. - * - * **Note:** Unlike `_.difference`, this method mutates `array`. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Array - * @param {Array} array The array to modify. - * @param {Array} values The values to remove. - * @returns {Array} Returns `array`. - * @example - * - * var array = ['a', 'b', 'c', 'a', 'b', 'c']; - * - * _.pullAll(array, ['a', 'c']); - * console.log(array); - * // => ['b', 'b'] - */ - function pullAll(array, values) { - return (array && array.length && values && values.length) - ? basePullAll(array, values) - : array; - } - - /** - * This method is like `_.pullAll` except that it accepts `iteratee` which is - * invoked for each element of `array` and `values` to generate the criterion - * by which they're compared. The iteratee is invoked with one argument: (value). - * - * **Note:** Unlike `_.differenceBy`, this method mutates `array`. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Array - * @param {Array} array The array to modify. - * @param {Array} values The values to remove. - * @param {Function} [iteratee=_.identity] The iteratee invoked per element. - * @returns {Array} Returns `array`. - * @example - * - * var array = [{ 'x': 1 }, { 'x': 2 }, { 'x': 3 }, { 'x': 1 }]; - * - * _.pullAllBy(array, [{ 'x': 1 }, { 'x': 3 }], 'x'); - * console.log(array); - * // => [{ 'x': 2 }] - */ - function pullAllBy(array, values, iteratee) { - return (array && array.length && values && values.length) - ? basePullAll(array, values, getIteratee(iteratee, 2)) - : array; - } - - /** - * This method is like `_.pullAll` except that it accepts `comparator` which - * is invoked to compare elements of `array` to `values`. The comparator is - * invoked with two arguments: (arrVal, othVal). - * - * **Note:** Unlike `_.differenceWith`, this method mutates `array`. - * - * @static - * @memberOf _ - * @since 4.6.0 - * @category Array - * @param {Array} array The array to modify. - * @param {Array} values The values to remove. - * @param {Function} [comparator] The comparator invoked per element. - * @returns {Array} Returns `array`. - * @example - * - * var array = [{ 'x': 1, 'y': 2 }, { 'x': 3, 'y': 4 }, { 'x': 5, 'y': 6 }]; - * - * _.pullAllWith(array, [{ 'x': 3, 'y': 4 }], _.isEqual); - * console.log(array); - * // => [{ 'x': 1, 'y': 2 }, { 'x': 5, 'y': 6 }] - */ - function pullAllWith(array, values, comparator) { - return (array && array.length && values && values.length) - ? basePullAll(array, values, undefined, comparator) - : array; - } - - /** - * Removes elements from `array` corresponding to `indexes` and returns an - * array of removed elements. - * - * **Note:** Unlike `_.at`, this method mutates `array`. - * - * @static - * @memberOf _ - * @since 3.0.0 - * @category Array - * @param {Array} array The array to modify. - * @param {...(number|number[])} [indexes] The indexes of elements to remove. - * @returns {Array} Returns the new array of removed elements. - * @example - * - * var array = ['a', 'b', 'c', 'd']; - * var pulled = _.pullAt(array, [1, 3]); - * - * console.log(array); - * // => ['a', 'c'] - * - * console.log(pulled); - * // => ['b', 'd'] - */ - var pullAt = flatRest(function(array, indexes) { - var length = array == null ? 0 : array.length, - result = baseAt(array, indexes); - - basePullAt(array, arrayMap(indexes, function(index) { - return isIndex(index, length) ? +index : index; - }).sort(compareAscending)); - - return result; - }); - - /** - * Removes all elements from `array` that `predicate` returns truthy for - * and returns an array of the removed elements. The predicate is invoked - * with three arguments: (value, index, array). - * - * **Note:** Unlike `_.filter`, this method mutates `array`. Use `_.pull` - * to pull elements from an array by value. - * - * @static - * @memberOf _ - * @since 2.0.0 - * @category Array - * @param {Array} array The array to modify. - * @param {Function} [predicate=_.identity] The function invoked per iteration. - * @returns {Array} Returns the new array of removed elements. - * @example - * - * var array = [1, 2, 3, 4]; - * var evens = _.remove(array, function(n) { - * return n % 2 == 0; - * }); - * - * console.log(array); - * // => [1, 3] - * - * console.log(evens); - * // => [2, 4] - */ - function remove(array, predicate) { - var result = []; - if (!(array && array.length)) { - return result; - } - var index = -1, - indexes = [], - length = array.length; - - predicate = getIteratee(predicate, 3); - while (++index < length) { - var value = array[index]; - if (predicate(value, index, array)) { - result.push(value); - indexes.push(index); - } - } - basePullAt(array, indexes); - return result; - } - - /** - * Reverses `array` so that the first element becomes the last, the second - * element becomes the second to last, and so on. - * - * **Note:** This method mutates `array` and is based on - * [`Array#reverse`](https://mdn.io/Array/reverse). - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Array - * @param {Array} array The array to modify. - * @returns {Array} Returns `array`. - * @example - * - * var array = [1, 2, 3]; - * - * _.reverse(array); - * // => [3, 2, 1] - * - * console.log(array); - * // => [3, 2, 1] - */ - function reverse(array) { - return array == null ? array : nativeReverse.call(array); - } - - /** - * Creates a slice of `array` from `start` up to, but not including, `end`. - * - * **Note:** This method is used instead of - * [`Array#slice`](https://mdn.io/Array/slice) to ensure dense arrays are - * returned. - * - * @static - * @memberOf _ - * @since 3.0.0 - * @category Array - * @param {Array} array The array to slice. - * @param {number} [start=0] The start position. - * @param {number} [end=array.length] The end position. - * @returns {Array} Returns the slice of `array`. - */ - function slice(array, start, end) { - var length = array == null ? 0 : array.length; - if (!length) { - return []; - } - if (end && typeof end != 'number' && isIterateeCall(array, start, end)) { - start = 0; - end = length; - } - else { - start = start == null ? 0 : toInteger(start); - end = end === undefined ? length : toInteger(end); - } - return baseSlice(array, start, end); - } - - /** - * Uses a binary search to determine the lowest index at which `value` - * should be inserted into `array` in order to maintain its sort order. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Array - * @param {Array} array The sorted array to inspect. - * @param {*} value The value to evaluate. - * @returns {number} Returns the index at which `value` should be inserted - * into `array`. - * @example - * - * _.sortedIndex([30, 50], 40); - * // => 1 - */ - function sortedIndex(array, value) { - return baseSortedIndex(array, value); - } - - /** - * This method is like `_.sortedIndex` except that it accepts `iteratee` - * which is invoked for `value` and each element of `array` to compute their - * sort ranking. The iteratee is invoked with one argument: (value). - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Array - * @param {Array} array The sorted array to inspect. - * @param {*} value The value to evaluate. - * @param {Function} [iteratee=_.identity] The iteratee invoked per element. - * @returns {number} Returns the index at which `value` should be inserted - * into `array`. - * @example - * - * var objects = [{ 'x': 4 }, { 'x': 5 }]; - * - * _.sortedIndexBy(objects, { 'x': 4 }, function(o) { return o.x; }); - * // => 0 - * - * // The `_.property` iteratee shorthand. - * _.sortedIndexBy(objects, { 'x': 4 }, 'x'); - * // => 0 - */ - function sortedIndexBy(array, value, iteratee) { - return baseSortedIndexBy(array, value, getIteratee(iteratee, 2)); - } - - /** - * This method is like `_.indexOf` except that it performs a binary - * search on a sorted `array`. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Array - * @param {Array} array The array to inspect. - * @param {*} value The value to search for. - * @returns {number} Returns the index of the matched value, else `-1`. - * @example - * - * _.sortedIndexOf([4, 5, 5, 5, 6], 5); - * // => 1 - */ - function sortedIndexOf(array, value) { - var length = array == null ? 0 : array.length; - if (length) { - var index = baseSortedIndex(array, value); - if (index < length && eq(array[index], value)) { - return index; - } - } - return -1; - } - - /** - * This method is like `_.sortedIndex` except that it returns the highest - * index at which `value` should be inserted into `array` in order to - * maintain its sort order. - * - * @static - * @memberOf _ - * @since 3.0.0 - * @category Array - * @param {Array} array The sorted array to inspect. - * @param {*} value The value to evaluate. - * @returns {number} Returns the index at which `value` should be inserted - * into `array`. - * @example - * - * _.sortedLastIndex([4, 5, 5, 5, 6], 5); - * // => 4 - */ - function sortedLastIndex(array, value) { - return baseSortedIndex(array, value, true); - } - - /** - * This method is like `_.sortedLastIndex` except that it accepts `iteratee` - * which is invoked for `value` and each element of `array` to compute their - * sort ranking. The iteratee is invoked with one argument: (value). - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Array - * @param {Array} array The sorted array to inspect. - * @param {*} value The value to evaluate. - * @param {Function} [iteratee=_.identity] The iteratee invoked per element. - * @returns {number} Returns the index at which `value` should be inserted - * into `array`. - * @example - * - * var objects = [{ 'x': 4 }, { 'x': 5 }]; - * - * _.sortedLastIndexBy(objects, { 'x': 4 }, function(o) { return o.x; }); - * // => 1 - * - * // The `_.property` iteratee shorthand. - * _.sortedLastIndexBy(objects, { 'x': 4 }, 'x'); - * // => 1 - */ - function sortedLastIndexBy(array, value, iteratee) { - return baseSortedIndexBy(array, value, getIteratee(iteratee, 2), true); - } - - /** - * This method is like `_.lastIndexOf` except that it performs a binary - * search on a sorted `array`. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Array - * @param {Array} array The array to inspect. - * @param {*} value The value to search for. - * @returns {number} Returns the index of the matched value, else `-1`. - * @example - * - * _.sortedLastIndexOf([4, 5, 5, 5, 6], 5); - * // => 3 - */ - function sortedLastIndexOf(array, value) { - var length = array == null ? 0 : array.length; - if (length) { - var index = baseSortedIndex(array, value, true) - 1; - if (eq(array[index], value)) { - return index; - } - } - return -1; - } - - /** - * This method is like `_.uniq` except that it's designed and optimized - * for sorted arrays. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Array - * @param {Array} array The array to inspect. - * @returns {Array} Returns the new duplicate free array. - * @example - * - * _.sortedUniq([1, 1, 2]); - * // => [1, 2] - */ - function sortedUniq(array) { - return (array && array.length) - ? baseSortedUniq(array) - : []; - } - - /** - * This method is like `_.uniqBy` except that it's designed and optimized - * for sorted arrays. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Array - * @param {Array} array The array to inspect. - * @param {Function} [iteratee] The iteratee invoked per element. - * @returns {Array} Returns the new duplicate free array. - * @example - * - * _.sortedUniqBy([1.1, 1.2, 2.3, 2.4], Math.floor); - * // => [1.1, 2.3] - */ - function sortedUniqBy(array, iteratee) { - return (array && array.length) - ? baseSortedUniq(array, getIteratee(iteratee, 2)) - : []; - } - - /** - * Gets all but the first element of `array`. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Array - * @param {Array} array The array to query. - * @returns {Array} Returns the slice of `array`. - * @example - * - * _.tail([1, 2, 3]); - * // => [2, 3] - */ - function tail(array) { - var length = array == null ? 0 : array.length; - return length ? baseSlice(array, 1, length) : []; - } - - /** - * Creates a slice of `array` with `n` elements taken from the beginning. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Array - * @param {Array} array The array to query. - * @param {number} [n=1] The number of elements to take. - * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. - * @returns {Array} Returns the slice of `array`. - * @example - * - * _.take([1, 2, 3]); - * // => [1] - * - * _.take([1, 2, 3], 2); - * // => [1, 2] - * - * _.take([1, 2, 3], 5); - * // => [1, 2, 3] - * - * _.take([1, 2, 3], 0); - * // => [] - */ - function take(array, n, guard) { - if (!(array && array.length)) { - return []; - } - n = (guard || n === undefined) ? 1 : toInteger(n); - return baseSlice(array, 0, n < 0 ? 0 : n); - } - - /** - * Creates a slice of `array` with `n` elements taken from the end. - * - * @static - * @memberOf _ - * @since 3.0.0 - * @category Array - * @param {Array} array The array to query. - * @param {number} [n=1] The number of elements to take. - * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. - * @returns {Array} Returns the slice of `array`. - * @example - * - * _.takeRight([1, 2, 3]); - * // => [3] - * - * _.takeRight([1, 2, 3], 2); - * // => [2, 3] - * - * _.takeRight([1, 2, 3], 5); - * // => [1, 2, 3] - * - * _.takeRight([1, 2, 3], 0); - * // => [] - */ - function takeRight(array, n, guard) { - var length = array == null ? 0 : array.length; - if (!length) { - return []; - } - n = (guard || n === undefined) ? 1 : toInteger(n); - n = length - n; - return baseSlice(array, n < 0 ? 0 : n, length); - } - - /** - * Creates a slice of `array` with elements taken from the end. Elements are - * taken until `predicate` returns falsey. The predicate is invoked with - * three arguments: (value, index, array). - * - * @static - * @memberOf _ - * @since 3.0.0 - * @category Array - * @param {Array} array The array to query. - * @param {Function} [predicate=_.identity] The function invoked per iteration. - * @returns {Array} Returns the slice of `array`. - * @example - * - * var users = [ - * { 'user': 'barney', 'active': true }, - * { 'user': 'fred', 'active': false }, - * { 'user': 'pebbles', 'active': false } - * ]; - * - * _.takeRightWhile(users, function(o) { return !o.active; }); - * // => objects for ['fred', 'pebbles'] - * - * // The `_.matches` iteratee shorthand. - * _.takeRightWhile(users, { 'user': 'pebbles', 'active': false }); - * // => objects for ['pebbles'] - * - * // The `_.matchesProperty` iteratee shorthand. - * _.takeRightWhile(users, ['active', false]); - * // => objects for ['fred', 'pebbles'] - * - * // The `_.property` iteratee shorthand. - * _.takeRightWhile(users, 'active'); - * // => [] - */ - function takeRightWhile(array, predicate) { - return (array && array.length) - ? baseWhile(array, getIteratee(predicate, 3), false, true) - : []; - } - - /** - * Creates a slice of `array` with elements taken from the beginning. Elements - * are taken until `predicate` returns falsey. The predicate is invoked with - * three arguments: (value, index, array). - * - * @static - * @memberOf _ - * @since 3.0.0 - * @category Array - * @param {Array} array The array to query. - * @param {Function} [predicate=_.identity] The function invoked per iteration. - * @returns {Array} Returns the slice of `array`. - * @example - * - * var users = [ - * { 'user': 'barney', 'active': false }, - * { 'user': 'fred', 'active': false }, - * { 'user': 'pebbles', 'active': true } - * ]; - * - * _.takeWhile(users, function(o) { return !o.active; }); - * // => objects for ['barney', 'fred'] - * - * // The `_.matches` iteratee shorthand. - * _.takeWhile(users, { 'user': 'barney', 'active': false }); - * // => objects for ['barney'] - * - * // The `_.matchesProperty` iteratee shorthand. - * _.takeWhile(users, ['active', false]); - * // => objects for ['barney', 'fred'] - * - * // The `_.property` iteratee shorthand. - * _.takeWhile(users, 'active'); - * // => [] - */ - function takeWhile(array, predicate) { - return (array && array.length) - ? baseWhile(array, getIteratee(predicate, 3)) - : []; - } - - /** - * Creates an array of unique values, in order, from all given arrays using - * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) - * for equality comparisons. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Array - * @param {...Array} [arrays] The arrays to inspect. - * @returns {Array} Returns the new array of combined values. - * @example - * - * _.union([2], [1, 2]); - * // => [2, 1] - */ - var union = baseRest(function(arrays) { - return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true)); - }); - - /** - * This method is like `_.union` except that it accepts `iteratee` which is - * invoked for each element of each `arrays` to generate the criterion by - * which uniqueness is computed. Result values are chosen from the first - * array in which the value occurs. The iteratee is invoked with one argument: - * (value). - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Array - * @param {...Array} [arrays] The arrays to inspect. - * @param {Function} [iteratee=_.identity] The iteratee invoked per element. - * @returns {Array} Returns the new array of combined values. - * @example - * - * _.unionBy([2.1], [1.2, 2.3], Math.floor); - * // => [2.1, 1.2] - * - * // The `_.property` iteratee shorthand. - * _.unionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x'); - * // => [{ 'x': 1 }, { 'x': 2 }] - */ - var unionBy = baseRest(function(arrays) { - var iteratee = last(arrays); - if (isArrayLikeObject(iteratee)) { - iteratee = undefined; - } - return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), getIteratee(iteratee, 2)); - }); - - /** - * This method is like `_.union` except that it accepts `comparator` which - * is invoked to compare elements of `arrays`. Result values are chosen from - * the first array in which the value occurs. The comparator is invoked - * with two arguments: (arrVal, othVal). - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Array - * @param {...Array} [arrays] The arrays to inspect. - * @param {Function} [comparator] The comparator invoked per element. - * @returns {Array} Returns the new array of combined values. - * @example - * - * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]; - * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }]; - * - * _.unionWith(objects, others, _.isEqual); - * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }] - */ - var unionWith = baseRest(function(arrays) { - var comparator = last(arrays); - comparator = typeof comparator == 'function' ? comparator : undefined; - return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), undefined, comparator); - }); - - /** - * Creates a duplicate-free version of an array, using - * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) - * for equality comparisons, in which only the first occurrence of each element - * is kept. The order of result values is determined by the order they occur - * in the array. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Array - * @param {Array} array The array to inspect. - * @returns {Array} Returns the new duplicate free array. - * @example - * - * _.uniq([2, 1, 2]); - * // => [2, 1] - */ - function uniq(array) { - return (array && array.length) ? baseUniq(array) : []; - } - - /** - * This method is like `_.uniq` except that it accepts `iteratee` which is - * invoked for each element in `array` to generate the criterion by which - * uniqueness is computed. The order of result values is determined by the - * order they occur in the array. The iteratee is invoked with one argument: - * (value). - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Array - * @param {Array} array The array to inspect. - * @param {Function} [iteratee=_.identity] The iteratee invoked per element. - * @returns {Array} Returns the new duplicate free array. - * @example - * - * _.uniqBy([2.1, 1.2, 2.3], Math.floor); - * // => [2.1, 1.2] - * - * // The `_.property` iteratee shorthand. - * _.uniqBy([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x'); - * // => [{ 'x': 1 }, { 'x': 2 }] - */ - function uniqBy(array, iteratee) { - return (array && array.length) ? baseUniq(array, getIteratee(iteratee, 2)) : []; - } - - /** - * This method is like `_.uniq` except that it accepts `comparator` which - * is invoked to compare elements of `array`. The order of result values is - * determined by the order they occur in the array.The comparator is invoked - * with two arguments: (arrVal, othVal). - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Array - * @param {Array} array The array to inspect. - * @param {Function} [comparator] The comparator invoked per element. - * @returns {Array} Returns the new duplicate free array. - * @example - * - * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 2 }]; - * - * _.uniqWith(objects, _.isEqual); - * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }] - */ - function uniqWith(array, comparator) { - comparator = typeof comparator == 'function' ? comparator : undefined; - return (array && array.length) ? baseUniq(array, undefined, comparator) : []; - } - - /** - * This method is like `_.zip` except that it accepts an array of grouped - * elements and creates an array regrouping the elements to their pre-zip - * configuration. - * - * @static - * @memberOf _ - * @since 1.2.0 - * @category Array - * @param {Array} array The array of grouped elements to process. - * @returns {Array} Returns the new array of regrouped elements. - * @example - * - * var zipped = _.zip(['a', 'b'], [1, 2], [true, false]); - * // => [['a', 1, true], ['b', 2, false]] - * - * _.unzip(zipped); - * // => [['a', 'b'], [1, 2], [true, false]] - */ - function unzip(array) { - if (!(array && array.length)) { - return []; - } - var length = 0; - array = arrayFilter(array, function(group) { - if (isArrayLikeObject(group)) { - length = nativeMax(group.length, length); - return true; - } - }); - return baseTimes(length, function(index) { - return arrayMap(array, baseProperty(index)); - }); - } - - /** - * This method is like `_.unzip` except that it accepts `iteratee` to specify - * how regrouped values should be combined. The iteratee is invoked with the - * elements of each group: (...group). - * - * @static - * @memberOf _ - * @since 3.8.0 - * @category Array - * @param {Array} array The array of grouped elements to process. - * @param {Function} [iteratee=_.identity] The function to combine - * regrouped values. - * @returns {Array} Returns the new array of regrouped elements. - * @example - * - * var zipped = _.zip([1, 2], [10, 20], [100, 200]); - * // => [[1, 10, 100], [2, 20, 200]] - * - * _.unzipWith(zipped, _.add); - * // => [3, 30, 300] - */ - function unzipWith(array, iteratee) { - if (!(array && array.length)) { - return []; - } - var result = unzip(array); - if (iteratee == null) { - return result; - } - return arrayMap(result, function(group) { - return apply(iteratee, undefined, group); - }); - } - - /** - * Creates an array excluding all given values using - * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) - * for equality comparisons. - * - * **Note:** Unlike `_.pull`, this method returns a new array. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Array - * @param {Array} array The array to inspect. - * @param {...*} [values] The values to exclude. - * @returns {Array} Returns the new array of filtered values. - * @see _.difference, _.xor - * @example - * - * _.without([2, 1, 2, 3], 1, 2); - * // => [3] - */ - var without = baseRest(function(array, values) { - return isArrayLikeObject(array) - ? baseDifference(array, values) - : []; - }); - - /** - * Creates an array of unique values that is the - * [symmetric difference](https://en.wikipedia.org/wiki/Symmetric_difference) - * of the given arrays. The order of result values is determined by the order - * they occur in the arrays. - * - * @static - * @memberOf _ - * @since 2.4.0 - * @category Array - * @param {...Array} [arrays] The arrays to inspect. - * @returns {Array} Returns the new array of filtered values. - * @see _.difference, _.without - * @example - * - * _.xor([2, 1], [2, 3]); - * // => [1, 3] - */ - var xor = baseRest(function(arrays) { - return baseXor(arrayFilter(arrays, isArrayLikeObject)); - }); - - /** - * This method is like `_.xor` except that it accepts `iteratee` which is - * invoked for each element of each `arrays` to generate the criterion by - * which by which they're compared. The order of result values is determined - * by the order they occur in the arrays. The iteratee is invoked with one - * argument: (value). - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Array - * @param {...Array} [arrays] The arrays to inspect. - * @param {Function} [iteratee=_.identity] The iteratee invoked per element. - * @returns {Array} Returns the new array of filtered values. - * @example - * - * _.xorBy([2.1, 1.2], [2.3, 3.4], Math.floor); - * // => [1.2, 3.4] - * - * // The `_.property` iteratee shorthand. - * _.xorBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x'); - * // => [{ 'x': 2 }] - */ - var xorBy = baseRest(function(arrays) { - var iteratee = last(arrays); - if (isArrayLikeObject(iteratee)) { - iteratee = undefined; - } - return baseXor(arrayFilter(arrays, isArrayLikeObject), getIteratee(iteratee, 2)); - }); - - /** - * This method is like `_.xor` except that it accepts `comparator` which is - * invoked to compare elements of `arrays`. The order of result values is - * determined by the order they occur in the arrays. The comparator is invoked - * with two arguments: (arrVal, othVal). - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Array - * @param {...Array} [arrays] The arrays to inspect. - * @param {Function} [comparator] The comparator invoked per element. - * @returns {Array} Returns the new array of filtered values. - * @example - * - * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]; - * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }]; - * - * _.xorWith(objects, others, _.isEqual); - * // => [{ 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }] - */ - var xorWith = baseRest(function(arrays) { - var comparator = last(arrays); - comparator = typeof comparator == 'function' ? comparator : undefined; - return baseXor(arrayFilter(arrays, isArrayLikeObject), undefined, comparator); - }); - - /** - * Creates an array of grouped elements, the first of which contains the - * first elements of the given arrays, the second of which contains the - * second elements of the given arrays, and so on. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Array - * @param {...Array} [arrays] The arrays to process. - * @returns {Array} Returns the new array of grouped elements. - * @example - * - * _.zip(['a', 'b'], [1, 2], [true, false]); - * // => [['a', 1, true], ['b', 2, false]] - */ - var zip = baseRest(unzip); - - /** - * This method is like `_.fromPairs` except that it accepts two arrays, - * one of property identifiers and one of corresponding values. - * - * @static - * @memberOf _ - * @since 0.4.0 - * @category Array - * @param {Array} [props=[]] The property identifiers. - * @param {Array} [values=[]] The property values. - * @returns {Object} Returns the new object. - * @example - * - * _.zipObject(['a', 'b'], [1, 2]); - * // => { 'a': 1, 'b': 2 } - */ - function zipObject(props, values) { - return baseZipObject(props || [], values || [], assignValue); - } - - /** - * This method is like `_.zipObject` except that it supports property paths. - * - * @static - * @memberOf _ - * @since 4.1.0 - * @category Array - * @param {Array} [props=[]] The property identifiers. - * @param {Array} [values=[]] The property values. - * @returns {Object} Returns the new object. - * @example - * - * _.zipObjectDeep(['a.b[0].c', 'a.b[1].d'], [1, 2]); - * // => { 'a': { 'b': [{ 'c': 1 }, { 'd': 2 }] } } - */ - function zipObjectDeep(props, values) { - return baseZipObject(props || [], values || [], baseSet); - } - - /** - * This method is like `_.zip` except that it accepts `iteratee` to specify - * how grouped values should be combined. The iteratee is invoked with the - * elements of each group: (...group). - * - * @static - * @memberOf _ - * @since 3.8.0 - * @category Array - * @param {...Array} [arrays] The arrays to process. - * @param {Function} [iteratee=_.identity] The function to combine - * grouped values. - * @returns {Array} Returns the new array of grouped elements. - * @example - * - * _.zipWith([1, 2], [10, 20], [100, 200], function(a, b, c) { - * return a + b + c; - * }); - * // => [111, 222] - */ - var zipWith = baseRest(function(arrays) { - var length = arrays.length, - iteratee = length > 1 ? arrays[length - 1] : undefined; - - iteratee = typeof iteratee == 'function' ? (arrays.pop(), iteratee) : undefined; - return unzipWith(arrays, iteratee); - }); - - /*------------------------------------------------------------------------*/ - - /** - * Creates a `lodash` wrapper instance that wraps `value` with explicit method - * chain sequences enabled. The result of such sequences must be unwrapped - * with `_#value`. - * - * @static - * @memberOf _ - * @since 1.3.0 - * @category Seq - * @param {*} value The value to wrap. - * @returns {Object} Returns the new `lodash` wrapper instance. - * @example - * - * var users = [ - * { 'user': 'barney', 'age': 36 }, - * { 'user': 'fred', 'age': 40 }, - * { 'user': 'pebbles', 'age': 1 } - * ]; - * - * var youngest = _ - * .chain(users) - * .sortBy('age') - * .map(function(o) { - * return o.user + ' is ' + o.age; - * }) - * .head() - * .value(); - * // => 'pebbles is 1' - */ - function chain(value) { - var result = lodash(value); - result.__chain__ = true; - return result; - } - - /** - * This method invokes `interceptor` and returns `value`. The interceptor - * is invoked with one argument; (value). The purpose of this method is to - * "tap into" a method chain sequence in order to modify intermediate results. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Seq - * @param {*} value The value to provide to `interceptor`. - * @param {Function} interceptor The function to invoke. - * @returns {*} Returns `value`. - * @example - * - * _([1, 2, 3]) - * .tap(function(array) { - * // Mutate input array. - * array.pop(); - * }) - * .reverse() - * .value(); - * // => [2, 1] - */ - function tap(value, interceptor) { - interceptor(value); - return value; - } - - /** - * This method is like `_.tap` except that it returns the result of `interceptor`. - * The purpose of this method is to "pass thru" values replacing intermediate - * results in a method chain sequence. - * - * @static - * @memberOf _ - * @since 3.0.0 - * @category Seq - * @param {*} value The value to provide to `interceptor`. - * @param {Function} interceptor The function to invoke. - * @returns {*} Returns the result of `interceptor`. - * @example - * - * _(' abc ') - * .chain() - * .trim() - * .thru(function(value) { - * return [value]; - * }) - * .value(); - * // => ['abc'] - */ - function thru(value, interceptor) { - return interceptor(value); - } - - /** - * This method is the wrapper version of `_.at`. - * - * @name at - * @memberOf _ - * @since 1.0.0 - * @category Seq - * @param {...(string|string[])} [paths] The property paths to pick. - * @returns {Object} Returns the new `lodash` wrapper instance. - * @example - * - * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] }; - * - * _(object).at(['a[0].b.c', 'a[1]']).value(); - * // => [3, 4] - */ - var wrapperAt = flatRest(function(paths) { - var length = paths.length, - start = length ? paths[0] : 0, - value = this.__wrapped__, - interceptor = function(object) { return baseAt(object, paths); }; - - if (length > 1 || this.__actions__.length || - !(value instanceof LazyWrapper) || !isIndex(start)) { - return this.thru(interceptor); - } - value = value.slice(start, +start + (length ? 1 : 0)); - value.__actions__.push({ - 'func': thru, - 'args': [interceptor], - 'thisArg': undefined - }); - return new LodashWrapper(value, this.__chain__).thru(function(array) { - if (length && !array.length) { - array.push(undefined); - } - return array; - }); - }); - - /** - * Creates a `lodash` wrapper instance with explicit method chain sequences enabled. - * - * @name chain - * @memberOf _ - * @since 0.1.0 - * @category Seq - * @returns {Object} Returns the new `lodash` wrapper instance. - * @example - * - * var users = [ - * { 'user': 'barney', 'age': 36 }, - * { 'user': 'fred', 'age': 40 } - * ]; - * - * // A sequence without explicit chaining. - * _(users).head(); - * // => { 'user': 'barney', 'age': 36 } - * - * // A sequence with explicit chaining. - * _(users) - * .chain() - * .head() - * .pick('user') - * .value(); - * // => { 'user': 'barney' } - */ - function wrapperChain() { - return chain(this); - } - - /** - * Executes the chain sequence and returns the wrapped result. - * - * @name commit - * @memberOf _ - * @since 3.2.0 - * @category Seq - * @returns {Object} Returns the new `lodash` wrapper instance. - * @example - * - * var array = [1, 2]; - * var wrapped = _(array).push(3); - * - * console.log(array); - * // => [1, 2] - * - * wrapped = wrapped.commit(); - * console.log(array); - * // => [1, 2, 3] - * - * wrapped.last(); - * // => 3 - * - * console.log(array); - * // => [1, 2, 3] - */ - function wrapperCommit() { - return new LodashWrapper(this.value(), this.__chain__); - } - - /** - * Gets the next value on a wrapped object following the - * [iterator protocol](https://mdn.io/iteration_protocols#iterator). - * - * @name next - * @memberOf _ - * @since 4.0.0 - * @category Seq - * @returns {Object} Returns the next iterator value. - * @example - * - * var wrapped = _([1, 2]); - * - * wrapped.next(); - * // => { 'done': false, 'value': 1 } - * - * wrapped.next(); - * // => { 'done': false, 'value': 2 } - * - * wrapped.next(); - * // => { 'done': true, 'value': undefined } - */ - function wrapperNext() { - if (this.__values__ === undefined) { - this.__values__ = toArray(this.value()); - } - var done = this.__index__ >= this.__values__.length, - value = done ? undefined : this.__values__[this.__index__++]; - - return { 'done': done, 'value': value }; - } - - /** - * Enables the wrapper to be iterable. - * - * @name Symbol.iterator - * @memberOf _ - * @since 4.0.0 - * @category Seq - * @returns {Object} Returns the wrapper object. - * @example - * - * var wrapped = _([1, 2]); - * - * wrapped[Symbol.iterator]() === wrapped; - * // => true - * - * Array.from(wrapped); - * // => [1, 2] - */ - function wrapperToIterator() { - return this; - } - - /** - * Creates a clone of the chain sequence planting `value` as the wrapped value. - * - * @name plant - * @memberOf _ - * @since 3.2.0 - * @category Seq - * @param {*} value The value to plant. - * @returns {Object} Returns the new `lodash` wrapper instance. - * @example - * - * function square(n) { - * return n * n; - * } - * - * var wrapped = _([1, 2]).map(square); - * var other = wrapped.plant([3, 4]); - * - * other.value(); - * // => [9, 16] - * - * wrapped.value(); - * // => [1, 4] - */ - function wrapperPlant(value) { - var result, - parent = this; - - while (parent instanceof baseLodash) { - var clone = wrapperClone(parent); - clone.__index__ = 0; - clone.__values__ = undefined; - if (result) { - previous.__wrapped__ = clone; - } else { - result = clone; - } - var previous = clone; - parent = parent.__wrapped__; - } - previous.__wrapped__ = value; - return result; - } - - /** - * This method is the wrapper version of `_.reverse`. - * - * **Note:** This method mutates the wrapped array. - * - * @name reverse - * @memberOf _ - * @since 0.1.0 - * @category Seq - * @returns {Object} Returns the new `lodash` wrapper instance. - * @example - * - * var array = [1, 2, 3]; - * - * _(array).reverse().value() - * // => [3, 2, 1] - * - * console.log(array); - * // => [3, 2, 1] - */ - function wrapperReverse() { - var value = this.__wrapped__; - if (value instanceof LazyWrapper) { - var wrapped = value; - if (this.__actions__.length) { - wrapped = new LazyWrapper(this); - } - wrapped = wrapped.reverse(); - wrapped.__actions__.push({ - 'func': thru, - 'args': [reverse], - 'thisArg': undefined - }); - return new LodashWrapper(wrapped, this.__chain__); - } - return this.thru(reverse); - } - - /** - * Executes the chain sequence to resolve the unwrapped value. - * - * @name value - * @memberOf _ - * @since 0.1.0 - * @alias toJSON, valueOf - * @category Seq - * @returns {*} Returns the resolved unwrapped value. - * @example - * - * _([1, 2, 3]).value(); - * // => [1, 2, 3] - */ - function wrapperValue() { - return baseWrapperValue(this.__wrapped__, this.__actions__); - } - - /*------------------------------------------------------------------------*/ - - /** - * Creates an object composed of keys generated from the results of running - * each element of `collection` thru `iteratee`. The corresponding value of - * each key is the number of times the key was returned by `iteratee`. The - * iteratee is invoked with one argument: (value). - * - * @static - * @memberOf _ - * @since 0.5.0 - * @category Collection - * @param {Array|Object} collection The collection to iterate over. - * @param {Function} [iteratee=_.identity] The iteratee to transform keys. - * @returns {Object} Returns the composed aggregate object. - * @example - * - * _.countBy([6.1, 4.2, 6.3], Math.floor); - * // => { '4': 1, '6': 2 } - * - * // The `_.property` iteratee shorthand. - * _.countBy(['one', 'two', 'three'], 'length'); - * // => { '3': 2, '5': 1 } - */ - var countBy = createAggregator(function(result, value, key) { - if (hasOwnProperty.call(result, key)) { - ++result[key]; - } else { - baseAssignValue(result, key, 1); - } - }); - - /** - * Checks if `predicate` returns truthy for **all** elements of `collection`. - * Iteration is stopped once `predicate` returns falsey. The predicate is - * invoked with three arguments: (value, index|key, collection). - * - * **Note:** This method returns `true` for - * [empty collections](https://en.wikipedia.org/wiki/Empty_set) because - * [everything is true](https://en.wikipedia.org/wiki/Vacuous_truth) of - * elements of empty collections. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Collection - * @param {Array|Object} collection The collection to iterate over. - * @param {Function} [predicate=_.identity] The function invoked per iteration. - * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. - * @returns {boolean} Returns `true` if all elements pass the predicate check, - * else `false`. - * @example - * - * _.every([true, 1, null, 'yes'], Boolean); - * // => false - * - * var users = [ - * { 'user': 'barney', 'age': 36, 'active': false }, - * { 'user': 'fred', 'age': 40, 'active': false } - * ]; - * - * // The `_.matches` iteratee shorthand. - * _.every(users, { 'user': 'barney', 'active': false }); - * // => false - * - * // The `_.matchesProperty` iteratee shorthand. - * _.every(users, ['active', false]); - * // => true - * - * // The `_.property` iteratee shorthand. - * _.every(users, 'active'); - * // => false - */ - function every(collection, predicate, guard) { - var func = isArray(collection) ? arrayEvery : baseEvery; - if (guard && isIterateeCall(collection, predicate, guard)) { - predicate = undefined; - } - return func(collection, getIteratee(predicate, 3)); - } - - /** - * Iterates over elements of `collection`, returning an array of all elements - * `predicate` returns truthy for. The predicate is invoked with three - * arguments: (value, index|key, collection). - * - * **Note:** Unlike `_.remove`, this method returns a new array. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Collection - * @param {Array|Object} collection The collection to iterate over. - * @param {Function} [predicate=_.identity] The function invoked per iteration. - * @returns {Array} Returns the new filtered array. - * @see _.reject - * @example - * - * var users = [ - * { 'user': 'barney', 'age': 36, 'active': true }, - * { 'user': 'fred', 'age': 40, 'active': false } - * ]; - * - * _.filter(users, function(o) { return !o.active; }); - * // => objects for ['fred'] - * - * // The `_.matches` iteratee shorthand. - * _.filter(users, { 'age': 36, 'active': true }); - * // => objects for ['barney'] - * - * // The `_.matchesProperty` iteratee shorthand. - * _.filter(users, ['active', false]); - * // => objects for ['fred'] - * - * // The `_.property` iteratee shorthand. - * _.filter(users, 'active'); - * // => objects for ['barney'] - */ - function filter(collection, predicate) { - var func = isArray(collection) ? arrayFilter : baseFilter; - return func(collection, getIteratee(predicate, 3)); - } - - /** - * Iterates over elements of `collection`, returning the first element - * `predicate` returns truthy for. The predicate is invoked with three - * arguments: (value, index|key, collection). - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Collection - * @param {Array|Object} collection The collection to inspect. - * @param {Function} [predicate=_.identity] The function invoked per iteration. - * @param {number} [fromIndex=0] The index to search from. - * @returns {*} Returns the matched element, else `undefined`. - * @example - * - * var users = [ - * { 'user': 'barney', 'age': 36, 'active': true }, - * { 'user': 'fred', 'age': 40, 'active': false }, - * { 'user': 'pebbles', 'age': 1, 'active': true } - * ]; - * - * _.find(users, function(o) { return o.age < 40; }); - * // => object for 'barney' - * - * // The `_.matches` iteratee shorthand. - * _.find(users, { 'age': 1, 'active': true }); - * // => object for 'pebbles' - * - * // The `_.matchesProperty` iteratee shorthand. - * _.find(users, ['active', false]); - * // => object for 'fred' - * - * // The `_.property` iteratee shorthand. - * _.find(users, 'active'); - * // => object for 'barney' - */ - var find = createFind(findIndex); - - /** - * This method is like `_.find` except that it iterates over elements of - * `collection` from right to left. - * - * @static - * @memberOf _ - * @since 2.0.0 - * @category Collection - * @param {Array|Object} collection The collection to inspect. - * @param {Function} [predicate=_.identity] The function invoked per iteration. - * @param {number} [fromIndex=collection.length-1] The index to search from. - * @returns {*} Returns the matched element, else `undefined`. - * @example - * - * _.findLast([1, 2, 3, 4], function(n) { - * return n % 2 == 1; - * }); - * // => 3 - */ - var findLast = createFind(findLastIndex); - - /** - * Creates a flattened array of values by running each element in `collection` - * thru `iteratee` and flattening the mapped results. The iteratee is invoked - * with three arguments: (value, index|key, collection). - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Collection - * @param {Array|Object} collection The collection to iterate over. - * @param {Function} [iteratee=_.identity] The function invoked per iteration. - * @returns {Array} Returns the new flattened array. - * @example - * - * function duplicate(n) { - * return [n, n]; - * } - * - * _.flatMap([1, 2], duplicate); - * // => [1, 1, 2, 2] - */ - function flatMap(collection, iteratee) { - return baseFlatten(map(collection, iteratee), 1); - } - - /** - * This method is like `_.flatMap` except that it recursively flattens the - * mapped results. - * - * @static - * @memberOf _ - * @since 4.7.0 - * @category Collection - * @param {Array|Object} collection The collection to iterate over. - * @param {Function} [iteratee=_.identity] The function invoked per iteration. - * @returns {Array} Returns the new flattened array. - * @example - * - * function duplicate(n) { - * return [[[n, n]]]; - * } - * - * _.flatMapDeep([1, 2], duplicate); - * // => [1, 1, 2, 2] - */ - function flatMapDeep(collection, iteratee) { - return baseFlatten(map(collection, iteratee), INFINITY); - } - - /** - * This method is like `_.flatMap` except that it recursively flattens the - * mapped results up to `depth` times. - * - * @static - * @memberOf _ - * @since 4.7.0 - * @category Collection - * @param {Array|Object} collection The collection to iterate over. - * @param {Function} [iteratee=_.identity] The function invoked per iteration. - * @param {number} [depth=1] The maximum recursion depth. - * @returns {Array} Returns the new flattened array. - * @example - * - * function duplicate(n) { - * return [[[n, n]]]; - * } - * - * _.flatMapDepth([1, 2], duplicate, 2); - * // => [[1, 1], [2, 2]] - */ - function flatMapDepth(collection, iteratee, depth) { - depth = depth === undefined ? 1 : toInteger(depth); - return baseFlatten(map(collection, iteratee), depth); - } - - /** - * Iterates over elements of `collection` and invokes `iteratee` for each element. - * The iteratee is invoked with three arguments: (value, index|key, collection). - * Iteratee functions may exit iteration early by explicitly returning `false`. - * - * **Note:** As with other "Collections" methods, objects with a "length" - * property are iterated like arrays. To avoid this behavior use `_.forIn` - * or `_.forOwn` for object iteration. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @alias each - * @category Collection - * @param {Array|Object} collection The collection to iterate over. - * @param {Function} [iteratee=_.identity] The function invoked per iteration. - * @returns {Array|Object} Returns `collection`. - * @see _.forEachRight - * @example - * - * _.forEach([1, 2], function(value) { - * console.log(value); - * }); - * // => Logs `1` then `2`. - * - * _.forEach({ 'a': 1, 'b': 2 }, function(value, key) { - * console.log(key); - * }); - * // => Logs 'a' then 'b' (iteration order is not guaranteed). - */ - function forEach(collection, iteratee) { - var func = isArray(collection) ? arrayEach : baseEach; - return func(collection, getIteratee(iteratee, 3)); - } - - /** - * This method is like `_.forEach` except that it iterates over elements of - * `collection` from right to left. - * - * @static - * @memberOf _ - * @since 2.0.0 - * @alias eachRight - * @category Collection - * @param {Array|Object} collection The collection to iterate over. - * @param {Function} [iteratee=_.identity] The function invoked per iteration. - * @returns {Array|Object} Returns `collection`. - * @see _.forEach - * @example - * - * _.forEachRight([1, 2], function(value) { - * console.log(value); - * }); - * // => Logs `2` then `1`. - */ - function forEachRight(collection, iteratee) { - var func = isArray(collection) ? arrayEachRight : baseEachRight; - return func(collection, getIteratee(iteratee, 3)); - } - - /** - * Creates an object composed of keys generated from the results of running - * each element of `collection` thru `iteratee`. The order of grouped values - * is determined by the order they occur in `collection`. The corresponding - * value of each key is an array of elements responsible for generating the - * key. The iteratee is invoked with one argument: (value). - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Collection - * @param {Array|Object} collection The collection to iterate over. - * @param {Function} [iteratee=_.identity] The iteratee to transform keys. - * @returns {Object} Returns the composed aggregate object. - * @example - * - * _.groupBy([6.1, 4.2, 6.3], Math.floor); - * // => { '4': [4.2], '6': [6.1, 6.3] } - * - * // The `_.property` iteratee shorthand. - * _.groupBy(['one', 'two', 'three'], 'length'); - * // => { '3': ['one', 'two'], '5': ['three'] } - */ - var groupBy = createAggregator(function(result, value, key) { - if (hasOwnProperty.call(result, key)) { - result[key].push(value); - } else { - baseAssignValue(result, key, [value]); - } - }); - - /** - * Checks if `value` is in `collection`. If `collection` is a string, it's - * checked for a substring of `value`, otherwise - * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) - * is used for equality comparisons. If `fromIndex` is negative, it's used as - * the offset from the end of `collection`. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Collection - * @param {Array|Object|string} collection The collection to inspect. - * @param {*} value The value to search for. - * @param {number} [fromIndex=0] The index to search from. - * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`. - * @returns {boolean} Returns `true` if `value` is found, else `false`. - * @example - * - * _.includes([1, 2, 3], 1); - * // => true - * - * _.includes([1, 2, 3], 1, 2); - * // => false - * - * _.includes({ 'a': 1, 'b': 2 }, 1); - * // => true - * - * _.includes('abcd', 'bc'); - * // => true - */ - function includes(collection, value, fromIndex, guard) { - collection = isArrayLike(collection) ? collection : values(collection); - fromIndex = (fromIndex && !guard) ? toInteger(fromIndex) : 0; - - var length = collection.length; - if (fromIndex < 0) { - fromIndex = nativeMax(length + fromIndex, 0); - } - return isString(collection) - ? (fromIndex <= length && collection.indexOf(value, fromIndex) > -1) - : (!!length && baseIndexOf(collection, value, fromIndex) > -1); - } - - /** - * Invokes the method at `path` of each element in `collection`, returning - * an array of the results of each invoked method. Any additional arguments - * are provided to each invoked method. If `path` is a function, it's invoked - * for, and `this` bound to, each element in `collection`. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Collection - * @param {Array|Object} collection The collection to iterate over. - * @param {Array|Function|string} path The path of the method to invoke or - * the function invoked per iteration. - * @param {...*} [args] The arguments to invoke each method with. - * @returns {Array} Returns the array of results. - * @example - * - * _.invokeMap([[5, 1, 7], [3, 2, 1]], 'sort'); - * // => [[1, 5, 7], [1, 2, 3]] - * - * _.invokeMap([123, 456], String.prototype.split, ''); - * // => [['1', '2', '3'], ['4', '5', '6']] - */ - var invokeMap = baseRest(function(collection, path, args) { - var index = -1, - isFunc = typeof path == 'function', - result = isArrayLike(collection) ? Array(collection.length) : []; - - baseEach(collection, function(value) { - result[++index] = isFunc ? apply(path, value, args) : baseInvoke(value, path, args); - }); - return result; - }); - - /** - * Creates an object composed of keys generated from the results of running - * each element of `collection` thru `iteratee`. The corresponding value of - * each key is the last element responsible for generating the key. The - * iteratee is invoked with one argument: (value). - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Collection - * @param {Array|Object} collection The collection to iterate over. - * @param {Function} [iteratee=_.identity] The iteratee to transform keys. - * @returns {Object} Returns the composed aggregate object. - * @example - * - * var array = [ - * { 'dir': 'left', 'code': 97 }, - * { 'dir': 'right', 'code': 100 } - * ]; - * - * _.keyBy(array, function(o) { - * return String.fromCharCode(o.code); - * }); - * // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } } - * - * _.keyBy(array, 'dir'); - * // => { 'left': { 'dir': 'left', 'code': 97 }, 'right': { 'dir': 'right', 'code': 100 } } - */ - var keyBy = createAggregator(function(result, value, key) { - baseAssignValue(result, key, value); - }); - - /** - * Creates an array of values by running each element in `collection` thru - * `iteratee`. The iteratee is invoked with three arguments: - * (value, index|key, collection). - * - * Many lodash methods are guarded to work as iteratees for methods like - * `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`. - * - * The guarded methods are: - * `ary`, `chunk`, `curry`, `curryRight`, `drop`, `dropRight`, `every`, - * `fill`, `invert`, `parseInt`, `random`, `range`, `rangeRight`, `repeat`, - * `sampleSize`, `slice`, `some`, `sortBy`, `split`, `take`, `takeRight`, - * `template`, `trim`, `trimEnd`, `trimStart`, and `words` - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Collection - * @param {Array|Object} collection The collection to iterate over. - * @param {Function} [iteratee=_.identity] The function invoked per iteration. - * @returns {Array} Returns the new mapped array. - * @example - * - * function square(n) { - * return n * n; - * } - * - * _.map([4, 8], square); - * // => [16, 64] - * - * _.map({ 'a': 4, 'b': 8 }, square); - * // => [16, 64] (iteration order is not guaranteed) - * - * var users = [ - * { 'user': 'barney' }, - * { 'user': 'fred' } - * ]; - * - * // The `_.property` iteratee shorthand. - * _.map(users, 'user'); - * // => ['barney', 'fred'] - */ - function map(collection, iteratee) { - var func = isArray(collection) ? arrayMap : baseMap; - return func(collection, getIteratee(iteratee, 3)); - } - - /** - * This method is like `_.sortBy` except that it allows specifying the sort - * orders of the iteratees to sort by. If `orders` is unspecified, all values - * are sorted in ascending order. Otherwise, specify an order of "desc" for - * descending or "asc" for ascending sort order of corresponding values. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Collection - * @param {Array|Object} collection The collection to iterate over. - * @param {Array[]|Function[]|Object[]|string[]} [iteratees=[_.identity]] - * The iteratees to sort by. - * @param {string[]} [orders] The sort orders of `iteratees`. - * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`. - * @returns {Array} Returns the new sorted array. - * @example - * - * var users = [ - * { 'user': 'fred', 'age': 48 }, - * { 'user': 'barney', 'age': 34 }, - * { 'user': 'fred', 'age': 40 }, - * { 'user': 'barney', 'age': 36 } - * ]; - * - * // Sort by `user` in ascending order and by `age` in descending order. - * _.orderBy(users, ['user', 'age'], ['asc', 'desc']); - * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]] - */ - function orderBy(collection, iteratees, orders, guard) { - if (collection == null) { - return []; - } - if (!isArray(iteratees)) { - iteratees = iteratees == null ? [] : [iteratees]; - } - orders = guard ? undefined : orders; - if (!isArray(orders)) { - orders = orders == null ? [] : [orders]; - } - return baseOrderBy(collection, iteratees, orders); - } - - /** - * Creates an array of elements split into two groups, the first of which - * contains elements `predicate` returns truthy for, the second of which - * contains elements `predicate` returns falsey for. The predicate is - * invoked with one argument: (value). - * - * @static - * @memberOf _ - * @since 3.0.0 - * @category Collection - * @param {Array|Object} collection The collection to iterate over. - * @param {Function} [predicate=_.identity] The function invoked per iteration. - * @returns {Array} Returns the array of grouped elements. - * @example - * - * var users = [ - * { 'user': 'barney', 'age': 36, 'active': false }, - * { 'user': 'fred', 'age': 40, 'active': true }, - * { 'user': 'pebbles', 'age': 1, 'active': false } - * ]; - * - * _.partition(users, function(o) { return o.active; }); - * // => objects for [['fred'], ['barney', 'pebbles']] - * - * // The `_.matches` iteratee shorthand. - * _.partition(users, { 'age': 1, 'active': false }); - * // => objects for [['pebbles'], ['barney', 'fred']] - * - * // The `_.matchesProperty` iteratee shorthand. - * _.partition(users, ['active', false]); - * // => objects for [['barney', 'pebbles'], ['fred']] - * - * // The `_.property` iteratee shorthand. - * _.partition(users, 'active'); - * // => objects for [['fred'], ['barney', 'pebbles']] - */ - var partition = createAggregator(function(result, value, key) { - result[key ? 0 : 1].push(value); - }, function() { return [[], []]; }); - - /** - * Reduces `collection` to a value which is the accumulated result of running - * each element in `collection` thru `iteratee`, where each successive - * invocation is supplied the return value of the previous. If `accumulator` - * is not given, the first element of `collection` is used as the initial - * value. The iteratee is invoked with four arguments: - * (accumulator, value, index|key, collection). - * - * Many lodash methods are guarded to work as iteratees for methods like - * `_.reduce`, `_.reduceRight`, and `_.transform`. - * - * The guarded methods are: - * `assign`, `defaults`, `defaultsDeep`, `includes`, `merge`, `orderBy`, - * and `sortBy` - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Collection - * @param {Array|Object} collection The collection to iterate over. - * @param {Function} [iteratee=_.identity] The function invoked per iteration. - * @param {*} [accumulator] The initial value. - * @returns {*} Returns the accumulated value. - * @see _.reduceRight - * @example - * - * _.reduce([1, 2], function(sum, n) { - * return sum + n; - * }, 0); - * // => 3 - * - * _.reduce({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) { - * (result[value] || (result[value] = [])).push(key); - * return result; - * }, {}); - * // => { '1': ['a', 'c'], '2': ['b'] } (iteration order is not guaranteed) - */ - function reduce(collection, iteratee, accumulator) { - var func = isArray(collection) ? arrayReduce : baseReduce, - initAccum = arguments.length < 3; - - return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEach); - } - - /** - * This method is like `_.reduce` except that it iterates over elements of - * `collection` from right to left. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Collection - * @param {Array|Object} collection The collection to iterate over. - * @param {Function} [iteratee=_.identity] The function invoked per iteration. - * @param {*} [accumulator] The initial value. - * @returns {*} Returns the accumulated value. - * @see _.reduce - * @example - * - * var array = [[0, 1], [2, 3], [4, 5]]; - * - * _.reduceRight(array, function(flattened, other) { - * return flattened.concat(other); - * }, []); - * // => [4, 5, 2, 3, 0, 1] - */ - function reduceRight(collection, iteratee, accumulator) { - var func = isArray(collection) ? arrayReduceRight : baseReduce, - initAccum = arguments.length < 3; - - return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEachRight); - } - - /** - * The opposite of `_.filter`; this method returns the elements of `collection` - * that `predicate` does **not** return truthy for. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Collection - * @param {Array|Object} collection The collection to iterate over. - * @param {Function} [predicate=_.identity] The function invoked per iteration. - * @returns {Array} Returns the new filtered array. - * @see _.filter - * @example - * - * var users = [ - * { 'user': 'barney', 'age': 36, 'active': false }, - * { 'user': 'fred', 'age': 40, 'active': true } - * ]; - * - * _.reject(users, function(o) { return !o.active; }); - * // => objects for ['fred'] - * - * // The `_.matches` iteratee shorthand. - * _.reject(users, { 'age': 40, 'active': true }); - * // => objects for ['barney'] - * - * // The `_.matchesProperty` iteratee shorthand. - * _.reject(users, ['active', false]); - * // => objects for ['fred'] - * - * // The `_.property` iteratee shorthand. - * _.reject(users, 'active'); - * // => objects for ['barney'] - */ - function reject(collection, predicate) { - var func = isArray(collection) ? arrayFilter : baseFilter; - return func(collection, negate(getIteratee(predicate, 3))); - } - - /** - * Gets a random element from `collection`. - * - * @static - * @memberOf _ - * @since 2.0.0 - * @category Collection - * @param {Array|Object} collection The collection to sample. - * @returns {*} Returns the random element. - * @example - * - * _.sample([1, 2, 3, 4]); - * // => 2 - */ - function sample(collection) { - var func = isArray(collection) ? arraySample : baseSample; - return func(collection); - } - - /** - * Gets `n` random elements at unique keys from `collection` up to the - * size of `collection`. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Collection - * @param {Array|Object} collection The collection to sample. - * @param {number} [n=1] The number of elements to sample. - * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. - * @returns {Array} Returns the random elements. - * @example - * - * _.sampleSize([1, 2, 3], 2); - * // => [3, 1] - * - * _.sampleSize([1, 2, 3], 4); - * // => [2, 3, 1] - */ - function sampleSize(collection, n, guard) { - if ((guard ? isIterateeCall(collection, n, guard) : n === undefined)) { - n = 1; - } else { - n = toInteger(n); - } - var func = isArray(collection) ? arraySampleSize : baseSampleSize; - return func(collection, n); - } - - /** - * Creates an array of shuffled values, using a version of the - * [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher-Yates_shuffle). - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Collection - * @param {Array|Object} collection The collection to shuffle. - * @returns {Array} Returns the new shuffled array. - * @example - * - * _.shuffle([1, 2, 3, 4]); - * // => [4, 1, 3, 2] - */ - function shuffle(collection) { - var func = isArray(collection) ? arrayShuffle : baseShuffle; - return func(collection); - } - - /** - * Gets the size of `collection` by returning its length for array-like - * values or the number of own enumerable string keyed properties for objects. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Collection - * @param {Array|Object|string} collection The collection to inspect. - * @returns {number} Returns the collection size. - * @example - * - * _.size([1, 2, 3]); - * // => 3 - * - * _.size({ 'a': 1, 'b': 2 }); - * // => 2 - * - * _.size('pebbles'); - * // => 7 - */ - function size(collection) { - if (collection == null) { - return 0; - } - if (isArrayLike(collection)) { - return isString(collection) ? stringSize(collection) : collection.length; - } - var tag = getTag(collection); - if (tag == mapTag || tag == setTag) { - return collection.size; - } - return baseKeys(collection).length; - } - - /** - * Checks if `predicate` returns truthy for **any** element of `collection`. - * Iteration is stopped once `predicate` returns truthy. The predicate is - * invoked with three arguments: (value, index|key, collection). - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Collection - * @param {Array|Object} collection The collection to iterate over. - * @param {Function} [predicate=_.identity] The function invoked per iteration. - * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. - * @returns {boolean} Returns `true` if any element passes the predicate check, - * else `false`. - * @example - * - * _.some([null, 0, 'yes', false], Boolean); - * // => true - * - * var users = [ - * { 'user': 'barney', 'active': true }, - * { 'user': 'fred', 'active': false } - * ]; - * - * // The `_.matches` iteratee shorthand. - * _.some(users, { 'user': 'barney', 'active': false }); - * // => false - * - * // The `_.matchesProperty` iteratee shorthand. - * _.some(users, ['active', false]); - * // => true - * - * // The `_.property` iteratee shorthand. - * _.some(users, 'active'); - * // => true - */ - function some(collection, predicate, guard) { - var func = isArray(collection) ? arraySome : baseSome; - if (guard && isIterateeCall(collection, predicate, guard)) { - predicate = undefined; - } - return func(collection, getIteratee(predicate, 3)); - } - - /** - * Creates an array of elements, sorted in ascending order by the results of - * running each element in a collection thru each iteratee. This method - * performs a stable sort, that is, it preserves the original sort order of - * equal elements. The iteratees are invoked with one argument: (value). - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Collection - * @param {Array|Object} collection The collection to iterate over. - * @param {...(Function|Function[])} [iteratees=[_.identity]] - * The iteratees to sort by. - * @returns {Array} Returns the new sorted array. - * @example - * - * var users = [ - * { 'user': 'fred', 'age': 48 }, - * { 'user': 'barney', 'age': 36 }, - * { 'user': 'fred', 'age': 40 }, - * { 'user': 'barney', 'age': 34 } - * ]; - * - * _.sortBy(users, [function(o) { return o.user; }]); - * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]] - * - * _.sortBy(users, ['user', 'age']); - * // => objects for [['barney', 34], ['barney', 36], ['fred', 40], ['fred', 48]] - */ - var sortBy = baseRest(function(collection, iteratees) { - if (collection == null) { - return []; - } - var length = iteratees.length; - if (length > 1 && isIterateeCall(collection, iteratees[0], iteratees[1])) { - iteratees = []; - } else if (length > 2 && isIterateeCall(iteratees[0], iteratees[1], iteratees[2])) { - iteratees = [iteratees[0]]; - } - return baseOrderBy(collection, baseFlatten(iteratees, 1), []); - }); - - /*------------------------------------------------------------------------*/ - - /** - * Gets the timestamp of the number of milliseconds that have elapsed since - * the Unix epoch (1 January 1970 00:00:00 UTC). - * - * @static - * @memberOf _ - * @since 2.4.0 - * @category Date - * @returns {number} Returns the timestamp. - * @example - * - * _.defer(function(stamp) { - * console.log(_.now() - stamp); - * }, _.now()); - * // => Logs the number of milliseconds it took for the deferred invocation. - */ - var now = ctxNow || function() { - return root.Date.now(); - }; - - /*------------------------------------------------------------------------*/ - - /** - * The opposite of `_.before`; this method creates a function that invokes - * `func` once it's called `n` or more times. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Function - * @param {number} n The number of calls before `func` is invoked. - * @param {Function} func The function to restrict. - * @returns {Function} Returns the new restricted function. - * @example - * - * var saves = ['profile', 'settings']; - * - * var done = _.after(saves.length, function() { - * console.log('done saving!'); - * }); - * - * _.forEach(saves, function(type) { - * asyncSave({ 'type': type, 'complete': done }); - * }); - * // => Logs 'done saving!' after the two async saves have completed. - */ - function after(n, func) { - if (typeof func != 'function') { - throw new TypeError(FUNC_ERROR_TEXT); - } - n = toInteger(n); - return function() { - if (--n < 1) { - return func.apply(this, arguments); - } - }; - } - - /** - * Creates a function that invokes `func`, with up to `n` arguments, - * ignoring any additional arguments. - * - * @static - * @memberOf _ - * @since 3.0.0 - * @category Function - * @param {Function} func The function to cap arguments for. - * @param {number} [n=func.length] The arity cap. - * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. - * @returns {Function} Returns the new capped function. - * @example - * - * _.map(['6', '8', '10'], _.ary(parseInt, 1)); - * // => [6, 8, 10] - */ - function ary(func, n, guard) { - n = guard ? undefined : n; - n = (func && n == null) ? func.length : n; - return createWrap(func, WRAP_ARY_FLAG, undefined, undefined, undefined, undefined, n); - } - - /** - * Creates a function that invokes `func`, with the `this` binding and arguments - * of the created function, while it's called less than `n` times. Subsequent - * calls to the created function return the result of the last `func` invocation. - * - * @static - * @memberOf _ - * @since 3.0.0 - * @category Function - * @param {number} n The number of calls at which `func` is no longer invoked. - * @param {Function} func The function to restrict. - * @returns {Function} Returns the new restricted function. - * @example - * - * jQuery(element).on('click', _.before(5, addContactToList)); - * // => Allows adding up to 4 contacts to the list. - */ - function before(n, func) { - var result; - if (typeof func != 'function') { - throw new TypeError(FUNC_ERROR_TEXT); - } - n = toInteger(n); - return function() { - if (--n > 0) { - result = func.apply(this, arguments); - } - if (n <= 1) { - func = undefined; - } - return result; - }; - } - - /** - * Creates a function that invokes `func` with the `this` binding of `thisArg` - * and `partials` prepended to the arguments it receives. - * - * The `_.bind.placeholder` value, which defaults to `_` in monolithic builds, - * may be used as a placeholder for partially applied arguments. - * - * **Note:** Unlike native `Function#bind`, this method doesn't set the "length" - * property of bound functions. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Function - * @param {Function} func The function to bind. - * @param {*} thisArg The `this` binding of `func`. - * @param {...*} [partials] The arguments to be partially applied. - * @returns {Function} Returns the new bound function. - * @example - * - * function greet(greeting, punctuation) { - * return greeting + ' ' + this.user + punctuation; - * } - * - * var object = { 'user': 'fred' }; - * - * var bound = _.bind(greet, object, 'hi'); - * bound('!'); - * // => 'hi fred!' - * - * // Bound with placeholders. - * var bound = _.bind(greet, object, _, '!'); - * bound('hi'); - * // => 'hi fred!' - */ - var bind = baseRest(function(func, thisArg, partials) { - var bitmask = WRAP_BIND_FLAG; - if (partials.length) { - var holders = replaceHolders(partials, getHolder(bind)); - bitmask |= WRAP_PARTIAL_FLAG; - } - return createWrap(func, bitmask, thisArg, partials, holders); - }); - - /** - * Creates a function that invokes the method at `object[key]` with `partials` - * prepended to the arguments it receives. - * - * This method differs from `_.bind` by allowing bound functions to reference - * methods that may be redefined or don't yet exist. See - * [Peter Michaux's article](http://peter.michaux.ca/articles/lazy-function-definition-pattern) - * for more details. - * - * The `_.bindKey.placeholder` value, which defaults to `_` in monolithic - * builds, may be used as a placeholder for partially applied arguments. - * - * @static - * @memberOf _ - * @since 0.10.0 - * @category Function - * @param {Object} object The object to invoke the method on. - * @param {string} key The key of the method. - * @param {...*} [partials] The arguments to be partially applied. - * @returns {Function} Returns the new bound function. - * @example - * - * var object = { - * 'user': 'fred', - * 'greet': function(greeting, punctuation) { - * return greeting + ' ' + this.user + punctuation; - * } - * }; - * - * var bound = _.bindKey(object, 'greet', 'hi'); - * bound('!'); - * // => 'hi fred!' - * - * object.greet = function(greeting, punctuation) { - * return greeting + 'ya ' + this.user + punctuation; - * }; - * - * bound('!'); - * // => 'hiya fred!' - * - * // Bound with placeholders. - * var bound = _.bindKey(object, 'greet', _, '!'); - * bound('hi'); - * // => 'hiya fred!' - */ - var bindKey = baseRest(function(object, key, partials) { - var bitmask = WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG; - if (partials.length) { - var holders = replaceHolders(partials, getHolder(bindKey)); - bitmask |= WRAP_PARTIAL_FLAG; - } - return createWrap(key, bitmask, object, partials, holders); - }); - - /** - * Creates a function that accepts arguments of `func` and either invokes - * `func` returning its result, if at least `arity` number of arguments have - * been provided, or returns a function that accepts the remaining `func` - * arguments, and so on. The arity of `func` may be specified if `func.length` - * is not sufficient. - * - * The `_.curry.placeholder` value, which defaults to `_` in monolithic builds, - * may be used as a placeholder for provided arguments. - * - * **Note:** This method doesn't set the "length" property of curried functions. - * - * @static - * @memberOf _ - * @since 2.0.0 - * @category Function - * @param {Function} func The function to curry. - * @param {number} [arity=func.length] The arity of `func`. - * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. - * @returns {Function} Returns the new curried function. - * @example - * - * var abc = function(a, b, c) { - * return [a, b, c]; - * }; - * - * var curried = _.curry(abc); - * - * curried(1)(2)(3); - * // => [1, 2, 3] - * - * curried(1, 2)(3); - * // => [1, 2, 3] - * - * curried(1, 2, 3); - * // => [1, 2, 3] - * - * // Curried with placeholders. - * curried(1)(_, 3)(2); - * // => [1, 2, 3] - */ - function curry(func, arity, guard) { - arity = guard ? undefined : arity; - var result = createWrap(func, WRAP_CURRY_FLAG, undefined, undefined, undefined, undefined, undefined, arity); - result.placeholder = curry.placeholder; - return result; - } - - /** - * This method is like `_.curry` except that arguments are applied to `func` - * in the manner of `_.partialRight` instead of `_.partial`. - * - * The `_.curryRight.placeholder` value, which defaults to `_` in monolithic - * builds, may be used as a placeholder for provided arguments. - * - * **Note:** This method doesn't set the "length" property of curried functions. - * - * @static - * @memberOf _ - * @since 3.0.0 - * @category Function - * @param {Function} func The function to curry. - * @param {number} [arity=func.length] The arity of `func`. - * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. - * @returns {Function} Returns the new curried function. - * @example - * - * var abc = function(a, b, c) { - * return [a, b, c]; - * }; - * - * var curried = _.curryRight(abc); - * - * curried(3)(2)(1); - * // => [1, 2, 3] - * - * curried(2, 3)(1); - * // => [1, 2, 3] - * - * curried(1, 2, 3); - * // => [1, 2, 3] - * - * // Curried with placeholders. - * curried(3)(1, _)(2); - * // => [1, 2, 3] - */ - function curryRight(func, arity, guard) { - arity = guard ? undefined : arity; - var result = createWrap(func, WRAP_CURRY_RIGHT_FLAG, undefined, undefined, undefined, undefined, undefined, arity); - result.placeholder = curryRight.placeholder; - return result; - } - - /** - * Creates a debounced function that delays invoking `func` until after `wait` - * milliseconds have elapsed since the last time the debounced function was - * invoked. The debounced function comes with a `cancel` method to cancel - * delayed `func` invocations and a `flush` method to immediately invoke them. - * Provide `options` to indicate whether `func` should be invoked on the - * leading and/or trailing edge of the `wait` timeout. The `func` is invoked - * with the last arguments provided to the debounced function. Subsequent - * calls to the debounced function return the result of the last `func` - * invocation. - * - * **Note:** If `leading` and `trailing` options are `true`, `func` is - * invoked on the trailing edge of the timeout only if the debounced function - * is invoked more than once during the `wait` timeout. - * - * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred - * until to the next tick, similar to `setTimeout` with a timeout of `0`. - * - * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/) - * for details over the differences between `_.debounce` and `_.throttle`. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Function - * @param {Function} func The function to debounce. - * @param {number} [wait=0] The number of milliseconds to delay. - * @param {Object} [options={}] The options object. - * @param {boolean} [options.leading=false] - * Specify invoking on the leading edge of the timeout. - * @param {number} [options.maxWait] - * The maximum time `func` is allowed to be delayed before it's invoked. - * @param {boolean} [options.trailing=true] - * Specify invoking on the trailing edge of the timeout. - * @returns {Function} Returns the new debounced function. - * @example - * - * // Avoid costly calculations while the window size is in flux. - * jQuery(window).on('resize', _.debounce(calculateLayout, 150)); - * - * // Invoke `sendMail` when clicked, debouncing subsequent calls. - * jQuery(element).on('click', _.debounce(sendMail, 300, { - * 'leading': true, - * 'trailing': false - * })); - * - * // Ensure `batchLog` is invoked once after 1 second of debounced calls. - * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 }); - * var source = new EventSource('/stream'); - * jQuery(source).on('message', debounced); - * - * // Cancel the trailing debounced invocation. - * jQuery(window).on('popstate', debounced.cancel); - */ - function debounce(func, wait, options) { - var lastArgs, - lastThis, - maxWait, - result, - timerId, - lastCallTime, - lastInvokeTime = 0, - leading = false, - maxing = false, - trailing = true; - - if (typeof func != 'function') { - throw new TypeError(FUNC_ERROR_TEXT); - } - wait = toNumber(wait) || 0; - if (isObject(options)) { - leading = !!options.leading; - maxing = 'maxWait' in options; - maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait; - trailing = 'trailing' in options ? !!options.trailing : trailing; - } - - function invokeFunc(time) { - var args = lastArgs, - thisArg = lastThis; - - lastArgs = lastThis = undefined; - lastInvokeTime = time; - result = func.apply(thisArg, args); - return result; - } - - function leadingEdge(time) { - // Reset any `maxWait` timer. - lastInvokeTime = time; - // Start the timer for the trailing edge. - timerId = setTimeout(timerExpired, wait); - // Invoke the leading edge. - return leading ? invokeFunc(time) : result; - } - - function remainingWait(time) { - var timeSinceLastCall = time - lastCallTime, - timeSinceLastInvoke = time - lastInvokeTime, - result = wait - timeSinceLastCall; - - return maxing ? nativeMin(result, maxWait - timeSinceLastInvoke) : result; - } - - function shouldInvoke(time) { - var timeSinceLastCall = time - lastCallTime, - timeSinceLastInvoke = time - lastInvokeTime; - - // Either this is the first call, activity has stopped and we're at the - // trailing edge, the system time has gone backwards and we're treating - // it as the trailing edge, or we've hit the `maxWait` limit. - return (lastCallTime === undefined || (timeSinceLastCall >= wait) || - (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait)); - } - - function timerExpired() { - var time = now(); - if (shouldInvoke(time)) { - return trailingEdge(time); - } - // Restart the timer. - timerId = setTimeout(timerExpired, remainingWait(time)); - } - - function trailingEdge(time) { - timerId = undefined; - - // Only invoke if we have `lastArgs` which means `func` has been - // debounced at least once. - if (trailing && lastArgs) { - return invokeFunc(time); - } - lastArgs = lastThis = undefined; - return result; - } - - function cancel() { - if (timerId !== undefined) { - clearTimeout(timerId); - } - lastInvokeTime = 0; - lastArgs = lastCallTime = lastThis = timerId = undefined; - } - - function flush() { - return timerId === undefined ? result : trailingEdge(now()); - } - - function debounced() { - var time = now(), - isInvoking = shouldInvoke(time); - - lastArgs = arguments; - lastThis = this; - lastCallTime = time; - - if (isInvoking) { - if (timerId === undefined) { - return leadingEdge(lastCallTime); - } - if (maxing) { - // Handle invocations in a tight loop. - timerId = setTimeout(timerExpired, wait); - return invokeFunc(lastCallTime); - } - } - if (timerId === undefined) { - timerId = setTimeout(timerExpired, wait); - } - return result; - } - debounced.cancel = cancel; - debounced.flush = flush; - return debounced; - } - - /** - * Defers invoking the `func` until the current call stack has cleared. Any - * additional arguments are provided to `func` when it's invoked. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Function - * @param {Function} func The function to defer. - * @param {...*} [args] The arguments to invoke `func` with. - * @returns {number} Returns the timer id. - * @example - * - * _.defer(function(text) { - * console.log(text); - * }, 'deferred'); - * // => Logs 'deferred' after one millisecond. - */ - var defer = baseRest(function(func, args) { - return baseDelay(func, 1, args); - }); - - /** - * Invokes `func` after `wait` milliseconds. Any additional arguments are - * provided to `func` when it's invoked. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Function - * @param {Function} func The function to delay. - * @param {number} wait The number of milliseconds to delay invocation. - * @param {...*} [args] The arguments to invoke `func` with. - * @returns {number} Returns the timer id. - * @example - * - * _.delay(function(text) { - * console.log(text); - * }, 1000, 'later'); - * // => Logs 'later' after one second. - */ - var delay = baseRest(function(func, wait, args) { - return baseDelay(func, toNumber(wait) || 0, args); - }); - - /** - * Creates a function that invokes `func` with arguments reversed. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Function - * @param {Function} func The function to flip arguments for. - * @returns {Function} Returns the new flipped function. - * @example - * - * var flipped = _.flip(function() { - * return _.toArray(arguments); - * }); - * - * flipped('a', 'b', 'c', 'd'); - * // => ['d', 'c', 'b', 'a'] - */ - function flip(func) { - return createWrap(func, WRAP_FLIP_FLAG); - } - - /** - * Creates a function that memoizes the result of `func`. If `resolver` is - * provided, it determines the cache key for storing the result based on the - * arguments provided to the memoized function. By default, the first argument - * provided to the memoized function is used as the map cache key. The `func` - * is invoked with the `this` binding of the memoized function. - * - * **Note:** The cache is exposed as the `cache` property on the memoized - * function. Its creation may be customized by replacing the `_.memoize.Cache` - * constructor with one whose instances implement the - * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object) - * method interface of `clear`, `delete`, `get`, `has`, and `set`. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Function - * @param {Function} func The function to have its output memoized. - * @param {Function} [resolver] The function to resolve the cache key. - * @returns {Function} Returns the new memoized function. - * @example - * - * var object = { 'a': 1, 'b': 2 }; - * var other = { 'c': 3, 'd': 4 }; - * - * var values = _.memoize(_.values); - * values(object); - * // => [1, 2] - * - * values(other); - * // => [3, 4] - * - * object.a = 2; - * values(object); - * // => [1, 2] - * - * // Modify the result cache. - * values.cache.set(object, ['a', 'b']); - * values(object); - * // => ['a', 'b'] - * - * // Replace `_.memoize.Cache`. - * _.memoize.Cache = WeakMap; - */ - function memoize(func, resolver) { - if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) { - throw new TypeError(FUNC_ERROR_TEXT); - } - var memoized = function() { - var args = arguments, - key = resolver ? resolver.apply(this, args) : args[0], - cache = memoized.cache; - - if (cache.has(key)) { - return cache.get(key); - } - var result = func.apply(this, args); - memoized.cache = cache.set(key, result) || cache; - return result; - }; - memoized.cache = new (memoize.Cache || MapCache); - return memoized; - } - - // Expose `MapCache`. - memoize.Cache = MapCache; - - /** - * Creates a function that negates the result of the predicate `func`. The - * `func` predicate is invoked with the `this` binding and arguments of the - * created function. - * - * @static - * @memberOf _ - * @since 3.0.0 - * @category Function - * @param {Function} predicate The predicate to negate. - * @returns {Function} Returns the new negated function. - * @example - * - * function isEven(n) { - * return n % 2 == 0; - * } - * - * _.filter([1, 2, 3, 4, 5, 6], _.negate(isEven)); - * // => [1, 3, 5] - */ - function negate(predicate) { - if (typeof predicate != 'function') { - throw new TypeError(FUNC_ERROR_TEXT); - } - return function() { - var args = arguments; - switch (args.length) { - case 0: return !predicate.call(this); - case 1: return !predicate.call(this, args[0]); - case 2: return !predicate.call(this, args[0], args[1]); - case 3: return !predicate.call(this, args[0], args[1], args[2]); - } - return !predicate.apply(this, args); - }; - } - - /** - * Creates a function that is restricted to invoking `func` once. Repeat calls - * to the function return the value of the first invocation. The `func` is - * invoked with the `this` binding and arguments of the created function. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Function - * @param {Function} func The function to restrict. - * @returns {Function} Returns the new restricted function. - * @example - * - * var initialize = _.once(createApplication); - * initialize(); - * initialize(); - * // => `createApplication` is invoked once - */ - function once(func) { - return before(2, func); - } - - /** - * Creates a function that invokes `func` with its arguments transformed. - * - * @static - * @since 4.0.0 - * @memberOf _ - * @category Function - * @param {Function} func The function to wrap. - * @param {...(Function|Function[])} [transforms=[_.identity]] - * The argument transforms. - * @returns {Function} Returns the new function. - * @example - * - * function doubled(n) { - * return n * 2; - * } - * - * function square(n) { - * return n * n; - * } - * - * var func = _.overArgs(function(x, y) { - * return [x, y]; - * }, [square, doubled]); - * - * func(9, 3); - * // => [81, 6] - * - * func(10, 5); - * // => [100, 10] - */ - var overArgs = castRest(function(func, transforms) { - transforms = (transforms.length == 1 && isArray(transforms[0])) - ? arrayMap(transforms[0], baseUnary(getIteratee())) - : arrayMap(baseFlatten(transforms, 1), baseUnary(getIteratee())); - - var funcsLength = transforms.length; - return baseRest(function(args) { - var index = -1, - length = nativeMin(args.length, funcsLength); - - while (++index < length) { - args[index] = transforms[index].call(this, args[index]); - } - return apply(func, this, args); - }); - }); - - /** - * Creates a function that invokes `func` with `partials` prepended to the - * arguments it receives. This method is like `_.bind` except it does **not** - * alter the `this` binding. - * - * The `_.partial.placeholder` value, which defaults to `_` in monolithic - * builds, may be used as a placeholder for partially applied arguments. - * - * **Note:** This method doesn't set the "length" property of partially - * applied functions. - * - * @static - * @memberOf _ - * @since 0.2.0 - * @category Function - * @param {Function} func The function to partially apply arguments to. - * @param {...*} [partials] The arguments to be partially applied. - * @returns {Function} Returns the new partially applied function. - * @example - * - * function greet(greeting, name) { - * return greeting + ' ' + name; - * } - * - * var sayHelloTo = _.partial(greet, 'hello'); - * sayHelloTo('fred'); - * // => 'hello fred' - * - * // Partially applied with placeholders. - * var greetFred = _.partial(greet, _, 'fred'); - * greetFred('hi'); - * // => 'hi fred' - */ - var partial = baseRest(function(func, partials) { - var holders = replaceHolders(partials, getHolder(partial)); - return createWrap(func, WRAP_PARTIAL_FLAG, undefined, partials, holders); - }); - - /** - * This method is like `_.partial` except that partially applied arguments - * are appended to the arguments it receives. - * - * The `_.partialRight.placeholder` value, which defaults to `_` in monolithic - * builds, may be used as a placeholder for partially applied arguments. - * - * **Note:** This method doesn't set the "length" property of partially - * applied functions. - * - * @static - * @memberOf _ - * @since 1.0.0 - * @category Function - * @param {Function} func The function to partially apply arguments to. - * @param {...*} [partials] The arguments to be partially applied. - * @returns {Function} Returns the new partially applied function. - * @example - * - * function greet(greeting, name) { - * return greeting + ' ' + name; - * } - * - * var greetFred = _.partialRight(greet, 'fred'); - * greetFred('hi'); - * // => 'hi fred' - * - * // Partially applied with placeholders. - * var sayHelloTo = _.partialRight(greet, 'hello', _); - * sayHelloTo('fred'); - * // => 'hello fred' - */ - var partialRight = baseRest(function(func, partials) { - var holders = replaceHolders(partials, getHolder(partialRight)); - return createWrap(func, WRAP_PARTIAL_RIGHT_FLAG, undefined, partials, holders); - }); - - /** - * Creates a function that invokes `func` with arguments arranged according - * to the specified `indexes` where the argument value at the first index is - * provided as the first argument, the argument value at the second index is - * provided as the second argument, and so on. - * - * @static - * @memberOf _ - * @since 3.0.0 - * @category Function - * @param {Function} func The function to rearrange arguments for. - * @param {...(number|number[])} indexes The arranged argument indexes. - * @returns {Function} Returns the new function. - * @example - * - * var rearged = _.rearg(function(a, b, c) { - * return [a, b, c]; - * }, [2, 0, 1]); - * - * rearged('b', 'c', 'a') - * // => ['a', 'b', 'c'] - */ - var rearg = flatRest(function(func, indexes) { - return createWrap(func, WRAP_REARG_FLAG, undefined, undefined, undefined, indexes); - }); - - /** - * Creates a function that invokes `func` with the `this` binding of the - * created function and arguments from `start` and beyond provided as - * an array. - * - * **Note:** This method is based on the - * [rest parameter](https://mdn.io/rest_parameters). - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Function - * @param {Function} func The function to apply a rest parameter to. - * @param {number} [start=func.length-1] The start position of the rest parameter. - * @returns {Function} Returns the new function. - * @example - * - * var say = _.rest(function(what, names) { - * return what + ' ' + _.initial(names).join(', ') + - * (_.size(names) > 1 ? ', & ' : '') + _.last(names); - * }); - * - * say('hello', 'fred', 'barney', 'pebbles'); - * // => 'hello fred, barney, & pebbles' - */ - function rest(func, start) { - if (typeof func != 'function') { - throw new TypeError(FUNC_ERROR_TEXT); - } - start = start === undefined ? start : toInteger(start); - return baseRest(func, start); - } - - /** - * Creates a function that invokes `func` with the `this` binding of the - * create function and an array of arguments much like - * [`Function#apply`](http://www.ecma-international.org/ecma-262/7.0/#sec-function.prototype.apply). - * - * **Note:** This method is based on the - * [spread operator](https://mdn.io/spread_operator). - * - * @static - * @memberOf _ - * @since 3.2.0 - * @category Function - * @param {Function} func The function to spread arguments over. - * @param {number} [start=0] The start position of the spread. - * @returns {Function} Returns the new function. - * @example - * - * var say = _.spread(function(who, what) { - * return who + ' says ' + what; - * }); - * - * say(['fred', 'hello']); - * // => 'fred says hello' - * - * var numbers = Promise.all([ - * Promise.resolve(40), - * Promise.resolve(36) - * ]); - * - * numbers.then(_.spread(function(x, y) { - * return x + y; - * })); - * // => a Promise of 76 - */ - function spread(func, start) { - if (typeof func != 'function') { - throw new TypeError(FUNC_ERROR_TEXT); - } - start = start == null ? 0 : nativeMax(toInteger(start), 0); - return baseRest(function(args) { - var array = args[start], - otherArgs = castSlice(args, 0, start); - - if (array) { - arrayPush(otherArgs, array); - } - return apply(func, this, otherArgs); - }); - } - - /** - * Creates a throttled function that only invokes `func` at most once per - * every `wait` milliseconds. The throttled function comes with a `cancel` - * method to cancel delayed `func` invocations and a `flush` method to - * immediately invoke them. Provide `options` to indicate whether `func` - * should be invoked on the leading and/or trailing edge of the `wait` - * timeout. The `func` is invoked with the last arguments provided to the - * throttled function. Subsequent calls to the throttled function return the - * result of the last `func` invocation. - * - * **Note:** If `leading` and `trailing` options are `true`, `func` is - * invoked on the trailing edge of the timeout only if the throttled function - * is invoked more than once during the `wait` timeout. - * - * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred - * until to the next tick, similar to `setTimeout` with a timeout of `0`. - * - * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/) - * for details over the differences between `_.throttle` and `_.debounce`. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Function - * @param {Function} func The function to throttle. - * @param {number} [wait=0] The number of milliseconds to throttle invocations to. - * @param {Object} [options={}] The options object. - * @param {boolean} [options.leading=true] - * Specify invoking on the leading edge of the timeout. - * @param {boolean} [options.trailing=true] - * Specify invoking on the trailing edge of the timeout. - * @returns {Function} Returns the new throttled function. - * @example - * - * // Avoid excessively updating the position while scrolling. - * jQuery(window).on('scroll', _.throttle(updatePosition, 100)); - * - * // Invoke `renewToken` when the click event is fired, but not more than once every 5 minutes. - * var throttled = _.throttle(renewToken, 300000, { 'trailing': false }); - * jQuery(element).on('click', throttled); - * - * // Cancel the trailing throttled invocation. - * jQuery(window).on('popstate', throttled.cancel); - */ - function throttle(func, wait, options) { - var leading = true, - trailing = true; - - if (typeof func != 'function') { - throw new TypeError(FUNC_ERROR_TEXT); - } - if (isObject(options)) { - leading = 'leading' in options ? !!options.leading : leading; - trailing = 'trailing' in options ? !!options.trailing : trailing; - } - return debounce(func, wait, { - 'leading': leading, - 'maxWait': wait, - 'trailing': trailing - }); - } - - /** - * Creates a function that accepts up to one argument, ignoring any - * additional arguments. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Function - * @param {Function} func The function to cap arguments for. - * @returns {Function} Returns the new capped function. - * @example - * - * _.map(['6', '8', '10'], _.unary(parseInt)); - * // => [6, 8, 10] - */ - function unary(func) { - return ary(func, 1); - } - - /** - * Creates a function that provides `value` to `wrapper` as its first - * argument. Any additional arguments provided to the function are appended - * to those provided to the `wrapper`. The wrapper is invoked with the `this` - * binding of the created function. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Function - * @param {*} value The value to wrap. - * @param {Function} [wrapper=identity] The wrapper function. - * @returns {Function} Returns the new function. - * @example - * - * var p = _.wrap(_.escape, function(func, text) { - * return '

' + func(text) + '

'; - * }); - * - * p('fred, barney, & pebbles'); - * // => '

fred, barney, & pebbles

' - */ - function wrap(value, wrapper) { - return partial(castFunction(wrapper), value); - } - - /*------------------------------------------------------------------------*/ - - /** - * Casts `value` as an array if it's not one. - * - * @static - * @memberOf _ - * @since 4.4.0 - * @category Lang - * @param {*} value The value to inspect. - * @returns {Array} Returns the cast array. - * @example - * - * _.castArray(1); - * // => [1] - * - * _.castArray({ 'a': 1 }); - * // => [{ 'a': 1 }] - * - * _.castArray('abc'); - * // => ['abc'] - * - * _.castArray(null); - * // => [null] - * - * _.castArray(undefined); - * // => [undefined] - * - * _.castArray(); - * // => [] - * - * var array = [1, 2, 3]; - * console.log(_.castArray(array) === array); - * // => true - */ - function castArray() { - if (!arguments.length) { - return []; - } - var value = arguments[0]; - return isArray(value) ? value : [value]; - } - - /** - * Creates a shallow clone of `value`. - * - * **Note:** This method is loosely based on the - * [structured clone algorithm](https://mdn.io/Structured_clone_algorithm) - * and supports cloning arrays, array buffers, booleans, date objects, maps, - * numbers, `Object` objects, regexes, sets, strings, symbols, and typed - * arrays. The own enumerable properties of `arguments` objects are cloned - * as plain objects. An empty object is returned for uncloneable values such - * as error objects, functions, DOM nodes, and WeakMaps. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Lang - * @param {*} value The value to clone. - * @returns {*} Returns the cloned value. - * @see _.cloneDeep - * @example - * - * var objects = [{ 'a': 1 }, { 'b': 2 }]; - * - * var shallow = _.clone(objects); - * console.log(shallow[0] === objects[0]); - * // => true - */ - function clone(value) { - return baseClone(value, CLONE_SYMBOLS_FLAG); - } - - /** - * This method is like `_.clone` except that it accepts `customizer` which - * is invoked to produce the cloned value. If `customizer` returns `undefined`, - * cloning is handled by the method instead. The `customizer` is invoked with - * up to four arguments; (value [, index|key, object, stack]). - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to clone. - * @param {Function} [customizer] The function to customize cloning. - * @returns {*} Returns the cloned value. - * @see _.cloneDeepWith - * @example - * - * function customizer(value) { - * if (_.isElement(value)) { - * return value.cloneNode(false); - * } - * } - * - * var el = _.cloneWith(document.body, customizer); - * - * console.log(el === document.body); - * // => false - * console.log(el.nodeName); - * // => 'BODY' - * console.log(el.childNodes.length); - * // => 0 - */ - function cloneWith(value, customizer) { - customizer = typeof customizer == 'function' ? customizer : undefined; - return baseClone(value, CLONE_SYMBOLS_FLAG, customizer); - } - - /** - * This method is like `_.clone` except that it recursively clones `value`. - * - * @static - * @memberOf _ - * @since 1.0.0 - * @category Lang - * @param {*} value The value to recursively clone. - * @returns {*} Returns the deep cloned value. - * @see _.clone - * @example - * - * var objects = [{ 'a': 1 }, { 'b': 2 }]; - * - * var deep = _.cloneDeep(objects); - * console.log(deep[0] === objects[0]); - * // => false - */ - function cloneDeep(value) { - return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG); - } - - /** - * This method is like `_.cloneWith` except that it recursively clones `value`. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to recursively clone. - * @param {Function} [customizer] The function to customize cloning. - * @returns {*} Returns the deep cloned value. - * @see _.cloneWith - * @example - * - * function customizer(value) { - * if (_.isElement(value)) { - * return value.cloneNode(true); - * } - * } - * - * var el = _.cloneDeepWith(document.body, customizer); - * - * console.log(el === document.body); - * // => false - * console.log(el.nodeName); - * // => 'BODY' - * console.log(el.childNodes.length); - * // => 20 - */ - function cloneDeepWith(value, customizer) { - customizer = typeof customizer == 'function' ? customizer : undefined; - return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG, customizer); - } - - /** - * Checks if `object` conforms to `source` by invoking the predicate - * properties of `source` with the corresponding property values of `object`. - * - * **Note:** This method is equivalent to `_.conforms` when `source` is - * partially applied. - * - * @static - * @memberOf _ - * @since 4.14.0 - * @category Lang - * @param {Object} object The object to inspect. - * @param {Object} source The object of property predicates to conform to. - * @returns {boolean} Returns `true` if `object` conforms, else `false`. - * @example - * - * var object = { 'a': 1, 'b': 2 }; - * - * _.conformsTo(object, { 'b': function(n) { return n > 1; } }); - * // => true - * - * _.conformsTo(object, { 'b': function(n) { return n > 2; } }); - * // => false - */ - function conformsTo(object, source) { - return source == null || baseConformsTo(object, source, keys(source)); - } - - /** - * Performs a - * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) - * comparison between two values to determine if they are equivalent. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to compare. - * @param {*} other The other value to compare. - * @returns {boolean} Returns `true` if the values are equivalent, else `false`. - * @example - * - * var object = { 'a': 1 }; - * var other = { 'a': 1 }; - * - * _.eq(object, object); - * // => true - * - * _.eq(object, other); - * // => false - * - * _.eq('a', 'a'); - * // => true - * - * _.eq('a', Object('a')); - * // => false - * - * _.eq(NaN, NaN); - * // => true - */ - function eq(value, other) { - return value === other || (value !== value && other !== other); - } - - /** - * Checks if `value` is greater than `other`. - * - * @static - * @memberOf _ - * @since 3.9.0 - * @category Lang - * @param {*} value The value to compare. - * @param {*} other The other value to compare. - * @returns {boolean} Returns `true` if `value` is greater than `other`, - * else `false`. - * @see _.lt - * @example - * - * _.gt(3, 1); - * // => true - * - * _.gt(3, 3); - * // => false - * - * _.gt(1, 3); - * // => false - */ - var gt = createRelationalOperation(baseGt); - - /** - * Checks if `value` is greater than or equal to `other`. - * - * @static - * @memberOf _ - * @since 3.9.0 - * @category Lang - * @param {*} value The value to compare. - * @param {*} other The other value to compare. - * @returns {boolean} Returns `true` if `value` is greater than or equal to - * `other`, else `false`. - * @see _.lte - * @example - * - * _.gte(3, 1); - * // => true - * - * _.gte(3, 3); - * // => true - * - * _.gte(1, 3); - * // => false - */ - var gte = createRelationalOperation(function(value, other) { - return value >= other; - }); - - /** - * Checks if `value` is likely an `arguments` object. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is an `arguments` object, - * else `false`. - * @example - * - * _.isArguments(function() { return arguments; }()); - * // => true - * - * _.isArguments([1, 2, 3]); - * // => false - */ - var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) { - return isObjectLike(value) && hasOwnProperty.call(value, 'callee') && - !propertyIsEnumerable.call(value, 'callee'); - }; - - /** - * Checks if `value` is classified as an `Array` object. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is an array, else `false`. - * @example - * - * _.isArray([1, 2, 3]); - * // => true - * - * _.isArray(document.body.children); - * // => false - * - * _.isArray('abc'); - * // => false - * - * _.isArray(_.noop); - * // => false - */ - var isArray = Array.isArray; - - /** - * Checks if `value` is classified as an `ArrayBuffer` object. - * - * @static - * @memberOf _ - * @since 4.3.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`. - * @example - * - * _.isArrayBuffer(new ArrayBuffer(2)); - * // => true - * - * _.isArrayBuffer(new Array(2)); - * // => false - */ - var isArrayBuffer = nodeIsArrayBuffer ? baseUnary(nodeIsArrayBuffer) : baseIsArrayBuffer; - - /** - * Checks if `value` is array-like. A value is considered array-like if it's - * not a function and has a `value.length` that's an integer greater than or - * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is array-like, else `false`. - * @example - * - * _.isArrayLike([1, 2, 3]); - * // => true - * - * _.isArrayLike(document.body.children); - * // => true - * - * _.isArrayLike('abc'); - * // => true - * - * _.isArrayLike(_.noop); - * // => false - */ - function isArrayLike(value) { - return value != null && isLength(value.length) && !isFunction(value); - } - - /** - * This method is like `_.isArrayLike` except that it also checks if `value` - * is an object. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is an array-like object, - * else `false`. - * @example - * - * _.isArrayLikeObject([1, 2, 3]); - * // => true - * - * _.isArrayLikeObject(document.body.children); - * // => true - * - * _.isArrayLikeObject('abc'); - * // => false - * - * _.isArrayLikeObject(_.noop); - * // => false - */ - function isArrayLikeObject(value) { - return isObjectLike(value) && isArrayLike(value); - } - - /** - * Checks if `value` is classified as a boolean primitive or object. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a boolean, else `false`. - * @example - * - * _.isBoolean(false); - * // => true - * - * _.isBoolean(null); - * // => false - */ - function isBoolean(value) { - return value === true || value === false || - (isObjectLike(value) && baseGetTag(value) == boolTag); - } - - /** - * Checks if `value` is a buffer. - * - * @static - * @memberOf _ - * @since 4.3.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a buffer, else `false`. - * @example - * - * _.isBuffer(new Buffer(2)); - * // => true - * - * _.isBuffer(new Uint8Array(2)); - * // => false - */ - var isBuffer = nativeIsBuffer || stubFalse; - - /** - * Checks if `value` is classified as a `Date` object. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a date object, else `false`. - * @example - * - * _.isDate(new Date); - * // => true - * - * _.isDate('Mon April 23 2012'); - * // => false - */ - var isDate = nodeIsDate ? baseUnary(nodeIsDate) : baseIsDate; - - /** - * Checks if `value` is likely a DOM element. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a DOM element, else `false`. - * @example - * - * _.isElement(document.body); - * // => true - * - * _.isElement(''); - * // => false - */ - function isElement(value) { - return isObjectLike(value) && value.nodeType === 1 && !isPlainObject(value); - } - - /** - * Checks if `value` is an empty object, collection, map, or set. - * - * Objects are considered empty if they have no own enumerable string keyed - * properties. - * - * Array-like values such as `arguments` objects, arrays, buffers, strings, or - * jQuery-like collections are considered empty if they have a `length` of `0`. - * Similarly, maps and sets are considered empty if they have a `size` of `0`. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is empty, else `false`. - * @example - * - * _.isEmpty(null); - * // => true - * - * _.isEmpty(true); - * // => true - * - * _.isEmpty(1); - * // => true - * - * _.isEmpty([1, 2, 3]); - * // => false - * - * _.isEmpty({ 'a': 1 }); - * // => false - */ - function isEmpty(value) { - if (value == null) { - return true; - } - if (isArrayLike(value) && - (isArray(value) || typeof value == 'string' || typeof value.splice == 'function' || - isBuffer(value) || isTypedArray(value) || isArguments(value))) { - return !value.length; - } - var tag = getTag(value); - if (tag == mapTag || tag == setTag) { - return !value.size; - } - if (isPrototype(value)) { - return !baseKeys(value).length; - } - for (var key in value) { - if (hasOwnProperty.call(value, key)) { - return false; - } - } - return true; - } - - /** - * Performs a deep comparison between two values to determine if they are - * equivalent. - * - * **Note:** This method supports comparing arrays, array buffers, booleans, - * date objects, error objects, maps, numbers, `Object` objects, regexes, - * sets, strings, symbols, and typed arrays. `Object` objects are compared - * by their own, not inherited, enumerable properties. Functions and DOM - * nodes are compared by strict equality, i.e. `===`. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Lang - * @param {*} value The value to compare. - * @param {*} other The other value to compare. - * @returns {boolean} Returns `true` if the values are equivalent, else `false`. - * @example - * - * var object = { 'a': 1 }; - * var other = { 'a': 1 }; - * - * _.isEqual(object, other); - * // => true - * - * object === other; - * // => false - */ - function isEqual(value, other) { - return baseIsEqual(value, other); - } - - /** - * This method is like `_.isEqual` except that it accepts `customizer` which - * is invoked to compare values. If `customizer` returns `undefined`, comparisons - * are handled by the method instead. The `customizer` is invoked with up to - * six arguments: (objValue, othValue [, index|key, object, other, stack]). - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to compare. - * @param {*} other The other value to compare. - * @param {Function} [customizer] The function to customize comparisons. - * @returns {boolean} Returns `true` if the values are equivalent, else `false`. - * @example - * - * function isGreeting(value) { - * return /^h(?:i|ello)$/.test(value); - * } - * - * function customizer(objValue, othValue) { - * if (isGreeting(objValue) && isGreeting(othValue)) { - * return true; - * } - * } - * - * var array = ['hello', 'goodbye']; - * var other = ['hi', 'goodbye']; - * - * _.isEqualWith(array, other, customizer); - * // => true - */ - function isEqualWith(value, other, customizer) { - customizer = typeof customizer == 'function' ? customizer : undefined; - var result = customizer ? customizer(value, other) : undefined; - return result === undefined ? baseIsEqual(value, other, undefined, customizer) : !!result; - } - - /** - * Checks if `value` is an `Error`, `EvalError`, `RangeError`, `ReferenceError`, - * `SyntaxError`, `TypeError`, or `URIError` object. - * - * @static - * @memberOf _ - * @since 3.0.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is an error object, else `false`. - * @example - * - * _.isError(new Error); - * // => true - * - * _.isError(Error); - * // => false - */ - function isError(value) { - if (!isObjectLike(value)) { - return false; - } - var tag = baseGetTag(value); - return tag == errorTag || tag == domExcTag || - (typeof value.message == 'string' && typeof value.name == 'string' && !isPlainObject(value)); - } - - /** - * Checks if `value` is a finite primitive number. - * - * **Note:** This method is based on - * [`Number.isFinite`](https://mdn.io/Number/isFinite). - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a finite number, else `false`. - * @example - * - * _.isFinite(3); - * // => true - * - * _.isFinite(Number.MIN_VALUE); - * // => true - * - * _.isFinite(Infinity); - * // => false - * - * _.isFinite('3'); - * // => false - */ - function isFinite(value) { - return typeof value == 'number' && nativeIsFinite(value); - } - - /** - * Checks if `value` is classified as a `Function` object. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a function, else `false`. - * @example - * - * _.isFunction(_); - * // => true - * - * _.isFunction(/abc/); - * // => false - */ - function isFunction(value) { - if (!isObject(value)) { - return false; - } - // The use of `Object#toString` avoids issues with the `typeof` operator - // in Safari 9 which returns 'object' for typed arrays and other constructors. - var tag = baseGetTag(value); - return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag; - } - - /** - * Checks if `value` is an integer. - * - * **Note:** This method is based on - * [`Number.isInteger`](https://mdn.io/Number/isInteger). - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is an integer, else `false`. - * @example - * - * _.isInteger(3); - * // => true - * - * _.isInteger(Number.MIN_VALUE); - * // => false - * - * _.isInteger(Infinity); - * // => false - * - * _.isInteger('3'); - * // => false - */ - function isInteger(value) { - return typeof value == 'number' && value == toInteger(value); - } - - /** - * Checks if `value` is a valid array-like length. - * - * **Note:** This method is loosely based on - * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength). - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a valid length, else `false`. - * @example - * - * _.isLength(3); - * // => true - * - * _.isLength(Number.MIN_VALUE); - * // => false - * - * _.isLength(Infinity); - * // => false - * - * _.isLength('3'); - * // => false - */ - function isLength(value) { - return typeof value == 'number' && - value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER; - } - - /** - * Checks if `value` is the - * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types) - * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`) - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is an object, else `false`. - * @example - * - * _.isObject({}); - * // => true - * - * _.isObject([1, 2, 3]); - * // => true - * - * _.isObject(_.noop); - * // => true - * - * _.isObject(null); - * // => false - */ - function isObject(value) { - var type = typeof value; - return value != null && (type == 'object' || type == 'function'); - } - - /** - * Checks if `value` is object-like. A value is object-like if it's not `null` - * and has a `typeof` result of "object". - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is object-like, else `false`. - * @example - * - * _.isObjectLike({}); - * // => true - * - * _.isObjectLike([1, 2, 3]); - * // => true - * - * _.isObjectLike(_.noop); - * // => false - * - * _.isObjectLike(null); - * // => false - */ - function isObjectLike(value) { - return value != null && typeof value == 'object'; - } - - /** - * Checks if `value` is classified as a `Map` object. - * - * @static - * @memberOf _ - * @since 4.3.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a map, else `false`. - * @example - * - * _.isMap(new Map); - * // => true - * - * _.isMap(new WeakMap); - * // => false - */ - var isMap = nodeIsMap ? baseUnary(nodeIsMap) : baseIsMap; - - /** - * Performs a partial deep comparison between `object` and `source` to - * determine if `object` contains equivalent property values. - * - * **Note:** This method is equivalent to `_.matches` when `source` is - * partially applied. - * - * Partial comparisons will match empty array and empty object `source` - * values against any array or object value, respectively. See `_.isEqual` - * for a list of supported value comparisons. - * - * @static - * @memberOf _ - * @since 3.0.0 - * @category Lang - * @param {Object} object The object to inspect. - * @param {Object} source The object of property values to match. - * @returns {boolean} Returns `true` if `object` is a match, else `false`. - * @example - * - * var object = { 'a': 1, 'b': 2 }; - * - * _.isMatch(object, { 'b': 2 }); - * // => true - * - * _.isMatch(object, { 'b': 1 }); - * // => false - */ - function isMatch(object, source) { - return object === source || baseIsMatch(object, source, getMatchData(source)); - } - - /** - * This method is like `_.isMatch` except that it accepts `customizer` which - * is invoked to compare values. If `customizer` returns `undefined`, comparisons - * are handled by the method instead. The `customizer` is invoked with five - * arguments: (objValue, srcValue, index|key, object, source). - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {Object} object The object to inspect. - * @param {Object} source The object of property values to match. - * @param {Function} [customizer] The function to customize comparisons. - * @returns {boolean} Returns `true` if `object` is a match, else `false`. - * @example - * - * function isGreeting(value) { - * return /^h(?:i|ello)$/.test(value); - * } - * - * function customizer(objValue, srcValue) { - * if (isGreeting(objValue) && isGreeting(srcValue)) { - * return true; - * } - * } - * - * var object = { 'greeting': 'hello' }; - * var source = { 'greeting': 'hi' }; - * - * _.isMatchWith(object, source, customizer); - * // => true - */ - function isMatchWith(object, source, customizer) { - customizer = typeof customizer == 'function' ? customizer : undefined; - return baseIsMatch(object, source, getMatchData(source), customizer); - } - - /** - * Checks if `value` is `NaN`. - * - * **Note:** This method is based on - * [`Number.isNaN`](https://mdn.io/Number/isNaN) and is not the same as - * global [`isNaN`](https://mdn.io/isNaN) which returns `true` for - * `undefined` and other non-number values. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`. - * @example - * - * _.isNaN(NaN); - * // => true - * - * _.isNaN(new Number(NaN)); - * // => true - * - * isNaN(undefined); - * // => true - * - * _.isNaN(undefined); - * // => false - */ - function isNaN(value) { - // An `NaN` primitive is the only value that is not equal to itself. - // Perform the `toStringTag` check first to avoid errors with some - // ActiveX objects in IE. - return isNumber(value) && value != +value; - } - - /** - * Checks if `value` is a pristine native function. - * - * **Note:** This method can't reliably detect native functions in the presence - * of the core-js package because core-js circumvents this kind of detection. - * Despite multiple requests, the core-js maintainer has made it clear: any - * attempt to fix the detection will be obstructed. As a result, we're left - * with little choice but to throw an error. Unfortunately, this also affects - * packages, like [babel-polyfill](https://www.npmjs.com/package/babel-polyfill), - * which rely on core-js. - * - * @static - * @memberOf _ - * @since 3.0.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a native function, - * else `false`. - * @example - * - * _.isNative(Array.prototype.push); - * // => true - * - * _.isNative(_); - * // => false - */ - function isNative(value) { - if (isMaskable(value)) { - throw new Error(CORE_ERROR_TEXT); - } - return baseIsNative(value); - } - - /** - * Checks if `value` is `null`. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is `null`, else `false`. - * @example - * - * _.isNull(null); - * // => true - * - * _.isNull(void 0); - * // => false - */ - function isNull(value) { - return value === null; - } - - /** - * Checks if `value` is `null` or `undefined`. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is nullish, else `false`. - * @example - * - * _.isNil(null); - * // => true - * - * _.isNil(void 0); - * // => true - * - * _.isNil(NaN); - * // => false - */ - function isNil(value) { - return value == null; - } - - /** - * Checks if `value` is classified as a `Number` primitive or object. - * - * **Note:** To exclude `Infinity`, `-Infinity`, and `NaN`, which are - * classified as numbers, use the `_.isFinite` method. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a number, else `false`. - * @example - * - * _.isNumber(3); - * // => true - * - * _.isNumber(Number.MIN_VALUE); - * // => true - * - * _.isNumber(Infinity); - * // => true - * - * _.isNumber('3'); - * // => false - */ - function isNumber(value) { - return typeof value == 'number' || - (isObjectLike(value) && baseGetTag(value) == numberTag); - } - - /** - * Checks if `value` is a plain object, that is, an object created by the - * `Object` constructor or one with a `[[Prototype]]` of `null`. - * - * @static - * @memberOf _ - * @since 0.8.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a plain object, else `false`. - * @example - * - * function Foo() { - * this.a = 1; - * } - * - * _.isPlainObject(new Foo); - * // => false - * - * _.isPlainObject([1, 2, 3]); - * // => false - * - * _.isPlainObject({ 'x': 0, 'y': 0 }); - * // => true - * - * _.isPlainObject(Object.create(null)); - * // => true - */ - function isPlainObject(value) { - if (!isObjectLike(value) || baseGetTag(value) != objectTag) { - return false; - } - var proto = getPrototype(value); - if (proto === null) { - return true; - } - var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor; - return typeof Ctor == 'function' && Ctor instanceof Ctor && - funcToString.call(Ctor) == objectCtorString; - } - - /** - * Checks if `value` is classified as a `RegExp` object. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a regexp, else `false`. - * @example - * - * _.isRegExp(/abc/); - * // => true - * - * _.isRegExp('/abc/'); - * // => false - */ - var isRegExp = nodeIsRegExp ? baseUnary(nodeIsRegExp) : baseIsRegExp; - - /** - * Checks if `value` is a safe integer. An integer is safe if it's an IEEE-754 - * double precision number which isn't the result of a rounded unsafe integer. - * - * **Note:** This method is based on - * [`Number.isSafeInteger`](https://mdn.io/Number/isSafeInteger). - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a safe integer, else `false`. - * @example - * - * _.isSafeInteger(3); - * // => true - * - * _.isSafeInteger(Number.MIN_VALUE); - * // => false - * - * _.isSafeInteger(Infinity); - * // => false - * - * _.isSafeInteger('3'); - * // => false - */ - function isSafeInteger(value) { - return isInteger(value) && value >= -MAX_SAFE_INTEGER && value <= MAX_SAFE_INTEGER; - } - - /** - * Checks if `value` is classified as a `Set` object. - * - * @static - * @memberOf _ - * @since 4.3.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a set, else `false`. - * @example - * - * _.isSet(new Set); - * // => true - * - * _.isSet(new WeakSet); - * // => false - */ - var isSet = nodeIsSet ? baseUnary(nodeIsSet) : baseIsSet; - - /** - * Checks if `value` is classified as a `String` primitive or object. - * - * @static - * @since 0.1.0 - * @memberOf _ - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a string, else `false`. - * @example - * - * _.isString('abc'); - * // => true - * - * _.isString(1); - * // => false - */ - function isString(value) { - return typeof value == 'string' || - (!isArray(value) && isObjectLike(value) && baseGetTag(value) == stringTag); - } - - /** - * Checks if `value` is classified as a `Symbol` primitive or object. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a symbol, else `false`. - * @example - * - * _.isSymbol(Symbol.iterator); - * // => true - * - * _.isSymbol('abc'); - * // => false - */ - function isSymbol(value) { - return typeof value == 'symbol' || - (isObjectLike(value) && baseGetTag(value) == symbolTag); - } - - /** - * Checks if `value` is classified as a typed array. - * - * @static - * @memberOf _ - * @since 3.0.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a typed array, else `false`. - * @example - * - * _.isTypedArray(new Uint8Array); - * // => true - * - * _.isTypedArray([]); - * // => false - */ - var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray; - - /** - * Checks if `value` is `undefined`. - * - * @static - * @since 0.1.0 - * @memberOf _ - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is `undefined`, else `false`. - * @example - * - * _.isUndefined(void 0); - * // => true - * - * _.isUndefined(null); - * // => false - */ - function isUndefined(value) { - return value === undefined; - } - - /** - * Checks if `value` is classified as a `WeakMap` object. - * - * @static - * @memberOf _ - * @since 4.3.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a weak map, else `false`. - * @example - * - * _.isWeakMap(new WeakMap); - * // => true - * - * _.isWeakMap(new Map); - * // => false - */ - function isWeakMap(value) { - return isObjectLike(value) && getTag(value) == weakMapTag; - } - - /** - * Checks if `value` is classified as a `WeakSet` object. - * - * @static - * @memberOf _ - * @since 4.3.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a weak set, else `false`. - * @example - * - * _.isWeakSet(new WeakSet); - * // => true - * - * _.isWeakSet(new Set); - * // => false - */ - function isWeakSet(value) { - return isObjectLike(value) && baseGetTag(value) == weakSetTag; - } - - /** - * Checks if `value` is less than `other`. - * - * @static - * @memberOf _ - * @since 3.9.0 - * @category Lang - * @param {*} value The value to compare. - * @param {*} other The other value to compare. - * @returns {boolean} Returns `true` if `value` is less than `other`, - * else `false`. - * @see _.gt - * @example - * - * _.lt(1, 3); - * // => true - * - * _.lt(3, 3); - * // => false - * - * _.lt(3, 1); - * // => false - */ - var lt = createRelationalOperation(baseLt); - - /** - * Checks if `value` is less than or equal to `other`. - * - * @static - * @memberOf _ - * @since 3.9.0 - * @category Lang - * @param {*} value The value to compare. - * @param {*} other The other value to compare. - * @returns {boolean} Returns `true` if `value` is less than or equal to - * `other`, else `false`. - * @see _.gte - * @example - * - * _.lte(1, 3); - * // => true - * - * _.lte(3, 3); - * // => true - * - * _.lte(3, 1); - * // => false - */ - var lte = createRelationalOperation(function(value, other) { - return value <= other; - }); - - /** - * Converts `value` to an array. - * - * @static - * @since 0.1.0 - * @memberOf _ - * @category Lang - * @param {*} value The value to convert. - * @returns {Array} Returns the converted array. - * @example - * - * _.toArray({ 'a': 1, 'b': 2 }); - * // => [1, 2] - * - * _.toArray('abc'); - * // => ['a', 'b', 'c'] - * - * _.toArray(1); - * // => [] - * - * _.toArray(null); - * // => [] - */ - function toArray(value) { - if (!value) { - return []; - } - if (isArrayLike(value)) { - return isString(value) ? stringToArray(value) : copyArray(value); - } - if (symIterator && value[symIterator]) { - return iteratorToArray(value[symIterator]()); - } - var tag = getTag(value), - func = tag == mapTag ? mapToArray : (tag == setTag ? setToArray : values); - - return func(value); - } - - /** - * Converts `value` to a finite number. - * - * @static - * @memberOf _ - * @since 4.12.0 - * @category Lang - * @param {*} value The value to convert. - * @returns {number} Returns the converted number. - * @example - * - * _.toFinite(3.2); - * // => 3.2 - * - * _.toFinite(Number.MIN_VALUE); - * // => 5e-324 - * - * _.toFinite(Infinity); - * // => 1.7976931348623157e+308 - * - * _.toFinite('3.2'); - * // => 3.2 - */ - function toFinite(value) { - if (!value) { - return value === 0 ? value : 0; - } - value = toNumber(value); - if (value === INFINITY || value === -INFINITY) { - var sign = (value < 0 ? -1 : 1); - return sign * MAX_INTEGER; - } - return value === value ? value : 0; - } - - /** - * Converts `value` to an integer. - * - * **Note:** This method is loosely based on - * [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger). - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to convert. - * @returns {number} Returns the converted integer. - * @example - * - * _.toInteger(3.2); - * // => 3 - * - * _.toInteger(Number.MIN_VALUE); - * // => 0 - * - * _.toInteger(Infinity); - * // => 1.7976931348623157e+308 - * - * _.toInteger('3.2'); - * // => 3 - */ - function toInteger(value) { - var result = toFinite(value), - remainder = result % 1; - - return result === result ? (remainder ? result - remainder : result) : 0; - } - - /** - * Converts `value` to an integer suitable for use as the length of an - * array-like object. - * - * **Note:** This method is based on - * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength). - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to convert. - * @returns {number} Returns the converted integer. - * @example - * - * _.toLength(3.2); - * // => 3 - * - * _.toLength(Number.MIN_VALUE); - * // => 0 - * - * _.toLength(Infinity); - * // => 4294967295 - * - * _.toLength('3.2'); - * // => 3 - */ - function toLength(value) { - return value ? baseClamp(toInteger(value), 0, MAX_ARRAY_LENGTH) : 0; - } - - /** - * Converts `value` to a number. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to process. - * @returns {number} Returns the number. - * @example - * - * _.toNumber(3.2); - * // => 3.2 - * - * _.toNumber(Number.MIN_VALUE); - * // => 5e-324 - * - * _.toNumber(Infinity); - * // => Infinity - * - * _.toNumber('3.2'); - * // => 3.2 - */ - function toNumber(value) { - if (typeof value == 'number') { - return value; - } - if (isSymbol(value)) { - return NAN; - } - if (isObject(value)) { - var other = typeof value.valueOf == 'function' ? value.valueOf() : value; - value = isObject(other) ? (other + '') : other; - } - if (typeof value != 'string') { - return value === 0 ? value : +value; - } - value = value.replace(reTrim, ''); - var isBinary = reIsBinary.test(value); - return (isBinary || reIsOctal.test(value)) - ? freeParseInt(value.slice(2), isBinary ? 2 : 8) - : (reIsBadHex.test(value) ? NAN : +value); - } - - /** - * Converts `value` to a plain object flattening inherited enumerable string - * keyed properties of `value` to own properties of the plain object. - * - * @static - * @memberOf _ - * @since 3.0.0 - * @category Lang - * @param {*} value The value to convert. - * @returns {Object} Returns the converted plain object. - * @example - * - * function Foo() { - * this.b = 2; - * } - * - * Foo.prototype.c = 3; - * - * _.assign({ 'a': 1 }, new Foo); - * // => { 'a': 1, 'b': 2 } - * - * _.assign({ 'a': 1 }, _.toPlainObject(new Foo)); - * // => { 'a': 1, 'b': 2, 'c': 3 } - */ - function toPlainObject(value) { - return copyObject(value, keysIn(value)); - } - - /** - * Converts `value` to a safe integer. A safe integer can be compared and - * represented correctly. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to convert. - * @returns {number} Returns the converted integer. - * @example - * - * _.toSafeInteger(3.2); - * // => 3 - * - * _.toSafeInteger(Number.MIN_VALUE); - * // => 0 - * - * _.toSafeInteger(Infinity); - * // => 9007199254740991 - * - * _.toSafeInteger('3.2'); - * // => 3 - */ - function toSafeInteger(value) { - return value - ? baseClamp(toInteger(value), -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER) - : (value === 0 ? value : 0); - } - - /** - * Converts `value` to a string. An empty string is returned for `null` - * and `undefined` values. The sign of `-0` is preserved. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to convert. - * @returns {string} Returns the converted string. - * @example - * - * _.toString(null); - * // => '' - * - * _.toString(-0); - * // => '-0' - * - * _.toString([1, 2, 3]); - * // => '1,2,3' - */ - function toString(value) { - return value == null ? '' : baseToString(value); - } - - /*------------------------------------------------------------------------*/ - - /** - * Assigns own enumerable string keyed properties of source objects to the - * destination object. Source objects are applied from left to right. - * Subsequent sources overwrite property assignments of previous sources. - * - * **Note:** This method mutates `object` and is loosely based on - * [`Object.assign`](https://mdn.io/Object/assign). - * - * @static - * @memberOf _ - * @since 0.10.0 - * @category Object - * @param {Object} object The destination object. - * @param {...Object} [sources] The source objects. - * @returns {Object} Returns `object`. - * @see _.assignIn - * @example - * - * function Foo() { - * this.a = 1; - * } - * - * function Bar() { - * this.c = 3; - * } - * - * Foo.prototype.b = 2; - * Bar.prototype.d = 4; - * - * _.assign({ 'a': 0 }, new Foo, new Bar); - * // => { 'a': 1, 'c': 3 } - */ - var assign = createAssigner(function(object, source) { - if (isPrototype(source) || isArrayLike(source)) { - copyObject(source, keys(source), object); - return; - } - for (var key in source) { - if (hasOwnProperty.call(source, key)) { - assignValue(object, key, source[key]); - } - } - }); - - /** - * This method is like `_.assign` except that it iterates over own and - * inherited source properties. - * - * **Note:** This method mutates `object`. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @alias extend - * @category Object - * @param {Object} object The destination object. - * @param {...Object} [sources] The source objects. - * @returns {Object} Returns `object`. - * @see _.assign - * @example - * - * function Foo() { - * this.a = 1; - * } - * - * function Bar() { - * this.c = 3; - * } - * - * Foo.prototype.b = 2; - * Bar.prototype.d = 4; - * - * _.assignIn({ 'a': 0 }, new Foo, new Bar); - * // => { 'a': 1, 'b': 2, 'c': 3, 'd': 4 } - */ - var assignIn = createAssigner(function(object, source) { - copyObject(source, keysIn(source), object); - }); - - /** - * This method is like `_.assignIn` except that it accepts `customizer` - * which is invoked to produce the assigned values. If `customizer` returns - * `undefined`, assignment is handled by the method instead. The `customizer` - * is invoked with five arguments: (objValue, srcValue, key, object, source). - * - * **Note:** This method mutates `object`. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @alias extendWith - * @category Object - * @param {Object} object The destination object. - * @param {...Object} sources The source objects. - * @param {Function} [customizer] The function to customize assigned values. - * @returns {Object} Returns `object`. - * @see _.assignWith - * @example - * - * function customizer(objValue, srcValue) { - * return _.isUndefined(objValue) ? srcValue : objValue; - * } - * - * var defaults = _.partialRight(_.assignInWith, customizer); - * - * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 }); - * // => { 'a': 1, 'b': 2 } - */ - var assignInWith = createAssigner(function(object, source, srcIndex, customizer) { - copyObject(source, keysIn(source), object, customizer); - }); - - /** - * This method is like `_.assign` except that it accepts `customizer` - * which is invoked to produce the assigned values. If `customizer` returns - * `undefined`, assignment is handled by the method instead. The `customizer` - * is invoked with five arguments: (objValue, srcValue, key, object, source). - * - * **Note:** This method mutates `object`. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Object - * @param {Object} object The destination object. - * @param {...Object} sources The source objects. - * @param {Function} [customizer] The function to customize assigned values. - * @returns {Object} Returns `object`. - * @see _.assignInWith - * @example - * - * function customizer(objValue, srcValue) { - * return _.isUndefined(objValue) ? srcValue : objValue; - * } - * - * var defaults = _.partialRight(_.assignWith, customizer); - * - * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 }); - * // => { 'a': 1, 'b': 2 } - */ - var assignWith = createAssigner(function(object, source, srcIndex, customizer) { - copyObject(source, keys(source), object, customizer); - }); - - /** - * Creates an array of values corresponding to `paths` of `object`. - * - * @static - * @memberOf _ - * @since 1.0.0 - * @category Object - * @param {Object} object The object to iterate over. - * @param {...(string|string[])} [paths] The property paths to pick. - * @returns {Array} Returns the picked values. - * @example - * - * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] }; - * - * _.at(object, ['a[0].b.c', 'a[1]']); - * // => [3, 4] - */ - var at = flatRest(baseAt); - - /** - * Creates an object that inherits from the `prototype` object. If a - * `properties` object is given, its own enumerable string keyed properties - * are assigned to the created object. - * - * @static - * @memberOf _ - * @since 2.3.0 - * @category Object - * @param {Object} prototype The object to inherit from. - * @param {Object} [properties] The properties to assign to the object. - * @returns {Object} Returns the new object. - * @example - * - * function Shape() { - * this.x = 0; - * this.y = 0; - * } - * - * function Circle() { - * Shape.call(this); - * } - * - * Circle.prototype = _.create(Shape.prototype, { - * 'constructor': Circle - * }); - * - * var circle = new Circle; - * circle instanceof Circle; - * // => true - * - * circle instanceof Shape; - * // => true - */ - function create(prototype, properties) { - var result = baseCreate(prototype); - return properties == null ? result : baseAssign(result, properties); - } - - /** - * Assigns own and inherited enumerable string keyed properties of source - * objects to the destination object for all destination properties that - * resolve to `undefined`. Source objects are applied from left to right. - * Once a property is set, additional values of the same property are ignored. - * - * **Note:** This method mutates `object`. - * - * @static - * @since 0.1.0 - * @memberOf _ - * @category Object - * @param {Object} object The destination object. - * @param {...Object} [sources] The source objects. - * @returns {Object} Returns `object`. - * @see _.defaultsDeep - * @example - * - * _.defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 }); - * // => { 'a': 1, 'b': 2 } - */ - var defaults = baseRest(function(args) { - args.push(undefined, customDefaultsAssignIn); - return apply(assignInWith, undefined, args); - }); - - /** - * This method is like `_.defaults` except that it recursively assigns - * default properties. - * - * **Note:** This method mutates `object`. - * - * @static - * @memberOf _ - * @since 3.10.0 - * @category Object - * @param {Object} object The destination object. - * @param {...Object} [sources] The source objects. - * @returns {Object} Returns `object`. - * @see _.defaults - * @example - * - * _.defaultsDeep({ 'a': { 'b': 2 } }, { 'a': { 'b': 1, 'c': 3 } }); - * // => { 'a': { 'b': 2, 'c': 3 } } - */ - var defaultsDeep = baseRest(function(args) { - args.push(undefined, customDefaultsMerge); - return apply(mergeWith, undefined, args); - }); - - /** - * This method is like `_.find` except that it returns the key of the first - * element `predicate` returns truthy for instead of the element itself. - * - * @static - * @memberOf _ - * @since 1.1.0 - * @category Object - * @param {Object} object The object to inspect. - * @param {Function} [predicate=_.identity] The function invoked per iteration. - * @returns {string|undefined} Returns the key of the matched element, - * else `undefined`. - * @example - * - * var users = { - * 'barney': { 'age': 36, 'active': true }, - * 'fred': { 'age': 40, 'active': false }, - * 'pebbles': { 'age': 1, 'active': true } - * }; - * - * _.findKey(users, function(o) { return o.age < 40; }); - * // => 'barney' (iteration order is not guaranteed) - * - * // The `_.matches` iteratee shorthand. - * _.findKey(users, { 'age': 1, 'active': true }); - * // => 'pebbles' - * - * // The `_.matchesProperty` iteratee shorthand. - * _.findKey(users, ['active', false]); - * // => 'fred' - * - * // The `_.property` iteratee shorthand. - * _.findKey(users, 'active'); - * // => 'barney' - */ - function findKey(object, predicate) { - return baseFindKey(object, getIteratee(predicate, 3), baseForOwn); - } - - /** - * This method is like `_.findKey` except that it iterates over elements of - * a collection in the opposite order. - * - * @static - * @memberOf _ - * @since 2.0.0 - * @category Object - * @param {Object} object The object to inspect. - * @param {Function} [predicate=_.identity] The function invoked per iteration. - * @returns {string|undefined} Returns the key of the matched element, - * else `undefined`. - * @example - * - * var users = { - * 'barney': { 'age': 36, 'active': true }, - * 'fred': { 'age': 40, 'active': false }, - * 'pebbles': { 'age': 1, 'active': true } - * }; - * - * _.findLastKey(users, function(o) { return o.age < 40; }); - * // => returns 'pebbles' assuming `_.findKey` returns 'barney' - * - * // The `_.matches` iteratee shorthand. - * _.findLastKey(users, { 'age': 36, 'active': true }); - * // => 'barney' - * - * // The `_.matchesProperty` iteratee shorthand. - * _.findLastKey(users, ['active', false]); - * // => 'fred' - * - * // The `_.property` iteratee shorthand. - * _.findLastKey(users, 'active'); - * // => 'pebbles' - */ - function findLastKey(object, predicate) { - return baseFindKey(object, getIteratee(predicate, 3), baseForOwnRight); - } - - /** - * Iterates over own and inherited enumerable string keyed properties of an - * object and invokes `iteratee` for each property. The iteratee is invoked - * with three arguments: (value, key, object). Iteratee functions may exit - * iteration early by explicitly returning `false`. - * - * @static - * @memberOf _ - * @since 0.3.0 - * @category Object - * @param {Object} object The object to iterate over. - * @param {Function} [iteratee=_.identity] The function invoked per iteration. - * @returns {Object} Returns `object`. - * @see _.forInRight - * @example - * - * function Foo() { - * this.a = 1; - * this.b = 2; - * } - * - * Foo.prototype.c = 3; - * - * _.forIn(new Foo, function(value, key) { - * console.log(key); - * }); - * // => Logs 'a', 'b', then 'c' (iteration order is not guaranteed). - */ - function forIn(object, iteratee) { - return object == null - ? object - : baseFor(object, getIteratee(iteratee, 3), keysIn); - } - - /** - * This method is like `_.forIn` except that it iterates over properties of - * `object` in the opposite order. - * - * @static - * @memberOf _ - * @since 2.0.0 - * @category Object - * @param {Object} object The object to iterate over. - * @param {Function} [iteratee=_.identity] The function invoked per iteration. - * @returns {Object} Returns `object`. - * @see _.forIn - * @example - * - * function Foo() { - * this.a = 1; - * this.b = 2; - * } - * - * Foo.prototype.c = 3; - * - * _.forInRight(new Foo, function(value, key) { - * console.log(key); - * }); - * // => Logs 'c', 'b', then 'a' assuming `_.forIn` logs 'a', 'b', then 'c'. - */ - function forInRight(object, iteratee) { - return object == null - ? object - : baseForRight(object, getIteratee(iteratee, 3), keysIn); - } - - /** - * Iterates over own enumerable string keyed properties of an object and - * invokes `iteratee` for each property. The iteratee is invoked with three - * arguments: (value, key, object). Iteratee functions may exit iteration - * early by explicitly returning `false`. - * - * @static - * @memberOf _ - * @since 0.3.0 - * @category Object - * @param {Object} object The object to iterate over. - * @param {Function} [iteratee=_.identity] The function invoked per iteration. - * @returns {Object} Returns `object`. - * @see _.forOwnRight - * @example - * - * function Foo() { - * this.a = 1; - * this.b = 2; - * } - * - * Foo.prototype.c = 3; - * - * _.forOwn(new Foo, function(value, key) { - * console.log(key); - * }); - * // => Logs 'a' then 'b' (iteration order is not guaranteed). - */ - function forOwn(object, iteratee) { - return object && baseForOwn(object, getIteratee(iteratee, 3)); - } - - /** - * This method is like `_.forOwn` except that it iterates over properties of - * `object` in the opposite order. - * - * @static - * @memberOf _ - * @since 2.0.0 - * @category Object - * @param {Object} object The object to iterate over. - * @param {Function} [iteratee=_.identity] The function invoked per iteration. - * @returns {Object} Returns `object`. - * @see _.forOwn - * @example - * - * function Foo() { - * this.a = 1; - * this.b = 2; - * } - * - * Foo.prototype.c = 3; - * - * _.forOwnRight(new Foo, function(value, key) { - * console.log(key); - * }); - * // => Logs 'b' then 'a' assuming `_.forOwn` logs 'a' then 'b'. - */ - function forOwnRight(object, iteratee) { - return object && baseForOwnRight(object, getIteratee(iteratee, 3)); - } - - /** - * Creates an array of function property names from own enumerable properties - * of `object`. - * - * @static - * @since 0.1.0 - * @memberOf _ - * @category Object - * @param {Object} object The object to inspect. - * @returns {Array} Returns the function names. - * @see _.functionsIn - * @example - * - * function Foo() { - * this.a = _.constant('a'); - * this.b = _.constant('b'); - * } - * - * Foo.prototype.c = _.constant('c'); - * - * _.functions(new Foo); - * // => ['a', 'b'] - */ - function functions(object) { - return object == null ? [] : baseFunctions(object, keys(object)); - } - - /** - * Creates an array of function property names from own and inherited - * enumerable properties of `object`. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Object - * @param {Object} object The object to inspect. - * @returns {Array} Returns the function names. - * @see _.functions - * @example - * - * function Foo() { - * this.a = _.constant('a'); - * this.b = _.constant('b'); - * } - * - * Foo.prototype.c = _.constant('c'); - * - * _.functionsIn(new Foo); - * // => ['a', 'b', 'c'] - */ - function functionsIn(object) { - return object == null ? [] : baseFunctions(object, keysIn(object)); - } - - /** - * Gets the value at `path` of `object`. If the resolved value is - * `undefined`, the `defaultValue` is returned in its place. - * - * @static - * @memberOf _ - * @since 3.7.0 - * @category Object - * @param {Object} object The object to query. - * @param {Array|string} path The path of the property to get. - * @param {*} [defaultValue] The value returned for `undefined` resolved values. - * @returns {*} Returns the resolved value. - * @example - * - * var object = { 'a': [{ 'b': { 'c': 3 } }] }; - * - * _.get(object, 'a[0].b.c'); - * // => 3 - * - * _.get(object, ['a', '0', 'b', 'c']); - * // => 3 - * - * _.get(object, 'a.b.c', 'default'); - * // => 'default' - */ - function get(object, path, defaultValue) { - var result = object == null ? undefined : baseGet(object, path); - return result === undefined ? defaultValue : result; - } - - /** - * Checks if `path` is a direct property of `object`. - * - * @static - * @since 0.1.0 - * @memberOf _ - * @category Object - * @param {Object} object The object to query. - * @param {Array|string} path The path to check. - * @returns {boolean} Returns `true` if `path` exists, else `false`. - * @example - * - * var object = { 'a': { 'b': 2 } }; - * var other = _.create({ 'a': _.create({ 'b': 2 }) }); - * - * _.has(object, 'a'); - * // => true - * - * _.has(object, 'a.b'); - * // => true - * - * _.has(object, ['a', 'b']); - * // => true - * - * _.has(other, 'a'); - * // => false - */ - function has(object, path) { - return object != null && hasPath(object, path, baseHas); - } - - /** - * Checks if `path` is a direct or inherited property of `object`. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Object - * @param {Object} object The object to query. - * @param {Array|string} path The path to check. - * @returns {boolean} Returns `true` if `path` exists, else `false`. - * @example - * - * var object = _.create({ 'a': _.create({ 'b': 2 }) }); - * - * _.hasIn(object, 'a'); - * // => true - * - * _.hasIn(object, 'a.b'); - * // => true - * - * _.hasIn(object, ['a', 'b']); - * // => true - * - * _.hasIn(object, 'b'); - * // => false - */ - function hasIn(object, path) { - return object != null && hasPath(object, path, baseHasIn); - } - - /** - * Creates an object composed of the inverted keys and values of `object`. - * If `object` contains duplicate values, subsequent values overwrite - * property assignments of previous values. - * - * @static - * @memberOf _ - * @since 0.7.0 - * @category Object - * @param {Object} object The object to invert. - * @returns {Object} Returns the new inverted object. - * @example - * - * var object = { 'a': 1, 'b': 2, 'c': 1 }; - * - * _.invert(object); - * // => { '1': 'c', '2': 'b' } - */ - var invert = createInverter(function(result, value, key) { - result[value] = key; - }, constant(identity)); - - /** - * This method is like `_.invert` except that the inverted object is generated - * from the results of running each element of `object` thru `iteratee`. The - * corresponding inverted value of each inverted key is an array of keys - * responsible for generating the inverted value. The iteratee is invoked - * with one argument: (value). - * - * @static - * @memberOf _ - * @since 4.1.0 - * @category Object - * @param {Object} object The object to invert. - * @param {Function} [iteratee=_.identity] The iteratee invoked per element. - * @returns {Object} Returns the new inverted object. - * @example - * - * var object = { 'a': 1, 'b': 2, 'c': 1 }; - * - * _.invertBy(object); - * // => { '1': ['a', 'c'], '2': ['b'] } - * - * _.invertBy(object, function(value) { - * return 'group' + value; - * }); - * // => { 'group1': ['a', 'c'], 'group2': ['b'] } - */ - var invertBy = createInverter(function(result, value, key) { - if (hasOwnProperty.call(result, value)) { - result[value].push(key); - } else { - result[value] = [key]; - } - }, getIteratee); - - /** - * Invokes the method at `path` of `object`. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Object - * @param {Object} object The object to query. - * @param {Array|string} path The path of the method to invoke. - * @param {...*} [args] The arguments to invoke the method with. - * @returns {*} Returns the result of the invoked method. - * @example - * - * var object = { 'a': [{ 'b': { 'c': [1, 2, 3, 4] } }] }; - * - * _.invoke(object, 'a[0].b.c.slice', 1, 3); - * // => [2, 3] - */ - var invoke = baseRest(baseInvoke); - - /** - * Creates an array of the own enumerable property names of `object`. - * - * **Note:** Non-object values are coerced to objects. See the - * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys) - * for more details. - * - * @static - * @since 0.1.0 - * @memberOf _ - * @category Object - * @param {Object} object The object to query. - * @returns {Array} Returns the array of property names. - * @example - * - * function Foo() { - * this.a = 1; - * this.b = 2; - * } - * - * Foo.prototype.c = 3; - * - * _.keys(new Foo); - * // => ['a', 'b'] (iteration order is not guaranteed) - * - * _.keys('hi'); - * // => ['0', '1'] - */ - function keys(object) { - return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object); - } - - /** - * Creates an array of the own and inherited enumerable property names of `object`. - * - * **Note:** Non-object values are coerced to objects. - * - * @static - * @memberOf _ - * @since 3.0.0 - * @category Object - * @param {Object} object The object to query. - * @returns {Array} Returns the array of property names. - * @example - * - * function Foo() { - * this.a = 1; - * this.b = 2; - * } - * - * Foo.prototype.c = 3; - * - * _.keysIn(new Foo); - * // => ['a', 'b', 'c'] (iteration order is not guaranteed) - */ - function keysIn(object) { - return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object); - } - - /** - * The opposite of `_.mapValues`; this method creates an object with the - * same values as `object` and keys generated by running each own enumerable - * string keyed property of `object` thru `iteratee`. The iteratee is invoked - * with three arguments: (value, key, object). - * - * @static - * @memberOf _ - * @since 3.8.0 - * @category Object - * @param {Object} object The object to iterate over. - * @param {Function} [iteratee=_.identity] The function invoked per iteration. - * @returns {Object} Returns the new mapped object. - * @see _.mapValues - * @example - * - * _.mapKeys({ 'a': 1, 'b': 2 }, function(value, key) { - * return key + value; - * }); - * // => { 'a1': 1, 'b2': 2 } - */ - function mapKeys(object, iteratee) { - var result = {}; - iteratee = getIteratee(iteratee, 3); - - baseForOwn(object, function(value, key, object) { - baseAssignValue(result, iteratee(value, key, object), value); - }); - return result; - } - - /** - * Creates an object with the same keys as `object` and values generated - * by running each own enumerable string keyed property of `object` thru - * `iteratee`. The iteratee is invoked with three arguments: - * (value, key, object). - * - * @static - * @memberOf _ - * @since 2.4.0 - * @category Object - * @param {Object} object The object to iterate over. - * @param {Function} [iteratee=_.identity] The function invoked per iteration. - * @returns {Object} Returns the new mapped object. - * @see _.mapKeys - * @example - * - * var users = { - * 'fred': { 'user': 'fred', 'age': 40 }, - * 'pebbles': { 'user': 'pebbles', 'age': 1 } - * }; - * - * _.mapValues(users, function(o) { return o.age; }); - * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed) - * - * // The `_.property` iteratee shorthand. - * _.mapValues(users, 'age'); - * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed) - */ - function mapValues(object, iteratee) { - var result = {}; - iteratee = getIteratee(iteratee, 3); - - baseForOwn(object, function(value, key, object) { - baseAssignValue(result, key, iteratee(value, key, object)); - }); - return result; - } - - /** - * This method is like `_.assign` except that it recursively merges own and - * inherited enumerable string keyed properties of source objects into the - * destination object. Source properties that resolve to `undefined` are - * skipped if a destination value exists. Array and plain object properties - * are merged recursively. Other objects and value types are overridden by - * assignment. Source objects are applied from left to right. Subsequent - * sources overwrite property assignments of previous sources. - * - * **Note:** This method mutates `object`. - * - * @static - * @memberOf _ - * @since 0.5.0 - * @category Object - * @param {Object} object The destination object. - * @param {...Object} [sources] The source objects. - * @returns {Object} Returns `object`. - * @example - * - * var object = { - * 'a': [{ 'b': 2 }, { 'd': 4 }] - * }; - * - * var other = { - * 'a': [{ 'c': 3 }, { 'e': 5 }] - * }; - * - * _.merge(object, other); - * // => { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] } - */ - var merge = createAssigner(function(object, source, srcIndex) { - baseMerge(object, source, srcIndex); - }); - - /** - * This method is like `_.merge` except that it accepts `customizer` which - * is invoked to produce the merged values of the destination and source - * properties. If `customizer` returns `undefined`, merging is handled by the - * method instead. The `customizer` is invoked with six arguments: - * (objValue, srcValue, key, object, source, stack). - * - * **Note:** This method mutates `object`. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Object - * @param {Object} object The destination object. - * @param {...Object} sources The source objects. - * @param {Function} customizer The function to customize assigned values. - * @returns {Object} Returns `object`. - * @example - * - * function customizer(objValue, srcValue) { - * if (_.isArray(objValue)) { - * return objValue.concat(srcValue); - * } - * } - * - * var object = { 'a': [1], 'b': [2] }; - * var other = { 'a': [3], 'b': [4] }; - * - * _.mergeWith(object, other, customizer); - * // => { 'a': [1, 3], 'b': [2, 4] } - */ - var mergeWith = createAssigner(function(object, source, srcIndex, customizer) { - baseMerge(object, source, srcIndex, customizer); - }); - - /** - * The opposite of `_.pick`; this method creates an object composed of the - * own and inherited enumerable property paths of `object` that are not omitted. - * - * **Note:** This method is considerably slower than `_.pick`. - * - * @static - * @since 0.1.0 - * @memberOf _ - * @category Object - * @param {Object} object The source object. - * @param {...(string|string[])} [paths] The property paths to omit. - * @returns {Object} Returns the new object. - * @example - * - * var object = { 'a': 1, 'b': '2', 'c': 3 }; - * - * _.omit(object, ['a', 'c']); - * // => { 'b': '2' } - */ - var omit = flatRest(function(object, paths) { - var result = {}; - if (object == null) { - return result; - } - var isDeep = false; - paths = arrayMap(paths, function(path) { - path = castPath(path, object); - isDeep || (isDeep = path.length > 1); - return path; - }); - copyObject(object, getAllKeysIn(object), result); - if (isDeep) { - result = baseClone(result, CLONE_DEEP_FLAG | CLONE_FLAT_FLAG | CLONE_SYMBOLS_FLAG, customOmitClone); - } - var length = paths.length; - while (length--) { - baseUnset(result, paths[length]); - } - return result; - }); - - /** - * The opposite of `_.pickBy`; this method creates an object composed of - * the own and inherited enumerable string keyed properties of `object` that - * `predicate` doesn't return truthy for. The predicate is invoked with two - * arguments: (value, key). - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Object - * @param {Object} object The source object. - * @param {Function} [predicate=_.identity] The function invoked per property. - * @returns {Object} Returns the new object. - * @example - * - * var object = { 'a': 1, 'b': '2', 'c': 3 }; - * - * _.omitBy(object, _.isNumber); - * // => { 'b': '2' } - */ - function omitBy(object, predicate) { - return pickBy(object, negate(getIteratee(predicate))); - } - - /** - * Creates an object composed of the picked `object` properties. - * - * @static - * @since 0.1.0 - * @memberOf _ - * @category Object - * @param {Object} object The source object. - * @param {...(string|string[])} [paths] The property paths to pick. - * @returns {Object} Returns the new object. - * @example - * - * var object = { 'a': 1, 'b': '2', 'c': 3 }; - * - * _.pick(object, ['a', 'c']); - * // => { 'a': 1, 'c': 3 } - */ - var pick = flatRest(function(object, paths) { - return object == null ? {} : basePick(object, paths); - }); - - /** - * Creates an object composed of the `object` properties `predicate` returns - * truthy for. The predicate is invoked with two arguments: (value, key). - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Object - * @param {Object} object The source object. - * @param {Function} [predicate=_.identity] The function invoked per property. - * @returns {Object} Returns the new object. - * @example - * - * var object = { 'a': 1, 'b': '2', 'c': 3 }; - * - * _.pickBy(object, _.isNumber); - * // => { 'a': 1, 'c': 3 } - */ - function pickBy(object, predicate) { - if (object == null) { - return {}; - } - var props = arrayMap(getAllKeysIn(object), function(prop) { - return [prop]; - }); - predicate = getIteratee(predicate); - return basePickBy(object, props, function(value, path) { - return predicate(value, path[0]); - }); - } - - /** - * This method is like `_.get` except that if the resolved value is a - * function it's invoked with the `this` binding of its parent object and - * its result is returned. - * - * @static - * @since 0.1.0 - * @memberOf _ - * @category Object - * @param {Object} object The object to query. - * @param {Array|string} path The path of the property to resolve. - * @param {*} [defaultValue] The value returned for `undefined` resolved values. - * @returns {*} Returns the resolved value. - * @example - * - * var object = { 'a': [{ 'b': { 'c1': 3, 'c2': _.constant(4) } }] }; - * - * _.result(object, 'a[0].b.c1'); - * // => 3 - * - * _.result(object, 'a[0].b.c2'); - * // => 4 - * - * _.result(object, 'a[0].b.c3', 'default'); - * // => 'default' - * - * _.result(object, 'a[0].b.c3', _.constant('default')); - * // => 'default' - */ - function result(object, path, defaultValue) { - path = castPath(path, object); - - var index = -1, - length = path.length; - - // Ensure the loop is entered when path is empty. - if (!length) { - length = 1; - object = undefined; - } - while (++index < length) { - var value = object == null ? undefined : object[toKey(path[index])]; - if (value === undefined) { - index = length; - value = defaultValue; - } - object = isFunction(value) ? value.call(object) : value; - } - return object; - } - - /** - * Sets the value at `path` of `object`. If a portion of `path` doesn't exist, - * it's created. Arrays are created for missing index properties while objects - * are created for all other missing properties. Use `_.setWith` to customize - * `path` creation. - * - * **Note:** This method mutates `object`. - * - * @static - * @memberOf _ - * @since 3.7.0 - * @category Object - * @param {Object} object The object to modify. - * @param {Array|string} path The path of the property to set. - * @param {*} value The value to set. - * @returns {Object} Returns `object`. - * @example - * - * var object = { 'a': [{ 'b': { 'c': 3 } }] }; - * - * _.set(object, 'a[0].b.c', 4); - * console.log(object.a[0].b.c); - * // => 4 - * - * _.set(object, ['x', '0', 'y', 'z'], 5); - * console.log(object.x[0].y.z); - * // => 5 - */ - function set(object, path, value) { - return object == null ? object : baseSet(object, path, value); - } - - /** - * This method is like `_.set` except that it accepts `customizer` which is - * invoked to produce the objects of `path`. If `customizer` returns `undefined` - * path creation is handled by the method instead. The `customizer` is invoked - * with three arguments: (nsValue, key, nsObject). - * - * **Note:** This method mutates `object`. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Object - * @param {Object} object The object to modify. - * @param {Array|string} path The path of the property to set. - * @param {*} value The value to set. - * @param {Function} [customizer] The function to customize assigned values. - * @returns {Object} Returns `object`. - * @example - * - * var object = {}; - * - * _.setWith(object, '[0][1]', 'a', Object); - * // => { '0': { '1': 'a' } } - */ - function setWith(object, path, value, customizer) { - customizer = typeof customizer == 'function' ? customizer : undefined; - return object == null ? object : baseSet(object, path, value, customizer); - } - - /** - * Creates an array of own enumerable string keyed-value pairs for `object` - * which can be consumed by `_.fromPairs`. If `object` is a map or set, its - * entries are returned. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @alias entries - * @category Object - * @param {Object} object The object to query. - * @returns {Array} Returns the key-value pairs. - * @example - * - * function Foo() { - * this.a = 1; - * this.b = 2; - * } - * - * Foo.prototype.c = 3; - * - * _.toPairs(new Foo); - * // => [['a', 1], ['b', 2]] (iteration order is not guaranteed) - */ - var toPairs = createToPairs(keys); - - /** - * Creates an array of own and inherited enumerable string keyed-value pairs - * for `object` which can be consumed by `_.fromPairs`. If `object` is a map - * or set, its entries are returned. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @alias entriesIn - * @category Object - * @param {Object} object The object to query. - * @returns {Array} Returns the key-value pairs. - * @example - * - * function Foo() { - * this.a = 1; - * this.b = 2; - * } - * - * Foo.prototype.c = 3; - * - * _.toPairsIn(new Foo); - * // => [['a', 1], ['b', 2], ['c', 3]] (iteration order is not guaranteed) - */ - var toPairsIn = createToPairs(keysIn); - - /** - * An alternative to `_.reduce`; this method transforms `object` to a new - * `accumulator` object which is the result of running each of its own - * enumerable string keyed properties thru `iteratee`, with each invocation - * potentially mutating the `accumulator` object. If `accumulator` is not - * provided, a new object with the same `[[Prototype]]` will be used. The - * iteratee is invoked with four arguments: (accumulator, value, key, object). - * Iteratee functions may exit iteration early by explicitly returning `false`. - * - * @static - * @memberOf _ - * @since 1.3.0 - * @category Object - * @param {Object} object The object to iterate over. - * @param {Function} [iteratee=_.identity] The function invoked per iteration. - * @param {*} [accumulator] The custom accumulator value. - * @returns {*} Returns the accumulated value. - * @example - * - * _.transform([2, 3, 4], function(result, n) { - * result.push(n *= n); - * return n % 2 == 0; - * }, []); - * // => [4, 9] - * - * _.transform({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) { - * (result[value] || (result[value] = [])).push(key); - * }, {}); - * // => { '1': ['a', 'c'], '2': ['b'] } - */ - function transform(object, iteratee, accumulator) { - var isArr = isArray(object), - isArrLike = isArr || isBuffer(object) || isTypedArray(object); - - iteratee = getIteratee(iteratee, 4); - if (accumulator == null) { - var Ctor = object && object.constructor; - if (isArrLike) { - accumulator = isArr ? new Ctor : []; - } - else if (isObject(object)) { - accumulator = isFunction(Ctor) ? baseCreate(getPrototype(object)) : {}; - } - else { - accumulator = {}; - } - } - (isArrLike ? arrayEach : baseForOwn)(object, function(value, index, object) { - return iteratee(accumulator, value, index, object); - }); - return accumulator; - } - - /** - * Removes the property at `path` of `object`. - * - * **Note:** This method mutates `object`. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Object - * @param {Object} object The object to modify. - * @param {Array|string} path The path of the property to unset. - * @returns {boolean} Returns `true` if the property is deleted, else `false`. - * @example - * - * var object = { 'a': [{ 'b': { 'c': 7 } }] }; - * _.unset(object, 'a[0].b.c'); - * // => true - * - * console.log(object); - * // => { 'a': [{ 'b': {} }] }; - * - * _.unset(object, ['a', '0', 'b', 'c']); - * // => true - * - * console.log(object); - * // => { 'a': [{ 'b': {} }] }; - */ - function unset(object, path) { - return object == null ? true : baseUnset(object, path); - } - - /** - * This method is like `_.set` except that accepts `updater` to produce the - * value to set. Use `_.updateWith` to customize `path` creation. The `updater` - * is invoked with one argument: (value). - * - * **Note:** This method mutates `object`. - * - * @static - * @memberOf _ - * @since 4.6.0 - * @category Object - * @param {Object} object The object to modify. - * @param {Array|string} path The path of the property to set. - * @param {Function} updater The function to produce the updated value. - * @returns {Object} Returns `object`. - * @example - * - * var object = { 'a': [{ 'b': { 'c': 3 } }] }; - * - * _.update(object, 'a[0].b.c', function(n) { return n * n; }); - * console.log(object.a[0].b.c); - * // => 9 - * - * _.update(object, 'x[0].y.z', function(n) { return n ? n + 1 : 0; }); - * console.log(object.x[0].y.z); - * // => 0 - */ - function update(object, path, updater) { - return object == null ? object : baseUpdate(object, path, castFunction(updater)); - } - - /** - * This method is like `_.update` except that it accepts `customizer` which is - * invoked to produce the objects of `path`. If `customizer` returns `undefined` - * path creation is handled by the method instead. The `customizer` is invoked - * with three arguments: (nsValue, key, nsObject). - * - * **Note:** This method mutates `object`. - * - * @static - * @memberOf _ - * @since 4.6.0 - * @category Object - * @param {Object} object The object to modify. - * @param {Array|string} path The path of the property to set. - * @param {Function} updater The function to produce the updated value. - * @param {Function} [customizer] The function to customize assigned values. - * @returns {Object} Returns `object`. - * @example - * - * var object = {}; - * - * _.updateWith(object, '[0][1]', _.constant('a'), Object); - * // => { '0': { '1': 'a' } } - */ - function updateWith(object, path, updater, customizer) { - customizer = typeof customizer == 'function' ? customizer : undefined; - return object == null ? object : baseUpdate(object, path, castFunction(updater), customizer); - } - - /** - * Creates an array of the own enumerable string keyed property values of `object`. - * - * **Note:** Non-object values are coerced to objects. - * - * @static - * @since 0.1.0 - * @memberOf _ - * @category Object - * @param {Object} object The object to query. - * @returns {Array} Returns the array of property values. - * @example - * - * function Foo() { - * this.a = 1; - * this.b = 2; - * } - * - * Foo.prototype.c = 3; - * - * _.values(new Foo); - * // => [1, 2] (iteration order is not guaranteed) - * - * _.values('hi'); - * // => ['h', 'i'] - */ - function values(object) { - return object == null ? [] : baseValues(object, keys(object)); - } - - /** - * Creates an array of the own and inherited enumerable string keyed property - * values of `object`. - * - * **Note:** Non-object values are coerced to objects. - * - * @static - * @memberOf _ - * @since 3.0.0 - * @category Object - * @param {Object} object The object to query. - * @returns {Array} Returns the array of property values. - * @example - * - * function Foo() { - * this.a = 1; - * this.b = 2; - * } - * - * Foo.prototype.c = 3; - * - * _.valuesIn(new Foo); - * // => [1, 2, 3] (iteration order is not guaranteed) - */ - function valuesIn(object) { - return object == null ? [] : baseValues(object, keysIn(object)); - } - - /*------------------------------------------------------------------------*/ - - /** - * Clamps `number` within the inclusive `lower` and `upper` bounds. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Number - * @param {number} number The number to clamp. - * @param {number} [lower] The lower bound. - * @param {number} upper The upper bound. - * @returns {number} Returns the clamped number. - * @example - * - * _.clamp(-10, -5, 5); - * // => -5 - * - * _.clamp(10, -5, 5); - * // => 5 - */ - function clamp(number, lower, upper) { - if (upper === undefined) { - upper = lower; - lower = undefined; - } - if (upper !== undefined) { - upper = toNumber(upper); - upper = upper === upper ? upper : 0; - } - if (lower !== undefined) { - lower = toNumber(lower); - lower = lower === lower ? lower : 0; - } - return baseClamp(toNumber(number), lower, upper); - } - - /** - * Checks if `n` is between `start` and up to, but not including, `end`. If - * `end` is not specified, it's set to `start` with `start` then set to `0`. - * If `start` is greater than `end` the params are swapped to support - * negative ranges. - * - * @static - * @memberOf _ - * @since 3.3.0 - * @category Number - * @param {number} number The number to check. - * @param {number} [start=0] The start of the range. - * @param {number} end The end of the range. - * @returns {boolean} Returns `true` if `number` is in the range, else `false`. - * @see _.range, _.rangeRight - * @example - * - * _.inRange(3, 2, 4); - * // => true - * - * _.inRange(4, 8); - * // => true - * - * _.inRange(4, 2); - * // => false - * - * _.inRange(2, 2); - * // => false - * - * _.inRange(1.2, 2); - * // => true - * - * _.inRange(5.2, 4); - * // => false - * - * _.inRange(-3, -2, -6); - * // => true - */ - function inRange(number, start, end) { - start = toFinite(start); - if (end === undefined) { - end = start; - start = 0; - } else { - end = toFinite(end); - } - number = toNumber(number); - return baseInRange(number, start, end); - } - - /** - * Produces a random number between the inclusive `lower` and `upper` bounds. - * If only one argument is provided a number between `0` and the given number - * is returned. If `floating` is `true`, or either `lower` or `upper` are - * floats, a floating-point number is returned instead of an integer. - * - * **Note:** JavaScript follows the IEEE-754 standard for resolving - * floating-point values which can produce unexpected results. - * - * @static - * @memberOf _ - * @since 0.7.0 - * @category Number - * @param {number} [lower=0] The lower bound. - * @param {number} [upper=1] The upper bound. - * @param {boolean} [floating] Specify returning a floating-point number. - * @returns {number} Returns the random number. - * @example - * - * _.random(0, 5); - * // => an integer between 0 and 5 - * - * _.random(5); - * // => also an integer between 0 and 5 - * - * _.random(5, true); - * // => a floating-point number between 0 and 5 - * - * _.random(1.2, 5.2); - * // => a floating-point number between 1.2 and 5.2 - */ - function random(lower, upper, floating) { - if (floating && typeof floating != 'boolean' && isIterateeCall(lower, upper, floating)) { - upper = floating = undefined; - } - if (floating === undefined) { - if (typeof upper == 'boolean') { - floating = upper; - upper = undefined; - } - else if (typeof lower == 'boolean') { - floating = lower; - lower = undefined; - } - } - if (lower === undefined && upper === undefined) { - lower = 0; - upper = 1; - } - else { - lower = toFinite(lower); - if (upper === undefined) { - upper = lower; - lower = 0; - } else { - upper = toFinite(upper); - } - } - if (lower > upper) { - var temp = lower; - lower = upper; - upper = temp; - } - if (floating || lower % 1 || upper % 1) { - var rand = nativeRandom(); - return nativeMin(lower + (rand * (upper - lower + freeParseFloat('1e-' + ((rand + '').length - 1)))), upper); - } - return baseRandom(lower, upper); - } - - /*------------------------------------------------------------------------*/ - - /** - * Converts `string` to [camel case](https://en.wikipedia.org/wiki/CamelCase). - * - * @static - * @memberOf _ - * @since 3.0.0 - * @category String - * @param {string} [string=''] The string to convert. - * @returns {string} Returns the camel cased string. - * @example - * - * _.camelCase('Foo Bar'); - * // => 'fooBar' - * - * _.camelCase('--foo-bar--'); - * // => 'fooBar' - * - * _.camelCase('__FOO_BAR__'); - * // => 'fooBar' - */ - var camelCase = createCompounder(function(result, word, index) { - word = word.toLowerCase(); - return result + (index ? capitalize(word) : word); - }); - - /** - * Converts the first character of `string` to upper case and the remaining - * to lower case. - * - * @static - * @memberOf _ - * @since 3.0.0 - * @category String - * @param {string} [string=''] The string to capitalize. - * @returns {string} Returns the capitalized string. - * @example - * - * _.capitalize('FRED'); - * // => 'Fred' - */ - function capitalize(string) { - return upperFirst(toString(string).toLowerCase()); - } - - /** - * Deburrs `string` by converting - * [Latin-1 Supplement](https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)#Character_table) - * and [Latin Extended-A](https://en.wikipedia.org/wiki/Latin_Extended-A) - * letters to basic Latin letters and removing - * [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks). - * - * @static - * @memberOf _ - * @since 3.0.0 - * @category String - * @param {string} [string=''] The string to deburr. - * @returns {string} Returns the deburred string. - * @example - * - * _.deburr('déjà vu'); - * // => 'deja vu' - */ - function deburr(string) { - string = toString(string); - return string && string.replace(reLatin, deburrLetter).replace(reComboMark, ''); - } - - /** - * Checks if `string` ends with the given target string. - * - * @static - * @memberOf _ - * @since 3.0.0 - * @category String - * @param {string} [string=''] The string to inspect. - * @param {string} [target] The string to search for. - * @param {number} [position=string.length] The position to search up to. - * @returns {boolean} Returns `true` if `string` ends with `target`, - * else `false`. - * @example - * - * _.endsWith('abc', 'c'); - * // => true - * - * _.endsWith('abc', 'b'); - * // => false - * - * _.endsWith('abc', 'b', 2); - * // => true - */ - function endsWith(string, target, position) { - string = toString(string); - target = baseToString(target); - - var length = string.length; - position = position === undefined - ? length - : baseClamp(toInteger(position), 0, length); - - var end = position; - position -= target.length; - return position >= 0 && string.slice(position, end) == target; - } - - /** - * Converts the characters "&", "<", ">", '"', and "'" in `string` to their - * corresponding HTML entities. - * - * **Note:** No other characters are escaped. To escape additional - * characters use a third-party library like [_he_](https://mths.be/he). - * - * Though the ">" character is escaped for symmetry, characters like - * ">" and "/" don't need escaping in HTML and have no special meaning - * unless they're part of a tag or unquoted attribute value. See - * [Mathias Bynens's article](https://mathiasbynens.be/notes/ambiguous-ampersands) - * (under "semi-related fun fact") for more details. - * - * When working with HTML you should always - * [quote attribute values](http://wonko.com/post/html-escaping) to reduce - * XSS vectors. - * - * @static - * @since 0.1.0 - * @memberOf _ - * @category String - * @param {string} [string=''] The string to escape. - * @returns {string} Returns the escaped string. - * @example - * - * _.escape('fred, barney, & pebbles'); - * // => 'fred, barney, & pebbles' - */ - function escape(string) { - string = toString(string); - return (string && reHasUnescapedHtml.test(string)) - ? string.replace(reUnescapedHtml, escapeHtmlChar) - : string; - } - - /** - * Escapes the `RegExp` special characters "^", "$", "\", ".", "*", "+", - * "?", "(", ")", "[", "]", "{", "}", and "|" in `string`. - * - * @static - * @memberOf _ - * @since 3.0.0 - * @category String - * @param {string} [string=''] The string to escape. - * @returns {string} Returns the escaped string. - * @example - * - * _.escapeRegExp('[lodash](https://lodash.com/)'); - * // => '\[lodash\]\(https://lodash\.com/\)' - */ - function escapeRegExp(string) { - string = toString(string); - return (string && reHasRegExpChar.test(string)) - ? string.replace(reRegExpChar, '\\$&') - : string; - } - - /** - * Converts `string` to - * [kebab case](https://en.wikipedia.org/wiki/Letter_case#Special_case_styles). - * - * @static - * @memberOf _ - * @since 3.0.0 - * @category String - * @param {string} [string=''] The string to convert. - * @returns {string} Returns the kebab cased string. - * @example - * - * _.kebabCase('Foo Bar'); - * // => 'foo-bar' - * - * _.kebabCase('fooBar'); - * // => 'foo-bar' - * - * _.kebabCase('__FOO_BAR__'); - * // => 'foo-bar' - */ - var kebabCase = createCompounder(function(result, word, index) { - return result + (index ? '-' : '') + word.toLowerCase(); - }); - - /** - * Converts `string`, as space separated words, to lower case. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category String - * @param {string} [string=''] The string to convert. - * @returns {string} Returns the lower cased string. - * @example - * - * _.lowerCase('--Foo-Bar--'); - * // => 'foo bar' - * - * _.lowerCase('fooBar'); - * // => 'foo bar' - * - * _.lowerCase('__FOO_BAR__'); - * // => 'foo bar' - */ - var lowerCase = createCompounder(function(result, word, index) { - return result + (index ? ' ' : '') + word.toLowerCase(); - }); - - /** - * Converts the first character of `string` to lower case. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category String - * @param {string} [string=''] The string to convert. - * @returns {string} Returns the converted string. - * @example - * - * _.lowerFirst('Fred'); - * // => 'fred' - * - * _.lowerFirst('FRED'); - * // => 'fRED' - */ - var lowerFirst = createCaseFirst('toLowerCase'); - - /** - * Pads `string` on the left and right sides if it's shorter than `length`. - * Padding characters are truncated if they can't be evenly divided by `length`. - * - * @static - * @memberOf _ - * @since 3.0.0 - * @category String - * @param {string} [string=''] The string to pad. - * @param {number} [length=0] The padding length. - * @param {string} [chars=' '] The string used as padding. - * @returns {string} Returns the padded string. - * @example - * - * _.pad('abc', 8); - * // => ' abc ' - * - * _.pad('abc', 8, '_-'); - * // => '_-abc_-_' - * - * _.pad('abc', 3); - * // => 'abc' - */ - function pad(string, length, chars) { - string = toString(string); - length = toInteger(length); - - var strLength = length ? stringSize(string) : 0; - if (!length || strLength >= length) { - return string; - } - var mid = (length - strLength) / 2; - return ( - createPadding(nativeFloor(mid), chars) + - string + - createPadding(nativeCeil(mid), chars) - ); - } - - /** - * Pads `string` on the right side if it's shorter than `length`. Padding - * characters are truncated if they exceed `length`. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category String - * @param {string} [string=''] The string to pad. - * @param {number} [length=0] The padding length. - * @param {string} [chars=' '] The string used as padding. - * @returns {string} Returns the padded string. - * @example - * - * _.padEnd('abc', 6); - * // => 'abc ' - * - * _.padEnd('abc', 6, '_-'); - * // => 'abc_-_' - * - * _.padEnd('abc', 3); - * // => 'abc' - */ - function padEnd(string, length, chars) { - string = toString(string); - length = toInteger(length); - - var strLength = length ? stringSize(string) : 0; - return (length && strLength < length) - ? (string + createPadding(length - strLength, chars)) - : string; - } - - /** - * Pads `string` on the left side if it's shorter than `length`. Padding - * characters are truncated if they exceed `length`. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category String - * @param {string} [string=''] The string to pad. - * @param {number} [length=0] The padding length. - * @param {string} [chars=' '] The string used as padding. - * @returns {string} Returns the padded string. - * @example - * - * _.padStart('abc', 6); - * // => ' abc' - * - * _.padStart('abc', 6, '_-'); - * // => '_-_abc' - * - * _.padStart('abc', 3); - * // => 'abc' - */ - function padStart(string, length, chars) { - string = toString(string); - length = toInteger(length); - - var strLength = length ? stringSize(string) : 0; - return (length && strLength < length) - ? (createPadding(length - strLength, chars) + string) - : string; - } - - /** - * Converts `string` to an integer of the specified radix. If `radix` is - * `undefined` or `0`, a `radix` of `10` is used unless `value` is a - * hexadecimal, in which case a `radix` of `16` is used. - * - * **Note:** This method aligns with the - * [ES5 implementation](https://es5.github.io/#x15.1.2.2) of `parseInt`. - * - * @static - * @memberOf _ - * @since 1.1.0 - * @category String - * @param {string} string The string to convert. - * @param {number} [radix=10] The radix to interpret `value` by. - * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. - * @returns {number} Returns the converted integer. - * @example - * - * _.parseInt('08'); - * // => 8 - * - * _.map(['6', '08', '10'], _.parseInt); - * // => [6, 8, 10] - */ - function parseInt(string, radix, guard) { - if (guard || radix == null) { - radix = 0; - } else if (radix) { - radix = +radix; - } - return nativeParseInt(toString(string).replace(reTrimStart, ''), radix || 0); - } - - /** - * Repeats the given string `n` times. - * - * @static - * @memberOf _ - * @since 3.0.0 - * @category String - * @param {string} [string=''] The string to repeat. - * @param {number} [n=1] The number of times to repeat the string. - * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. - * @returns {string} Returns the repeated string. - * @example - * - * _.repeat('*', 3); - * // => '***' - * - * _.repeat('abc', 2); - * // => 'abcabc' - * - * _.repeat('abc', 0); - * // => '' - */ - function repeat(string, n, guard) { - if ((guard ? isIterateeCall(string, n, guard) : n === undefined)) { - n = 1; - } else { - n = toInteger(n); - } - return baseRepeat(toString(string), n); - } - - /** - * Replaces matches for `pattern` in `string` with `replacement`. - * - * **Note:** This method is based on - * [`String#replace`](https://mdn.io/String/replace). - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category String - * @param {string} [string=''] The string to modify. - * @param {RegExp|string} pattern The pattern to replace. - * @param {Function|string} replacement The match replacement. - * @returns {string} Returns the modified string. - * @example - * - * _.replace('Hi Fred', 'Fred', 'Barney'); - * // => 'Hi Barney' - */ - function replace() { - var args = arguments, - string = toString(args[0]); - - return args.length < 3 ? string : string.replace(args[1], args[2]); - } - - /** - * Converts `string` to - * [snake case](https://en.wikipedia.org/wiki/Snake_case). - * - * @static - * @memberOf _ - * @since 3.0.0 - * @category String - * @param {string} [string=''] The string to convert. - * @returns {string} Returns the snake cased string. - * @example - * - * _.snakeCase('Foo Bar'); - * // => 'foo_bar' - * - * _.snakeCase('fooBar'); - * // => 'foo_bar' - * - * _.snakeCase('--FOO-BAR--'); - * // => 'foo_bar' - */ - var snakeCase = createCompounder(function(result, word, index) { - return result + (index ? '_' : '') + word.toLowerCase(); - }); - - /** - * Splits `string` by `separator`. - * - * **Note:** This method is based on - * [`String#split`](https://mdn.io/String/split). - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category String - * @param {string} [string=''] The string to split. - * @param {RegExp|string} separator The separator pattern to split by. - * @param {number} [limit] The length to truncate results to. - * @returns {Array} Returns the string segments. - * @example - * - * _.split('a-b-c', '-', 2); - * // => ['a', 'b'] - */ - function split(string, separator, limit) { - if (limit && typeof limit != 'number' && isIterateeCall(string, separator, limit)) { - separator = limit = undefined; - } - limit = limit === undefined ? MAX_ARRAY_LENGTH : limit >>> 0; - if (!limit) { - return []; - } - string = toString(string); - if (string && ( - typeof separator == 'string' || - (separator != null && !isRegExp(separator)) - )) { - separator = baseToString(separator); - if (!separator && hasUnicode(string)) { - return castSlice(stringToArray(string), 0, limit); - } - } - return string.split(separator, limit); - } - - /** - * Converts `string` to - * [start case](https://en.wikipedia.org/wiki/Letter_case#Stylistic_or_specialised_usage). - * - * @static - * @memberOf _ - * @since 3.1.0 - * @category String - * @param {string} [string=''] The string to convert. - * @returns {string} Returns the start cased string. - * @example - * - * _.startCase('--foo-bar--'); - * // => 'Foo Bar' - * - * _.startCase('fooBar'); - * // => 'Foo Bar' - * - * _.startCase('__FOO_BAR__'); - * // => 'FOO BAR' - */ - var startCase = createCompounder(function(result, word, index) { - return result + (index ? ' ' : '') + upperFirst(word); - }); - - /** - * Checks if `string` starts with the given target string. - * - * @static - * @memberOf _ - * @since 3.0.0 - * @category String - * @param {string} [string=''] The string to inspect. - * @param {string} [target] The string to search for. - * @param {number} [position=0] The position to search from. - * @returns {boolean} Returns `true` if `string` starts with `target`, - * else `false`. - * @example - * - * _.startsWith('abc', 'a'); - * // => true - * - * _.startsWith('abc', 'b'); - * // => false - * - * _.startsWith('abc', 'b', 1); - * // => true - */ - function startsWith(string, target, position) { - string = toString(string); - position = position == null - ? 0 - : baseClamp(toInteger(position), 0, string.length); - - target = baseToString(target); - return string.slice(position, position + target.length) == target; - } - - /** - * Creates a compiled template function that can interpolate data properties - * in "interpolate" delimiters, HTML-escape interpolated data properties in - * "escape" delimiters, and execute JavaScript in "evaluate" delimiters. Data - * properties may be accessed as free variables in the template. If a setting - * object is given, it takes precedence over `_.templateSettings` values. - * - * **Note:** In the development build `_.template` utilizes - * [sourceURLs](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl) - * for easier debugging. - * - * For more information on precompiling templates see - * [lodash's custom builds documentation](https://lodash.com/custom-builds). - * - * For more information on Chrome extension sandboxes see - * [Chrome's extensions documentation](https://developer.chrome.com/extensions/sandboxingEval). - * - * @static - * @since 0.1.0 - * @memberOf _ - * @category String - * @param {string} [string=''] The template string. - * @param {Object} [options={}] The options object. - * @param {RegExp} [options.escape=_.templateSettings.escape] - * The HTML "escape" delimiter. - * @param {RegExp} [options.evaluate=_.templateSettings.evaluate] - * The "evaluate" delimiter. - * @param {Object} [options.imports=_.templateSettings.imports] - * An object to import into the template as free variables. - * @param {RegExp} [options.interpolate=_.templateSettings.interpolate] - * The "interpolate" delimiter. - * @param {string} [options.sourceURL='lodash.templateSources[n]'] - * The sourceURL of the compiled template. - * @param {string} [options.variable='obj'] - * The data object variable name. - * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. - * @returns {Function} Returns the compiled template function. - * @example - * - * // Use the "interpolate" delimiter to create a compiled template. - * var compiled = _.template('hello <%= user %>!'); - * compiled({ 'user': 'fred' }); - * // => 'hello fred!' - * - * // Use the HTML "escape" delimiter to escape data property values. - * var compiled = _.template('<%- value %>'); - * compiled({ 'value': '