emissions-api-sdk 1.0.12 → 1.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +42 -2
- package/dist/Constants.js +4 -1
- package/dist/api/AuditLog.js +99 -0
- package/dist/api/EconomicActivity.js +24 -0
- package/dist/api/Factor.js +19 -0
- package/dist/api/PhysicalActivity.js +87 -0
- package/dist/api/RealEstate.js +23 -0
- package/dist/api/TypeRecommender.js +19 -2
- package/dist/coverage/clover.xml +149 -87
- package/dist/coverage/coverage-final.json +14 -8
- package/dist/coverage/lcov-report/index.html +21 -21
- package/dist/coverage/lcov-report/src/Client.ts.html +32 -32
- package/dist/coverage/lcov-report/src/Constants.ts.html +36 -27
- package/dist/coverage/lcov-report/src/api/AuditLog.ts.html +388 -0
- package/dist/coverage/lcov-report/src/api/Calculation.ts.html +1 -1
- package/dist/coverage/lcov-report/src/api/EconomicActivity.ts.html +77 -5
- package/dist/coverage/lcov-report/src/api/Factor.ts.html +59 -2
- package/dist/coverage/lcov-report/src/api/FactorSets.ts.html +1 -1
- package/dist/coverage/lcov-report/src/api/Fugitive.ts.html +1 -1
- package/dist/coverage/lcov-report/src/api/Location.ts.html +1 -1
- package/dist/coverage/lcov-report/src/api/Metadata.ts.html +1 -1
- package/dist/coverage/lcov-report/src/api/Mobile.ts.html +1 -1
- package/dist/coverage/lcov-report/src/api/PhysicalActivity.ts.html +361 -0
- package/dist/coverage/lcov-report/src/api/RealEstate.ts.html +74 -5
- package/dist/coverage/lcov-report/src/api/Stationary.ts.html +1 -1
- package/dist/coverage/lcov-report/src/api/TransportationAndDistribution.ts.html +1 -1
- package/dist/coverage/lcov-report/src/api/TypeRecommender.ts.html +55 -4
- package/dist/coverage/lcov-report/src/api/Usage.ts.html +1 -1
- package/dist/coverage/lcov-report/src/api/index.html +36 -6
- package/dist/coverage/lcov-report/src/index.html +7 -7
- package/dist/coverage/lcov-report/src/request.ts.html +5 -5
- package/dist/coverage/lcov-report/src/utils.ts.html +6 -6
- package/dist/coverage/lcov-report/test/index.html +1 -1
- package/dist/coverage/lcov-report/test/mocks/AttributionRequest.ts.html +151 -0
- package/dist/coverage/lcov-report/test/mocks/CommonRequest.ts.html +1 -1
- package/dist/coverage/lcov-report/test/mocks/EconomicActivityAttributionRequest.ts.html +148 -0
- package/dist/coverage/lcov-report/test/mocks/FactorRequest.ts.html +1 -1
- package/dist/coverage/lcov-report/test/mocks/GenericCalculationRequest.ts.html +1 -1
- package/dist/coverage/lcov-report/test/mocks/LocationRequest.ts.html +1 -1
- package/dist/coverage/lcov-report/test/mocks/PhysicalActivityEVICRequest.ts.html +148 -0
- package/dist/coverage/lcov-report/test/mocks/PhysicalActivityRequest.ts.html +151 -0
- package/dist/coverage/lcov-report/test/mocks/SearchRequest.ts.html +1 -1
- package/dist/coverage/lcov-report/test/mocks/index.html +63 -3
- package/dist/coverage/lcov-report/test/testUtils.ts.html +1 -1
- package/dist/coverage/lcov.info +249 -122
- package/dist/index.js +3 -1
- package/dist/interfaces/response/AuditLogResponse.js +2 -0
- package/dist/types/Constants.d.ts +3 -0
- package/dist/types/api/AuditLog.d.ts +37 -0
- package/dist/types/api/EconomicActivity.d.ts +24 -0
- package/dist/types/api/Factor.d.ts +19 -0
- package/dist/types/api/PhysicalActivity.d.ts +76 -0
- package/dist/types/api/RealEstate.d.ts +23 -0
- package/dist/types/api/TypeRecommender.d.ts +19 -2
- package/dist/types/index.d.ts +4 -0
- package/dist/types/interfaces/Api.d.ts +17 -1
- package/dist/types/interfaces/common.d.ts +40 -0
- package/dist/types/interfaces/response/AuditLogResponse.d.ts +40 -0
- package/dist/types/interfaces/response/TypeRecommenderResponse.d.ts +1 -0
- package/docs/_sources/authentication.rst.txt +26 -4
- package/docs/_sources/getting_started.rst.txt +538 -74
- package/docs/_sources/index.rst.txt +11 -0
- package/docs/_sources/reference.rst.txt +26 -0
- package/docs/_sources/troubleshooting.rst.txt +77 -12
- package/docs/_static/basic.css +8 -0
- package/docs/_static/doctools.js +5 -6
- package/docs/_static/language_data.js +186 -7
- package/docs/_static/pygments.css +146 -164
- package/docs/_static/searchtools.js +60 -121
- package/docs/_static/sphinx_highlight.js +31 -36
- package/docs/_static/styles/furo.css +1 -1
- package/docs/_static/styles/furo.css.map +1 -1
- package/docs/authentication.html +61 -26
- package/docs/client.html +33 -22
- package/docs/genindex.html +52 -23
- package/docs/getting_started.html +745 -103
- package/docs/index.html +65 -21
- package/docs/reference.html +484 -66
- package/docs/sdk.html +32 -21
- package/docs/search.html +32 -21
- package/docs/searchindex.js +1 -1
- package/docs/troubleshooting.html +105 -38
- package/package.json +7 -3
- package/sphinx-build/source/authentication.rst +26 -4
- package/sphinx-build/source/getting_started.rst +538 -74
- package/sphinx-build/source/index.rst +11 -0
- package/sphinx-build/source/reference.rst +26 -0
- package/sphinx-build/source/troubleshooting.rst +77 -12
- package/src/Constants.ts +3 -0
- package/src/api/AuditLog.ts +102 -0
- package/src/api/EconomicActivity.ts +24 -0
- package/src/api/Factor.ts +19 -0
- package/src/api/PhysicalActivity.ts +92 -0
- package/src/api/RealEstate.ts +23 -0
- package/src/api/TypeRecommender.ts +19 -2
- package/src/index.ts +7 -1
- package/src/interfaces/Api.ts +22 -6
- package/src/interfaces/common.ts +46 -0
- package/src/interfaces/response/AuditLogResponse.ts +47 -0
- package/src/interfaces/response/TypeRecommenderResponse.ts +2 -0
- package/test/apiTest.test.ts +59 -3
- package/test/auditLog.test.ts +216 -0
- package/test/mocks/AttributionRequest.ts +23 -0
- package/test/mocks/EconomicActivityAttributionRequest.ts +22 -0
- package/test/mocks/PhysicalActivityEVICRequest.ts +22 -0
- package/test/mocks/PhysicalActivityRequest.ts +23 -0
|
@@ -99,12 +99,61 @@ These errors occur when ``Client.getClient()`` is called with invalid or missing
|
|
|
99
99
|
|
|
100
100
|
----
|
|
101
101
|
|
|
102
|
+
4. Missing Client ID with PAT Token
|
|
103
|
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
104
|
+
|
|
105
|
+
**Error Message:**
|
|
106
|
+
|
|
107
|
+
.. code-block:: text
|
|
108
|
+
|
|
109
|
+
Error: If patToken is provided, "clientId" must also be provided.
|
|
110
|
+
|
|
111
|
+
**Cause:** Personal Access Token (PAT) provided without client ID
|
|
112
|
+
|
|
113
|
+
**Solution:** Provide ``clientId`` parameter when using a PAT token
|
|
114
|
+
|
|
115
|
+
**Sample Function Call That Causes This Error:**
|
|
116
|
+
|
|
117
|
+
.. code-block:: typescript
|
|
118
|
+
|
|
119
|
+
await Client.getClient({
|
|
120
|
+
patToken: 'your-pat-token'
|
|
121
|
+
// Missing clientId parameter
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
----
|
|
125
|
+
|
|
126
|
+
5. Organization ID Provided with PAT Token
|
|
127
|
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
128
|
+
|
|
129
|
+
**Error Message:**
|
|
130
|
+
|
|
131
|
+
.. code-block:: text
|
|
132
|
+
|
|
133
|
+
Error: orgId should not be provided when using patToken.
|
|
134
|
+
|
|
135
|
+
**Cause:** Organization ID should not be used with Personal Access Token authentication
|
|
136
|
+
|
|
137
|
+
**Solution:** Remove ``orgId`` parameter when using PAT token authentication
|
|
138
|
+
|
|
139
|
+
**Sample Function Call That Causes This Error:**
|
|
140
|
+
|
|
141
|
+
.. code-block:: typescript
|
|
142
|
+
|
|
143
|
+
await Client.getClient({
|
|
144
|
+
patToken: 'your-pat-token',
|
|
145
|
+
clientId: 'client123',
|
|
146
|
+
orgId: 'org456' // This should not be provided with PAT token
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
----
|
|
150
|
+
|
|
102
151
|
Authentication Errors (HTTP 401)
|
|
103
152
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
104
153
|
|
|
105
154
|
These errors occur when authentication credentials are invalid or expired.
|
|
106
155
|
|
|
107
|
-
|
|
156
|
+
6. Invalid API Key
|
|
108
157
|
^^^^^^^^^^^^^^^^^^
|
|
109
158
|
|
|
110
159
|
**Error Response:**
|
|
@@ -135,7 +184,7 @@ These errors occur when authentication credentials are invalid or expired.
|
|
|
135
184
|
|
|
136
185
|
----
|
|
137
186
|
|
|
138
|
-
|
|
187
|
+
7. Invalid Organization ID
|
|
139
188
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
140
189
|
|
|
141
190
|
**Error Response:**
|
|
@@ -166,7 +215,7 @@ These errors occur when authentication credentials are invalid or expired.
|
|
|
166
215
|
|
|
167
216
|
----
|
|
168
217
|
|
|
169
|
-
|
|
218
|
+
8. Invalid Client ID
|
|
170
219
|
^^^^^^^^^^^^^^^^^^^^^
|
|
171
220
|
|
|
172
221
|
**Error Response:**
|
|
@@ -197,7 +246,7 @@ These errors occur when authentication credentials are invalid or expired.
|
|
|
197
246
|
|
|
198
247
|
----
|
|
199
248
|
|
|
200
|
-
|
|
249
|
+
9. Empty Token Response
|
|
201
250
|
^^^^^^^^^^^^^^^^^^^^^^^^
|
|
202
251
|
|
|
203
252
|
**Error Message:**
|
|
@@ -233,8 +282,8 @@ These errors occur when authentication credentials are invalid or expired.
|
|
|
233
282
|
|
|
234
283
|
----
|
|
235
284
|
|
|
236
|
-
|
|
237
|
-
|
|
285
|
+
10. Missing Expiry Field in Token
|
|
286
|
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
238
287
|
|
|
239
288
|
**Error Message:**
|
|
240
289
|
|
|
@@ -341,6 +390,14 @@ Error Summary Table
|
|
|
341
390
|
- ``If apiKey is provided , "clientId" and "OrgId" must also be provided.``
|
|
342
391
|
- N/A
|
|
343
392
|
- Provide all three parameters
|
|
393
|
+
* - Configuration
|
|
394
|
+
- ``If patToken is provided, "clientId" must also be provided.``
|
|
395
|
+
- N/A
|
|
396
|
+
- Provide clientId with PAT token
|
|
397
|
+
* - Configuration
|
|
398
|
+
- ``orgId should not be provided when using patToken.``
|
|
399
|
+
- N/A
|
|
400
|
+
- Remove orgId when using PAT token
|
|
344
401
|
* - Authentication
|
|
345
402
|
- ``Cannot pass the security checks...``
|
|
346
403
|
- 401
|
|
@@ -369,14 +426,22 @@ Required Configuration Parameters
|
|
|
369
426
|
|
|
370
427
|
When calling ``Client.getClient()``, the following parameters are required based on authentication method:
|
|
371
428
|
|
|
372
|
-
|
|
373
|
-
|
|
429
|
+
Personal Access Token (PAT) Authentication (Recommended)
|
|
430
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
431
|
+
|
|
432
|
+
- ``patToken`` - Your Personal Access Token
|
|
433
|
+
- ``clientId`` - Your client ID
|
|
434
|
+
|
|
435
|
+
**Note:** Do not provide ``orgId`` when using PAT token authentication.
|
|
436
|
+
|
|
437
|
+
API Key Authentication
|
|
438
|
+
~~~~~~~~~~~~~~~~~~~~~~
|
|
374
439
|
|
|
375
440
|
- ``apiKey`` - Your IBM Cloud API key
|
|
376
441
|
- ``clientId`` - Your client ID
|
|
377
442
|
- ``orgId`` - Your organization ID
|
|
378
|
-
- ``host`` - API host URL
|
|
379
|
-
- ``authUrl`` - Authentication URL
|
|
443
|
+
- ``host`` - API host URL (optional, uses default if not provided)
|
|
444
|
+
- ``authUrl`` - Authentication URL (optional, uses default if not provided)
|
|
380
445
|
|
|
381
446
|
Token Authentication
|
|
382
447
|
~~~~~~~~~~~~~~~~~~~~
|
|
@@ -479,8 +544,8 @@ For issues not covered in this guide:
|
|
|
479
544
|
|
|
480
545
|
----
|
|
481
546
|
|
|
482
|
-
**Last Updated:**
|
|
547
|
+
**Last Updated:** 2026-05-31
|
|
483
548
|
|
|
484
|
-
**SDK Version:** 1.0.
|
|
549
|
+
**SDK Version:** 1.0.2
|
|
485
550
|
|
|
486
551
|
**Coverage:** SDK initialization, client instance, and authentication errors
|
package/docs/_static/basic.css
CHANGED
|
@@ -741,6 +741,14 @@ abbr, acronym {
|
|
|
741
741
|
cursor: help;
|
|
742
742
|
}
|
|
743
743
|
|
|
744
|
+
.translated {
|
|
745
|
+
background-color: rgba(207, 255, 207, 0.2)
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
.untranslated {
|
|
749
|
+
background-color: rgba(255, 207, 207, 0.2)
|
|
750
|
+
}
|
|
751
|
+
|
|
744
752
|
/* -- code displays --------------------------------------------------------- */
|
|
745
753
|
|
|
746
754
|
pre {
|
package/docs/_static/doctools.js
CHANGED
|
@@ -59,7 +59,7 @@ const Documentation = {
|
|
|
59
59
|
Object.assign(Documentation.TRANSLATIONS, catalog.messages);
|
|
60
60
|
Documentation.PLURAL_EXPR = new Function(
|
|
61
61
|
"n",
|
|
62
|
-
`return (${catalog.plural_expr})
|
|
62
|
+
`return (${catalog.plural_expr})`
|
|
63
63
|
);
|
|
64
64
|
Documentation.LOCALE = catalog.locale;
|
|
65
65
|
},
|
|
@@ -89,7 +89,7 @@ const Documentation = {
|
|
|
89
89
|
|
|
90
90
|
const togglerElements = document.querySelectorAll("img.toggler");
|
|
91
91
|
togglerElements.forEach((el) =>
|
|
92
|
-
el.addEventListener("click", (event) => toggler(event.currentTarget))
|
|
92
|
+
el.addEventListener("click", (event) => toggler(event.currentTarget))
|
|
93
93
|
);
|
|
94
94
|
togglerElements.forEach((el) => (el.style.display = ""));
|
|
95
95
|
if (DOCUMENTATION_OPTIONS.COLLAPSE_INDEX) togglerElements.forEach(toggler);
|
|
@@ -98,15 +98,14 @@ const Documentation = {
|
|
|
98
98
|
initOnKeyListeners: () => {
|
|
99
99
|
// only install a listener if it is really needed
|
|
100
100
|
if (
|
|
101
|
-
!DOCUMENTATION_OPTIONS.NAVIGATION_WITH_KEYS
|
|
102
|
-
|
|
101
|
+
!DOCUMENTATION_OPTIONS.NAVIGATION_WITH_KEYS &&
|
|
102
|
+
!DOCUMENTATION_OPTIONS.ENABLE_SEARCH_SHORTCUTS
|
|
103
103
|
)
|
|
104
104
|
return;
|
|
105
105
|
|
|
106
106
|
document.addEventListener("keydown", (event) => {
|
|
107
107
|
// bail for input elements
|
|
108
|
-
if (BLACKLISTED_KEY_CONTROL_ELEMENTS.has(document.activeElement.tagName))
|
|
109
|
-
return;
|
|
108
|
+
if (BLACKLISTED_KEY_CONTROL_ELEMENTS.has(document.activeElement.tagName)) return;
|
|
110
109
|
// bail with special keys
|
|
111
110
|
if (event.altKey || event.ctrlKey || event.metaKey) return;
|
|
112
111
|
|
|
@@ -1,13 +1,192 @@
|
|
|
1
1
|
/*
|
|
2
2
|
* This script contains the language-specific data used by searchtools.js,
|
|
3
|
-
* namely the
|
|
3
|
+
* namely the list of stopwords, stemmer, scorer and splitter.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
window.stopwords = stopwords; // Export to global scope
|
|
6
|
+
var stopwords = ["a", "and", "are", "as", "at", "be", "but", "by", "for", "if", "in", "into", "is", "it", "near", "no", "not", "of", "on", "or", "such", "that", "the", "their", "then", "there", "these", "they", "this", "to", "was", "will", "with"];
|
|
8
7
|
|
|
9
8
|
|
|
10
|
-
/* Non-minified
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
/* Non-minified version is copied as a separate JS file, if available */
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Porter Stemmer
|
|
13
|
+
*/
|
|
14
|
+
var Stemmer = function() {
|
|
15
|
+
|
|
16
|
+
var step2list = {
|
|
17
|
+
ational: 'ate',
|
|
18
|
+
tional: 'tion',
|
|
19
|
+
enci: 'ence',
|
|
20
|
+
anci: 'ance',
|
|
21
|
+
izer: 'ize',
|
|
22
|
+
bli: 'ble',
|
|
23
|
+
alli: 'al',
|
|
24
|
+
entli: 'ent',
|
|
25
|
+
eli: 'e',
|
|
26
|
+
ousli: 'ous',
|
|
27
|
+
ization: 'ize',
|
|
28
|
+
ation: 'ate',
|
|
29
|
+
ator: 'ate',
|
|
30
|
+
alism: 'al',
|
|
31
|
+
iveness: 'ive',
|
|
32
|
+
fulness: 'ful',
|
|
33
|
+
ousness: 'ous',
|
|
34
|
+
aliti: 'al',
|
|
35
|
+
iviti: 'ive',
|
|
36
|
+
biliti: 'ble',
|
|
37
|
+
logi: 'log'
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
var step3list = {
|
|
41
|
+
icate: 'ic',
|
|
42
|
+
ative: '',
|
|
43
|
+
alize: 'al',
|
|
44
|
+
iciti: 'ic',
|
|
45
|
+
ical: 'ic',
|
|
46
|
+
ful: '',
|
|
47
|
+
ness: ''
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
var c = "[^aeiou]"; // consonant
|
|
51
|
+
var v = "[aeiouy]"; // vowel
|
|
52
|
+
var C = c + "[^aeiouy]*"; // consonant sequence
|
|
53
|
+
var V = v + "[aeiou]*"; // vowel sequence
|
|
54
|
+
|
|
55
|
+
var mgr0 = "^(" + C + ")?" + V + C; // [C]VC... is m>0
|
|
56
|
+
var meq1 = "^(" + C + ")?" + V + C + "(" + V + ")?$"; // [C]VC[V] is m=1
|
|
57
|
+
var mgr1 = "^(" + C + ")?" + V + C + V + C; // [C]VCVC... is m>1
|
|
58
|
+
var s_v = "^(" + C + ")?" + v; // vowel in stem
|
|
59
|
+
|
|
60
|
+
this.stemWord = function (w) {
|
|
61
|
+
var stem;
|
|
62
|
+
var suffix;
|
|
63
|
+
var firstch;
|
|
64
|
+
var origword = w;
|
|
65
|
+
|
|
66
|
+
if (w.length < 3)
|
|
67
|
+
return w;
|
|
68
|
+
|
|
69
|
+
var re;
|
|
70
|
+
var re2;
|
|
71
|
+
var re3;
|
|
72
|
+
var re4;
|
|
73
|
+
|
|
74
|
+
firstch = w.substr(0,1);
|
|
75
|
+
if (firstch == "y")
|
|
76
|
+
w = firstch.toUpperCase() + w.substr(1);
|
|
77
|
+
|
|
78
|
+
// Step 1a
|
|
79
|
+
re = /^(.+?)(ss|i)es$/;
|
|
80
|
+
re2 = /^(.+?)([^s])s$/;
|
|
81
|
+
|
|
82
|
+
if (re.test(w))
|
|
83
|
+
w = w.replace(re,"$1$2");
|
|
84
|
+
else if (re2.test(w))
|
|
85
|
+
w = w.replace(re2,"$1$2");
|
|
86
|
+
|
|
87
|
+
// Step 1b
|
|
88
|
+
re = /^(.+?)eed$/;
|
|
89
|
+
re2 = /^(.+?)(ed|ing)$/;
|
|
90
|
+
if (re.test(w)) {
|
|
91
|
+
var fp = re.exec(w);
|
|
92
|
+
re = new RegExp(mgr0);
|
|
93
|
+
if (re.test(fp[1])) {
|
|
94
|
+
re = /.$/;
|
|
95
|
+
w = w.replace(re,"");
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
else if (re2.test(w)) {
|
|
99
|
+
var fp = re2.exec(w);
|
|
100
|
+
stem = fp[1];
|
|
101
|
+
re2 = new RegExp(s_v);
|
|
102
|
+
if (re2.test(stem)) {
|
|
103
|
+
w = stem;
|
|
104
|
+
re2 = /(at|bl|iz)$/;
|
|
105
|
+
re3 = new RegExp("([^aeiouylsz])\\1$");
|
|
106
|
+
re4 = new RegExp("^" + C + v + "[^aeiouwxy]$");
|
|
107
|
+
if (re2.test(w))
|
|
108
|
+
w = w + "e";
|
|
109
|
+
else if (re3.test(w)) {
|
|
110
|
+
re = /.$/;
|
|
111
|
+
w = w.replace(re,"");
|
|
112
|
+
}
|
|
113
|
+
else if (re4.test(w))
|
|
114
|
+
w = w + "e";
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// Step 1c
|
|
119
|
+
re = /^(.+?)y$/;
|
|
120
|
+
if (re.test(w)) {
|
|
121
|
+
var fp = re.exec(w);
|
|
122
|
+
stem = fp[1];
|
|
123
|
+
re = new RegExp(s_v);
|
|
124
|
+
if (re.test(stem))
|
|
125
|
+
w = stem + "i";
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// Step 2
|
|
129
|
+
re = /^(.+?)(ational|tional|enci|anci|izer|bli|alli|entli|eli|ousli|ization|ation|ator|alism|iveness|fulness|ousness|aliti|iviti|biliti|logi)$/;
|
|
130
|
+
if (re.test(w)) {
|
|
131
|
+
var fp = re.exec(w);
|
|
132
|
+
stem = fp[1];
|
|
133
|
+
suffix = fp[2];
|
|
134
|
+
re = new RegExp(mgr0);
|
|
135
|
+
if (re.test(stem))
|
|
136
|
+
w = stem + step2list[suffix];
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// Step 3
|
|
140
|
+
re = /^(.+?)(icate|ative|alize|iciti|ical|ful|ness)$/;
|
|
141
|
+
if (re.test(w)) {
|
|
142
|
+
var fp = re.exec(w);
|
|
143
|
+
stem = fp[1];
|
|
144
|
+
suffix = fp[2];
|
|
145
|
+
re = new RegExp(mgr0);
|
|
146
|
+
if (re.test(stem))
|
|
147
|
+
w = stem + step3list[suffix];
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// Step 4
|
|
151
|
+
re = /^(.+?)(al|ance|ence|er|ic|able|ible|ant|ement|ment|ent|ou|ism|ate|iti|ous|ive|ize)$/;
|
|
152
|
+
re2 = /^(.+?)(s|t)(ion)$/;
|
|
153
|
+
if (re.test(w)) {
|
|
154
|
+
var fp = re.exec(w);
|
|
155
|
+
stem = fp[1];
|
|
156
|
+
re = new RegExp(mgr1);
|
|
157
|
+
if (re.test(stem))
|
|
158
|
+
w = stem;
|
|
159
|
+
}
|
|
160
|
+
else if (re2.test(w)) {
|
|
161
|
+
var fp = re2.exec(w);
|
|
162
|
+
stem = fp[1] + fp[2];
|
|
163
|
+
re2 = new RegExp(mgr1);
|
|
164
|
+
if (re2.test(stem))
|
|
165
|
+
w = stem;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
// Step 5
|
|
169
|
+
re = /^(.+?)e$/;
|
|
170
|
+
if (re.test(w)) {
|
|
171
|
+
var fp = re.exec(w);
|
|
172
|
+
stem = fp[1];
|
|
173
|
+
re = new RegExp(mgr1);
|
|
174
|
+
re2 = new RegExp(meq1);
|
|
175
|
+
re3 = new RegExp("^" + C + v + "[^aeiouwxy]$");
|
|
176
|
+
if (re.test(stem) || (re2.test(stem) && !(re3.test(stem))))
|
|
177
|
+
w = stem;
|
|
178
|
+
}
|
|
179
|
+
re = /ll$/;
|
|
180
|
+
re2 = new RegExp(mgr1);
|
|
181
|
+
if (re.test(w) && re2.test(w)) {
|
|
182
|
+
re = /.$/;
|
|
183
|
+
w = w.replace(re,"");
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
// and turn initial Y back to y
|
|
187
|
+
if (firstch == "y")
|
|
188
|
+
w = firstch.toLowerCase() + w.substr(1);
|
|
189
|
+
return w;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|