emissions-api-sdk 1.0.0 → 1.0.2
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 +33 -2
- package/dist/Constants.js +23 -1
- package/dist/api/Calculation.js +78 -15
- package/dist/api/Factor.js +99 -18
- package/dist/api/FactorSets.js +1 -1
- package/dist/api/Fugitive.js +76 -13
- package/dist/api/Location.js +76 -15
- package/dist/api/Mobile.js +65 -1
- package/dist/api/Stationary.js +78 -15
- package/dist/api/TransportationAndDistribution.js +77 -14
- package/dist/coverage/clover.xml +191 -81
- package/dist/coverage/coverage-final.json +11 -11
- package/dist/coverage/lcov-report/index.html +16 -16
- package/dist/coverage/lcov-report/src/Client.ts.html +23 -23
- package/dist/coverage/lcov-report/src/Constants.ts.html +82 -4
- package/dist/coverage/lcov-report/src/api/Calculation.ts.html +245 -26
- package/dist/coverage/lcov-report/src/api/Factor.ts.html +313 -34
- package/dist/coverage/lcov-report/src/api/FactorSets.ts.html +8 -5
- package/dist/coverage/lcov-report/src/api/Fugitive.ts.html +246 -24
- package/dist/coverage/lcov-report/src/api/Location.ts.html +245 -26
- package/dist/coverage/lcov-report/src/api/Mobile.ts.html +240 -12
- package/dist/coverage/lcov-report/src/api/Stationary.ts.html +248 -26
- package/dist/coverage/lcov-report/src/api/TransportationAndDistribution.ts.html +250 -25
- package/dist/coverage/lcov-report/src/api/index.html +25 -25
- package/dist/coverage/lcov-report/src/index.html +7 -7
- package/dist/coverage/lcov-report/src/request.ts.html +1 -1
- package/dist/coverage/lcov-report/src/utils.ts.html +5 -5
- package/dist/coverage/lcov-report/test/index.html +1 -1
- package/dist/coverage/lcov-report/test/mocks/CommonRequest.ts.html +1 -1
- 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/SearchRequest.ts.html +1 -1
- package/dist/coverage/lcov-report/test/mocks/index.html +1 -1
- package/dist/coverage/lcov-report/test/testUtils.ts.html +1 -1
- package/dist/coverage/lcov.info +287 -133
- package/dist/interfaces/response/AreaResponse.js +2 -0
- package/dist/interfaces/response/EmissionResponse.js +2 -0
- package/dist/interfaces/response/EmissionResponseWithDetails.js +2 -0
- package/dist/interfaces/response/FactorResponse.js +2 -0
- package/dist/interfaces/response/FactorSetResponse.js +2 -0
- package/dist/interfaces/response/SearchResponse.js +2 -0
- package/dist/interfaces/response/TypeResponse.js +2 -0
- package/dist/interfaces/response/UnitResponse.js +2 -0
- package/dist/types/Constants.d.ts +22 -0
- package/dist/types/api/Calculation.d.ts +59 -16
- package/dist/types/api/Factor.d.ts +73 -20
- package/dist/types/api/FactorSets.d.ts +3 -2
- package/dist/types/api/Fugitive.d.ts +57 -14
- package/dist/types/api/Location.d.ts +57 -16
- package/dist/types/api/Mobile.d.ts +46 -2
- package/dist/types/api/Stationary.d.ts +59 -16
- package/dist/types/api/TransportationAndDistribution.d.ts +58 -15
- package/dist/types/index.d.ts +8 -0
- package/dist/types/interfaces/response/AreaResponse.d.ts +20 -0
- package/dist/types/interfaces/response/EmissionResponse.d.ts +31 -0
- package/dist/types/interfaces/response/EmissionResponseWithDetails.d.ts +144 -0
- package/dist/types/interfaces/response/FactorResponse.d.ts +53 -0
- package/dist/types/interfaces/response/FactorSetResponse.d.ts +38 -0
- package/dist/types/interfaces/response/SearchResponse.d.ts +41 -0
- package/dist/types/interfaces/response/TypeResponse.d.ts +7 -0
- package/dist/types/interfaces/response/UnitResponse.d.ts +7 -0
- package/docs/.nojekyll +0 -0
- package/docs/_sources/authentication.rst.txt +164 -0
- package/docs/_sources/client.rst.txt +137 -0
- package/docs/_sources/getting_started.rst.txt +164 -0
- package/docs/_sources/index.rst.txt +30 -0
- package/docs/_sources/reference.rst.txt +129 -0
- package/docs/_sources/sdk.rst.txt +13 -0
- package/docs/_sources/troubleshooting.rst.txt +486 -0
- package/docs/_static/basic.css +914 -0
- package/docs/_static/custom.css +16 -0
- package/docs/_static/debug.css +69 -0
- package/docs/_static/doctools.js +149 -0
- package/docs/_static/documentation_options.js +13 -0
- package/docs/_static/file.png +0 -0
- package/docs/_static/language_data.js +192 -0
- package/docs/_static/minus.png +0 -0
- package/docs/_static/plus.png +0 -0
- package/docs/_static/pygments.css +232 -0
- package/docs/_static/scripts/furo-extensions.js +0 -0
- package/docs/_static/scripts/furo.js +3 -0
- package/docs/_static/scripts/furo.js.LICENSE.txt +7 -0
- package/docs/_static/scripts/furo.js.map +1 -0
- package/docs/_static/searchtools.js +632 -0
- package/docs/_static/skeleton.css +296 -0
- package/docs/_static/sphinx_highlight.js +154 -0
- package/docs/_static/sphinx_js.css +0 -0
- package/docs/_static/styles/furo-extensions.css +2 -0
- package/docs/_static/styles/furo-extensions.css.map +1 -0
- package/docs/_static/styles/furo.css +2 -0
- package/docs/_static/styles/furo.css.map +1 -0
- package/docs/authentication.html +523 -0
- package/docs/client.html +477 -0
- package/docs/genindex.html +492 -0
- package/docs/getting_started.html +491 -0
- package/docs/index.html +357 -0
- package/docs/objects.inv +0 -0
- package/docs/reference.html +1584 -0
- package/docs/sdk.html +334 -0
- package/docs/search.html +297 -0
- package/docs/searchindex.js +1 -0
- package/docs/troubleshooting.html +786 -0
- package/package.json +1 -1
- package/sphinx-build/Makefile +49 -0
- package/sphinx-build/requirements.txt +5 -0
- package/sphinx-build/source/_static/custom.css +16 -0
- package/sphinx-build/source/authentication.rst +164 -0
- package/sphinx-build/source/client.rst +137 -0
- package/sphinx-build/source/conf.py +56 -0
- package/sphinx-build/source/getting_started.rst +164 -0
- package/sphinx-build/source/index.rst +30 -0
- package/sphinx-build/source/reference.rst +129 -0
- package/sphinx-build/source/sdk.rst +13 -0
- package/sphinx-build/source/troubleshooting.rst +486 -0
- package/src/Constants.ts +26 -0
- package/src/api/Calculation.ts +94 -20
- package/src/api/Factor.ts +122 -28
- package/src/api/FactorSets.ts +4 -3
- package/src/api/Fugitive.ts +93 -18
- package/src/api/Location.ts +94 -20
- package/src/api/Mobile.ts +83 -6
- package/src/api/Stationary.ts +95 -20
- package/src/api/TransportationAndDistribution.ts +95 -19
- package/src/index.ts +33 -1
- package/src/interfaces/response/AreaResponse.ts +25 -0
- package/src/interfaces/response/EmissionResponse.ts +44 -0
- package/src/interfaces/response/EmissionResponseWithDetails.ts +183 -0
- package/src/interfaces/response/FactorResponse.ts +78 -0
- package/src/interfaces/response/FactorSetResponse.ts +52 -0
- package/src/interfaces/response/SearchResponse.ts +52 -0
- package/src/interfaces/response/TypeResponse.ts +7 -0
- package/src/interfaces/response/UnitResponse.ts +7 -0
- package/test/apiTest.test.ts +173 -6
- package/dist/api/Factors.js +0 -98
- package/dist/api/FugitiveEmission.js +0 -40
- package/dist/api/GenericCalculation.js +0 -41
- package/dist/api/LocationEmission.js +0 -41
- package/dist/api/MobileEmission.js +0 -41
- package/dist/api/StationaryEmission.js +0 -41
- package/dist/api/TransportationDistributionEmission.js +0 -40
- package/dist/coverage/lcov-report/src/api/Factors.ts.html +0 -403
- package/dist/coverage/lcov-report/src/api/FugitiveEmission.ts.html +0 -214
- package/dist/coverage/lcov-report/src/api/GenericCalculation.ts.html +0 -217
- package/dist/coverage/lcov-report/src/api/LocationEmission.ts.html +0 -214
- package/dist/coverage/lcov-report/src/api/MobileEmission.ts.html +0 -220
- package/dist/coverage/lcov-report/src/api/StationaryEmission.ts.html +0 -220
- package/dist/coverage/lcov-report/src/api/TransportationDistributionEmission.ts.html +0 -211
- package/dist/types/api/Factors.d.ts +0 -68
- package/dist/types/api/FugitiveEmission.d.ts +0 -27
- package/dist/types/api/GenericCalculation.d.ts +0 -28
- package/dist/types/api/LocationEmission.d.ts +0 -28
- package/dist/types/api/MobileEmission.d.ts +0 -28
- package/dist/types/api/StationaryEmission.d.ts +0 -28
- package/dist/types/api/TransportationDistributionEmission.d.ts +0 -27
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
div.nbinput.container div.input_area {
|
|
2
|
+
border: 1px solid #e0e0e0;
|
|
3
|
+
border-radius: 4px;
|
|
4
|
+
background: #f8f8f8;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
div.nboutput.container div.output_area {
|
|
8
|
+
border: 1px solid #e0e0e0;
|
|
9
|
+
border-radius: 4px;
|
|
10
|
+
background: #fcfcfc;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/* Make code cells more readable */
|
|
14
|
+
.highlight {
|
|
15
|
+
background: #f8f8f8;
|
|
16
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/*
|
|
2
|
+
This CSS file should be overridden by the theme authors. It's
|
|
3
|
+
meant for debugging and developing the skeleton that this theme provides.
|
|
4
|
+
*/
|
|
5
|
+
body {
|
|
6
|
+
font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif,
|
|
7
|
+
"Apple Color Emoji", "Segoe UI Emoji";
|
|
8
|
+
background: lavender;
|
|
9
|
+
}
|
|
10
|
+
.sb-announcement {
|
|
11
|
+
background: rgb(131, 131, 131);
|
|
12
|
+
}
|
|
13
|
+
.sb-announcement__inner {
|
|
14
|
+
background: black;
|
|
15
|
+
color: white;
|
|
16
|
+
}
|
|
17
|
+
.sb-header {
|
|
18
|
+
background: lightskyblue;
|
|
19
|
+
}
|
|
20
|
+
.sb-header__inner {
|
|
21
|
+
background: royalblue;
|
|
22
|
+
color: white;
|
|
23
|
+
}
|
|
24
|
+
.sb-header-secondary {
|
|
25
|
+
background: lightcyan;
|
|
26
|
+
}
|
|
27
|
+
.sb-header-secondary__inner {
|
|
28
|
+
background: cornflowerblue;
|
|
29
|
+
color: white;
|
|
30
|
+
}
|
|
31
|
+
.sb-sidebar-primary {
|
|
32
|
+
background: lightgreen;
|
|
33
|
+
}
|
|
34
|
+
.sb-main {
|
|
35
|
+
background: blanchedalmond;
|
|
36
|
+
}
|
|
37
|
+
.sb-main__inner {
|
|
38
|
+
background: antiquewhite;
|
|
39
|
+
}
|
|
40
|
+
.sb-header-article {
|
|
41
|
+
background: lightsteelblue;
|
|
42
|
+
}
|
|
43
|
+
.sb-article-container {
|
|
44
|
+
background: snow;
|
|
45
|
+
}
|
|
46
|
+
.sb-article-main {
|
|
47
|
+
background: white;
|
|
48
|
+
}
|
|
49
|
+
.sb-footer-article {
|
|
50
|
+
background: lightpink;
|
|
51
|
+
}
|
|
52
|
+
.sb-sidebar-secondary {
|
|
53
|
+
background: lightgoldenrodyellow;
|
|
54
|
+
}
|
|
55
|
+
.sb-footer-content {
|
|
56
|
+
background: plum;
|
|
57
|
+
}
|
|
58
|
+
.sb-footer-content__inner {
|
|
59
|
+
background: palevioletred;
|
|
60
|
+
}
|
|
61
|
+
.sb-footer {
|
|
62
|
+
background: pink;
|
|
63
|
+
}
|
|
64
|
+
.sb-footer__inner {
|
|
65
|
+
background: salmon;
|
|
66
|
+
}
|
|
67
|
+
.sb-article {
|
|
68
|
+
background: white;
|
|
69
|
+
}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Base JavaScript utilities for all Sphinx HTML documentation.
|
|
3
|
+
*/
|
|
4
|
+
"use strict";
|
|
5
|
+
|
|
6
|
+
const BLACKLISTED_KEY_CONTROL_ELEMENTS = new Set([
|
|
7
|
+
"TEXTAREA",
|
|
8
|
+
"INPUT",
|
|
9
|
+
"SELECT",
|
|
10
|
+
"BUTTON",
|
|
11
|
+
]);
|
|
12
|
+
|
|
13
|
+
const _ready = (callback) => {
|
|
14
|
+
if (document.readyState !== "loading") {
|
|
15
|
+
callback();
|
|
16
|
+
} else {
|
|
17
|
+
document.addEventListener("DOMContentLoaded", callback);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Small JavaScript module for the documentation.
|
|
23
|
+
*/
|
|
24
|
+
const Documentation = {
|
|
25
|
+
init: () => {
|
|
26
|
+
Documentation.initDomainIndexTable();
|
|
27
|
+
Documentation.initOnKeyListeners();
|
|
28
|
+
},
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* i18n support
|
|
32
|
+
*/
|
|
33
|
+
TRANSLATIONS: {},
|
|
34
|
+
PLURAL_EXPR: (n) => (n === 1 ? 0 : 1),
|
|
35
|
+
LOCALE: "unknown",
|
|
36
|
+
|
|
37
|
+
// gettext and ngettext don't access this so that the functions
|
|
38
|
+
// can safely bound to a different name (_ = Documentation.gettext)
|
|
39
|
+
gettext: (string) => {
|
|
40
|
+
const translated = Documentation.TRANSLATIONS[string];
|
|
41
|
+
switch (typeof translated) {
|
|
42
|
+
case "undefined":
|
|
43
|
+
return string; // no translation
|
|
44
|
+
case "string":
|
|
45
|
+
return translated; // translation exists
|
|
46
|
+
default:
|
|
47
|
+
return translated[0]; // (singular, plural) translation tuple exists
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
|
|
51
|
+
ngettext: (singular, plural, n) => {
|
|
52
|
+
const translated = Documentation.TRANSLATIONS[singular];
|
|
53
|
+
if (typeof translated !== "undefined")
|
|
54
|
+
return translated[Documentation.PLURAL_EXPR(n)];
|
|
55
|
+
return n === 1 ? singular : plural;
|
|
56
|
+
},
|
|
57
|
+
|
|
58
|
+
addTranslations: (catalog) => {
|
|
59
|
+
Object.assign(Documentation.TRANSLATIONS, catalog.messages);
|
|
60
|
+
Documentation.PLURAL_EXPR = new Function(
|
|
61
|
+
"n",
|
|
62
|
+
`return (${catalog.plural_expr})`
|
|
63
|
+
);
|
|
64
|
+
Documentation.LOCALE = catalog.locale;
|
|
65
|
+
},
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* helper function to focus on search bar
|
|
69
|
+
*/
|
|
70
|
+
focusSearchBar: () => {
|
|
71
|
+
document.querySelectorAll("input[name=q]")[0]?.focus();
|
|
72
|
+
},
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Initialise the domain index toggle buttons
|
|
76
|
+
*/
|
|
77
|
+
initDomainIndexTable: () => {
|
|
78
|
+
const toggler = (el) => {
|
|
79
|
+
const idNumber = el.id.substr(7);
|
|
80
|
+
const toggledRows = document.querySelectorAll(`tr.cg-${idNumber}`);
|
|
81
|
+
if (el.src.substr(-9) === "minus.png") {
|
|
82
|
+
el.src = `${el.src.substr(0, el.src.length - 9)}plus.png`;
|
|
83
|
+
toggledRows.forEach((el) => (el.style.display = "none"));
|
|
84
|
+
} else {
|
|
85
|
+
el.src = `${el.src.substr(0, el.src.length - 8)}minus.png`;
|
|
86
|
+
toggledRows.forEach((el) => (el.style.display = ""));
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
const togglerElements = document.querySelectorAll("img.toggler");
|
|
91
|
+
togglerElements.forEach((el) =>
|
|
92
|
+
el.addEventListener("click", (event) => toggler(event.currentTarget))
|
|
93
|
+
);
|
|
94
|
+
togglerElements.forEach((el) => (el.style.display = ""));
|
|
95
|
+
if (DOCUMENTATION_OPTIONS.COLLAPSE_INDEX) togglerElements.forEach(toggler);
|
|
96
|
+
},
|
|
97
|
+
|
|
98
|
+
initOnKeyListeners: () => {
|
|
99
|
+
// only install a listener if it is really needed
|
|
100
|
+
if (
|
|
101
|
+
!DOCUMENTATION_OPTIONS.NAVIGATION_WITH_KEYS &&
|
|
102
|
+
!DOCUMENTATION_OPTIONS.ENABLE_SEARCH_SHORTCUTS
|
|
103
|
+
)
|
|
104
|
+
return;
|
|
105
|
+
|
|
106
|
+
document.addEventListener("keydown", (event) => {
|
|
107
|
+
// bail for input elements
|
|
108
|
+
if (BLACKLISTED_KEY_CONTROL_ELEMENTS.has(document.activeElement.tagName)) return;
|
|
109
|
+
// bail with special keys
|
|
110
|
+
if (event.altKey || event.ctrlKey || event.metaKey) return;
|
|
111
|
+
|
|
112
|
+
if (!event.shiftKey) {
|
|
113
|
+
switch (event.key) {
|
|
114
|
+
case "ArrowLeft":
|
|
115
|
+
if (!DOCUMENTATION_OPTIONS.NAVIGATION_WITH_KEYS) break;
|
|
116
|
+
|
|
117
|
+
const prevLink = document.querySelector('link[rel="prev"]');
|
|
118
|
+
if (prevLink && prevLink.href) {
|
|
119
|
+
window.location.href = prevLink.href;
|
|
120
|
+
event.preventDefault();
|
|
121
|
+
}
|
|
122
|
+
break;
|
|
123
|
+
case "ArrowRight":
|
|
124
|
+
if (!DOCUMENTATION_OPTIONS.NAVIGATION_WITH_KEYS) break;
|
|
125
|
+
|
|
126
|
+
const nextLink = document.querySelector('link[rel="next"]');
|
|
127
|
+
if (nextLink && nextLink.href) {
|
|
128
|
+
window.location.href = nextLink.href;
|
|
129
|
+
event.preventDefault();
|
|
130
|
+
}
|
|
131
|
+
break;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// some keyboard layouts may need Shift to get /
|
|
136
|
+
switch (event.key) {
|
|
137
|
+
case "/":
|
|
138
|
+
if (!DOCUMENTATION_OPTIONS.ENABLE_SEARCH_SHORTCUTS) break;
|
|
139
|
+
Documentation.focusSearchBar();
|
|
140
|
+
event.preventDefault();
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
},
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
// quick alias for translations
|
|
147
|
+
const _ = Documentation.gettext;
|
|
148
|
+
|
|
149
|
+
_ready(Documentation.init);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const DOCUMENTATION_OPTIONS = {
|
|
2
|
+
VERSION: '',
|
|
3
|
+
LANGUAGE: 'en',
|
|
4
|
+
COLLAPSE_INDEX: false,
|
|
5
|
+
BUILDER: 'html',
|
|
6
|
+
FILE_SUFFIX: '.html',
|
|
7
|
+
LINK_SUFFIX: '.html',
|
|
8
|
+
HAS_SOURCE: true,
|
|
9
|
+
SOURCELINK_SUFFIX: '.txt',
|
|
10
|
+
NAVIGATION_WITH_KEYS: false,
|
|
11
|
+
SHOW_SEARCH_SUMMARY: true,
|
|
12
|
+
ENABLE_SEARCH_SHORTCUTS: true,
|
|
13
|
+
};
|
|
Binary file
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* This script contains the language-specific data used by searchtools.js,
|
|
3
|
+
* namely the list of stopwords, stemmer, scorer and splitter.
|
|
4
|
+
*/
|
|
5
|
+
|
|
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"];
|
|
7
|
+
|
|
8
|
+
|
|
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
|
+
|
|
Binary file
|
|
Binary file
|