ifct2017 2.0.14 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +661 -21
- package/README.md +1019 -71
- package/abbreviations/index.csv +78 -0
- package/abbreviations/index.d.ts +39 -0
- package/abbreviations/index.js +103 -0
- package/abbreviations/index.txt +12 -0
- package/about/build.ts +31 -0
- package/about/index.d.ts +47 -0
- package/about/index.js +110 -0
- package/about/index.txt +174 -0
- package/build.ts +115 -0
- package/carbohydrates/index.csv +8 -0
- package/carbohydrates/index.d.ts +42 -0
- package/carbohydrates/index.js +112 -0
- package/carbohydrates/index.txt +14 -0
- package/codes/index.csv +2904 -0
- package/codes/index.d.ts +36 -0
- package/codes/index.js +102 -0
- package/codes/index.txt +12 -0
- package/columndescriptions/build.ts +22 -0
- package/columndescriptions/index.csv +215 -0
- package/columndescriptions/index.d.ts +44 -0
- package/columndescriptions/index.js +119 -0
- package/columns/build.ts +23 -0
- package/columns/index.csv +215 -0
- package/columns/index.d.ts +39 -0
- package/columns/index.js +111 -0
- package/columns/index.txt +71 -0
- package/compositingcentres/index.csv +7 -0
- package/compositingcentres/index.d.ts +35 -0
- package/compositingcentres/index.js +103 -0
- package/compositingcentres/index.txt +13 -0
- package/compositions/build.ts +212 -0
- package/compositions/index.csv +543 -0
- package/compositions/index.d.ts +254 -0
- package/compositions/index.js +204 -0
- package/compositionstats/build.ts +103 -0
- package/compositionstats/index.csv +4 -0
- package/compositionstats/index.d.ts +31 -0
- package/compositionstats/index.js +97 -0
- package/contents/index.csv +21 -0
- package/contents/index.d.ts +39 -0
- package/contents/index.js +102 -0
- package/contents/index.txt +13 -0
- package/deno.lock +67 -0
- package/descriptions/index.csv +543 -0
- package/descriptions/index.d.ts +45 -0
- package/descriptions/index.js +124 -0
- package/descriptions/index.txt +15 -0
- package/energies/index.csv +6 -0
- package/energies/index.d.ts +34 -0
- package/energies/index.js +101 -0
- package/energies/index.txt +13 -0
- package/frequencydistribution/index.csv +10 -0
- package/frequencydistribution/index.d.ts +36 -0
- package/frequencydistribution/index.js +90 -0
- package/frequencydistribution/index.txt +14 -0
- package/groups/index.csv +21 -0
- package/groups/index.d.ts +46 -0
- package/groups/index.js +118 -0
- package/groups/index.txt +14 -0
- package/hierarchy/asset.csv +215 -0
- package/hierarchy/asset.txt +70 -0
- package/hierarchy/build.ts +73 -0
- package/hierarchy/index.csv +215 -0
- package/hierarchy/index.d.ts +39 -0
- package/hierarchy/index.js +100 -0
- package/hierarchy/index.txt +14 -0
- package/index.d.ts +24 -28
- package/index.js +28 -39
- package/index.test.ts +717 -0
- package/intakes/build.ts +28 -0
- package/intakes/index.csv +42 -0
- package/intakes/index.d.ts +66 -0
- package/intakes/index.js +113 -0
- package/intakes/index.txt +20 -0
- package/jonesfactors/index.csv +15 -0
- package/jonesfactors/index.d.ts +35 -0
- package/jonesfactors/index.js +105 -0
- package/jonesfactors/index.txt +12 -0
- package/languages/index.csv +22 -0
- package/languages/index.d.ts +39 -0
- package/languages/index.js +103 -0
- package/languages/index.txt +12 -0
- package/methods/build.ts +101 -0
- package/methods/index.csv +37 -0
- package/methods/index.d.ts +39 -0
- package/methods/index.js +196 -0
- package/methods/index.txt +13 -0
- package/package.json +15 -63
- package/regions/index.csv +7 -0
- package/regions/index.d.ts +36 -0
- package/regions/index.js +100 -0
- package/regions/index.txt +12 -0
- package/representations/build.ts +133 -0
- package/representations/index.csv +215 -0
- package/representations/index.d.ts +36 -0
- package/representations/index.js +91 -0
- package/retentionfactors/groups.csv +21 -0
- package/retentionfactors/index.csv +215 -0
- package/samplingunits/index.csv +36 -0
- package/samplingunits/index.d.ts +39 -0
- package/samplingunits/index.js +110 -0
- package/samplingunits/index.txt +14 -0
- package/yieldfactors/index.csv +543 -0
- package/yieldfactors/index.d.ts +57 -0
- package/yieldfactors/index.js +158 -0
- package/yieldfactors/index.txt +294 -0
- package/corpus.js +0 -6
- package/corpus.min.js +0 -1
- package/pictures.d.ts +0 -41
package/index.test.ts
ADDED
|
@@ -0,0 +1,717 @@
|
|
|
1
|
+
// Copyright (C) 2025-26 Subhajit Sahu
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
3
|
+
// See LICENSE for full terms
|
|
4
|
+
import {assertEquals} from "jsr:@std/assert";
|
|
5
|
+
import * as ifct2017 from "./index.ts";
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
//#region TEST ABBREVIATIONS
|
|
11
|
+
Deno.test("Abbreviations 1", async () => {
|
|
12
|
+
await ifct2017.loadAbbreviations();
|
|
13
|
+
const a = ifct2017.abbreviations('GLV');
|
|
14
|
+
const b = ifct2017.abbreviations('g l v');
|
|
15
|
+
const c = {abbr: 'GLV', full: 'Green Leafy Vegetables'};
|
|
16
|
+
assertEquals(a, c);
|
|
17
|
+
assertEquals(b, c);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
Deno.test("Abbreviations 2", async () => {
|
|
22
|
+
await ifct2017.loadAbbreviations();
|
|
23
|
+
const a = ifct2017.abbreviations('what is D.R.I.');
|
|
24
|
+
const b = ifct2017.abbreviations('d. r. i. stands for?');
|
|
25
|
+
const c = {abbr: 'DRI', full: 'Dietary reference intake'};
|
|
26
|
+
assertEquals(a, c);
|
|
27
|
+
assertEquals(b, c);
|
|
28
|
+
});
|
|
29
|
+
//#endregion
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
//#region TEST ABOUT
|
|
35
|
+
Deno.test("About 1", async () => {
|
|
36
|
+
await ifct2017.loadAbout();
|
|
37
|
+
const a = ifct2017.about('who is you publisher');
|
|
38
|
+
const b = ifct2017.about('which organization issued you');
|
|
39
|
+
assertEquals(a, b);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
Deno.test("About 2", async () => {
|
|
44
|
+
await ifct2017.loadAbout();
|
|
45
|
+
const a = ifct2017.about('can i know the food groups');
|
|
46
|
+
const b = ifct2017.about('i want to know what types of food are there');
|
|
47
|
+
assertEquals(a, b);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
Deno.test("About 3", async () => {
|
|
52
|
+
await ifct2017.loadAbout();
|
|
53
|
+
const a = ifct2017.about('what happened in 1951');
|
|
54
|
+
const b = ifct2017.about('what was the situation in 1951');
|
|
55
|
+
assertEquals(a, b);
|
|
56
|
+
});
|
|
57
|
+
//#endregion
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
//#region TEST CARBOHYDRATES
|
|
63
|
+
Deno.test("Carbohydrates 1", async () => {
|
|
64
|
+
await ifct2017.loadCarbohydrates();
|
|
65
|
+
const a = ifct2017.carbohydrates('monosaccharide');
|
|
66
|
+
const b = ifct2017.carbohydrates('Glucose');
|
|
67
|
+
const c = [{
|
|
68
|
+
sno: '1',
|
|
69
|
+
carbohydrate: 'Monosaccharides e.g. glucose',
|
|
70
|
+
hydrolysis: 100,
|
|
71
|
+
monosaccharide: 1,
|
|
72
|
+
}];
|
|
73
|
+
assertEquals(a, c);
|
|
74
|
+
assertEquals(b, c);
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
Deno.test("Carbohydrates 2", async () => {
|
|
79
|
+
await ifct2017.loadCarbohydrates();
|
|
80
|
+
const a = ifct2017.carbohydrates('what is carbohydrate conversion factor of disaccharides?');
|
|
81
|
+
const b = ifct2017.carbohydrates('maltose conversion factor');
|
|
82
|
+
const c = [{
|
|
83
|
+
sno: '2',
|
|
84
|
+
carbohydrate: 'Disaccharides e.g. sucrose, lactose, maltose',
|
|
85
|
+
hydrolysis: 105,
|
|
86
|
+
monosaccharide: 1.05,
|
|
87
|
+
}];
|
|
88
|
+
assertEquals(a, c);
|
|
89
|
+
assertEquals(b, c);
|
|
90
|
+
});
|
|
91
|
+
//#endregion
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
//#region TEST CODES
|
|
97
|
+
Deno.test("Codes 1", async () => {
|
|
98
|
+
await ifct2017.loadCodes();
|
|
99
|
+
const a = ifct2017.codes('mango green');
|
|
100
|
+
const b = ifct2017.codes('Raw mango');
|
|
101
|
+
const c = [{name: 'Mango, green, raw (Common)', code: 'D057'}];
|
|
102
|
+
assertEquals(a, c);
|
|
103
|
+
assertEquals(b, c);
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
Deno.test("Codes 2", async () => {
|
|
108
|
+
await ifct2017.loadCodes();
|
|
109
|
+
const a = ifct2017.codes('what is food code of atta?');
|
|
110
|
+
const b = ifct2017.codes('atta code');
|
|
111
|
+
const c = [
|
|
112
|
+
{name: 'Atta (H., P.)', code: 'A019'},
|
|
113
|
+
{name: 'Gahama atta (O.)', code: 'A019'},
|
|
114
|
+
{name: 'Wheat flour, atta (Common)', code: 'A019'}
|
|
115
|
+
];
|
|
116
|
+
assertEquals(a, c);
|
|
117
|
+
assertEquals(b, c);
|
|
118
|
+
});
|
|
119
|
+
//#endregion
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
//#region TEST COLUMNS
|
|
125
|
+
Deno.test("Columns 1", async () => {
|
|
126
|
+
await ifct2017.loadColumns();
|
|
127
|
+
const a = ifct2017.columns('vitamin c');
|
|
128
|
+
const b = ifct2017.columns('c-vitamin');
|
|
129
|
+
assertEquals(a[0].code, 'vitc');
|
|
130
|
+
assertEquals(b[0].code, 'vitc');
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
Deno.test("Columns 2", async () => {
|
|
135
|
+
await ifct2017.loadColumns();
|
|
136
|
+
const a = ifct2017.columns('what is butyric acid?');
|
|
137
|
+
const b = ifct2017.columns('c4:0 stands for?');
|
|
138
|
+
assertEquals(a[0].code, 'f4d0');
|
|
139
|
+
assertEquals(b[0].code, 'f4d0');
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
Deno.test("Columns 3", async () => {
|
|
144
|
+
await ifct2017.loadColumns();
|
|
145
|
+
const a = ifct2017.columns('fats');
|
|
146
|
+
const b = ifct2017.columns('total fat');
|
|
147
|
+
assertEquals(a[0].code, 'fatce');
|
|
148
|
+
assertEquals(b[0].code, 'fatce');
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
Deno.test("Columns 4", async () => {
|
|
153
|
+
await ifct2017.loadColumns();
|
|
154
|
+
const a = ifct2017.columns('fibers');
|
|
155
|
+
const b = ifct2017.columns('total fibre');
|
|
156
|
+
assertEquals(a[0].code, 'fibtg');
|
|
157
|
+
assertEquals(b[0].code, 'fibtg');
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
Deno.test("Columns 5", async () => {
|
|
162
|
+
await ifct2017.loadColumns();
|
|
163
|
+
const a = ifct2017.columns('vitamin b1');
|
|
164
|
+
const b = ifct2017.columns('vitamin b-1');
|
|
165
|
+
assertEquals(a[0].code, 'thia');
|
|
166
|
+
assertEquals(b[0].code, 'thia');
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
Deno.test("Columns 6", async () => {
|
|
171
|
+
await ifct2017.loadColumns();
|
|
172
|
+
const a = ifct2017.columns('vitamin c');
|
|
173
|
+
const b = ifct2017.columns('ascorbic acid');
|
|
174
|
+
assertEquals(a[0].code, 'vitc');
|
|
175
|
+
assertEquals(b[0].code, 'vitc');
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
Deno.test("Columns 7", async () => {
|
|
180
|
+
await ifct2017.loadColumns();
|
|
181
|
+
const a = ifct2017.columns('vitamin b');
|
|
182
|
+
const b = ifct2017.columns('total vitamin b');
|
|
183
|
+
assertEquals(a[0].code, 'vitb');
|
|
184
|
+
assertEquals(b[0].code, 'vitb');
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
Deno.test("Columns 8", async () => {
|
|
189
|
+
await ifct2017.loadColumns();
|
|
190
|
+
const a = ifct2017.columns('vitamin a');
|
|
191
|
+
const b = ifct2017.columns('total vitamin a');
|
|
192
|
+
assertEquals(a[0].code, 'vita');
|
|
193
|
+
assertEquals(b[0].code, 'vita');
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
Deno.test("Columns 9", async () => {
|
|
198
|
+
await ifct2017.loadColumns();
|
|
199
|
+
const a = ifct2017.columns('organic acid');
|
|
200
|
+
const b = ifct2017.columns('total organic acids');
|
|
201
|
+
assertEquals(a[0].code, 'orgac');
|
|
202
|
+
assertEquals(b[0].code, 'orgac');
|
|
203
|
+
});
|
|
204
|
+
//#endregion
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
//#region TEST COMPOSITING CENTRES
|
|
210
|
+
Deno.test("Compositing centres 1", async () => {
|
|
211
|
+
await ifct2017.loadCompositingCentres();
|
|
212
|
+
const a = ifct2017.compositingCentres('west');
|
|
213
|
+
const b = ifct2017.compositingCentres('Mumbai');
|
|
214
|
+
const c = [{region: 'West', centre: 'Mumbai', samples: 12}];
|
|
215
|
+
assertEquals(a, c);
|
|
216
|
+
assertEquals(b, c);
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
Deno.test("Compositing centres 2", async () => {
|
|
221
|
+
await ifct2017.loadCompositingCentres();
|
|
222
|
+
const a = ifct2017.compositingCentres('what is compositing centre of north east?');
|
|
223
|
+
const b = ifct2017.compositingCentres('North East compositing centre');
|
|
224
|
+
const c = [{region: 'North East', centre: 'Guwahati', samples: 11}];
|
|
225
|
+
assertEquals(a, c);
|
|
226
|
+
assertEquals(b, c);
|
|
227
|
+
});
|
|
228
|
+
//#endregion
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
//#region TEST COMPOSITIONS
|
|
234
|
+
Deno.test("Compositions 1", async () => {
|
|
235
|
+
await ifct2017.loadCompositions();
|
|
236
|
+
const a = ifct2017.compositions('pineapple');
|
|
237
|
+
const b = ifct2017.compositions('ananas comosus');
|
|
238
|
+
assertEquals(a[0].code, 'E053');
|
|
239
|
+
assertEquals(b[0].code, 'E053');
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
Deno.test("Compositions 2", async () => {
|
|
244
|
+
await ifct2017.loadCompositions();
|
|
245
|
+
const a = ifct2017.compositions('tell me about cow milk.');
|
|
246
|
+
const b = ifct2017.compositions('gai ka doodh details.');
|
|
247
|
+
assertEquals(a[0].code, 'L002');
|
|
248
|
+
assertEquals(b[0].code, 'L002');
|
|
249
|
+
});
|
|
250
|
+
//#endregion
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
//#region COMPOSITION STATS
|
|
256
|
+
Deno.test("Composition stats 1", async () => {
|
|
257
|
+
await ifct2017.loadCompositionStats();
|
|
258
|
+
const a = ifct2017.compositionStats('min')[0];
|
|
259
|
+
assertEquals(a.code, 'XMIN');
|
|
260
|
+
assertEquals(a.name, 'Minimum composition of all foods');
|
|
261
|
+
const b = ifct2017.compositionStats('max')[0];
|
|
262
|
+
assertEquals(b.code, 'XMAX');
|
|
263
|
+
assertEquals(b.name, 'Maximum composition of all foods');
|
|
264
|
+
});
|
|
265
|
+
//#endregion
|
|
266
|
+
|
|
267
|
+
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
//#region CONTENTS
|
|
271
|
+
Deno.test("Contents 1", async () => {
|
|
272
|
+
await ifct2017.loadContents();
|
|
273
|
+
const a = ifct2017.contents('table 2');
|
|
274
|
+
const b = ifct2017.contents('Water soluble vitamins');
|
|
275
|
+
const c = [{sno: '6.2.', title: 'Table 2: Water Soluble Vitamins', pagenos: '31'}];
|
|
276
|
+
assertEquals(a, c);
|
|
277
|
+
assertEquals(b, c);
|
|
278
|
+
});
|
|
279
|
+
|
|
280
|
+
|
|
281
|
+
Deno.test("Contents 2", async () => {
|
|
282
|
+
await ifct2017.loadContents();
|
|
283
|
+
const a = ifct2017.contents('what is page number of table 3?');
|
|
284
|
+
const b = ifct2017.contents('fat soluble vitamin page number');
|
|
285
|
+
const c = [{sno: '6.3.', title: 'Table 3: Fat Soluble Vitamins', pagenos: '61'}];
|
|
286
|
+
assertEquals(a, c);
|
|
287
|
+
assertEquals(b, c);
|
|
288
|
+
});
|
|
289
|
+
//#endregion
|
|
290
|
+
|
|
291
|
+
|
|
292
|
+
|
|
293
|
+
|
|
294
|
+
//#region TEST DESCRIPTIONS
|
|
295
|
+
Deno.test("Descriptions 1", async () => {
|
|
296
|
+
await ifct2017.loadDescriptions();
|
|
297
|
+
const a = ifct2017.descriptions('pineapple');
|
|
298
|
+
const b = ifct2017.descriptions('ananas comosus');
|
|
299
|
+
const c = [{code: 'E053', name: 'Pineapple', scie: 'Ananas comosus', grup: 'Fruits', desc: 'A. Ahnaros; B. Anarasa; G. Anenas; H. Ananas; Kan. Ananas; Kash. Punchitipul; Kh. Soh trun; Kon. Anas; Mal. Kayirha chakka; M. Kihom Ananas; O. Sapuri; P. Ananas; Tam. Annasi pazham; Tel. Anasa pandu; U. Ananas.'}];
|
|
300
|
+
assertEquals(a, c);
|
|
301
|
+
assertEquals(b, c);
|
|
302
|
+
});
|
|
303
|
+
|
|
304
|
+
|
|
305
|
+
Deno.test("Descriptions 2", async () => {
|
|
306
|
+
await ifct2017.loadDescriptions();
|
|
307
|
+
const a = ifct2017.descriptions('tell me about cow milk.');
|
|
308
|
+
const b = ifct2017.descriptions('gai ka doodh details.');
|
|
309
|
+
const c = [{code: 'L002', name: 'Milk, whole, Cow', scie: '', grup: 'Milk and Milk Products', desc: 'A. Garoor gakhir; B. Doodh (garu); G. Gai nu dhudh; H. Gai ka doodh; Kan. Hasuvina halu; Kash. Doodh; Kh. Dud masi; M. San Sanghom; Mar. Doodh (gay); O. Gai dudha; P. Gaan da doodh; S. Gow kshiram; Tam. Pasumpaal; Tel. Aavu paalu.'}];
|
|
310
|
+
assertEquals(a, c);
|
|
311
|
+
assertEquals(b, c);
|
|
312
|
+
});
|
|
313
|
+
//#endregion
|
|
314
|
+
|
|
315
|
+
|
|
316
|
+
|
|
317
|
+
|
|
318
|
+
//#region TEST ENERGIES
|
|
319
|
+
Deno.test("Energies 1", async () => {
|
|
320
|
+
await ifct2017.loadEnergies();
|
|
321
|
+
const a = ifct2017.energies('dietary fibre');
|
|
322
|
+
const b = ifct2017.energies('Soluble fibre');
|
|
323
|
+
const c = [{component: 'Fibre', kj: 8, kcal: 2}];
|
|
324
|
+
assertEquals(a, c);
|
|
325
|
+
assertEquals(b, c);
|
|
326
|
+
});
|
|
327
|
+
|
|
328
|
+
|
|
329
|
+
Deno.test("Energies 2", async () => {
|
|
330
|
+
await ifct2017.loadEnergies();
|
|
331
|
+
const a = ifct2017.energies('what is energy conversion factor of fat?');
|
|
332
|
+
const b = ifct2017.energies('conversion factor of fat');
|
|
333
|
+
const c = [{component: 'Fat', kj: 37, kcal: 9}];
|
|
334
|
+
assertEquals(a, c);
|
|
335
|
+
assertEquals(b, c);
|
|
336
|
+
});
|
|
337
|
+
//#endregion
|
|
338
|
+
|
|
339
|
+
|
|
340
|
+
|
|
341
|
+
|
|
342
|
+
//#region TEST FREQUENCY DISTRIBUTION
|
|
343
|
+
Deno.test("Frequency distribution 1", async () => {
|
|
344
|
+
await ifct2017.loadFrequencyDistribution();
|
|
345
|
+
const a = ifct2017.frequencyDistribution(2);
|
|
346
|
+
const b = ifct2017.frequencyDistribution(5);
|
|
347
|
+
const c = {districts: '1-5', states: 9, selected: 1, sampled: 9};
|
|
348
|
+
assertEquals(a, c);
|
|
349
|
+
assertEquals(b, c);
|
|
350
|
+
});
|
|
351
|
+
|
|
352
|
+
|
|
353
|
+
Deno.test("Frequency distribution 2", async () => {
|
|
354
|
+
await ifct2017.loadFrequencyDistribution();
|
|
355
|
+
const a = ifct2017.frequencyDistribution(32);
|
|
356
|
+
const b = ifct2017.frequencyDistribution(37);
|
|
357
|
+
const c = {districts: '31-40', states: 4, selected: 5, sampled: 20};
|
|
358
|
+
assertEquals(a, c);
|
|
359
|
+
assertEquals(b, c);
|
|
360
|
+
});
|
|
361
|
+
//#endregion
|
|
362
|
+
|
|
363
|
+
|
|
364
|
+
|
|
365
|
+
|
|
366
|
+
//#region TEST GROUPS
|
|
367
|
+
Deno.test("Groups 1", async () => {
|
|
368
|
+
await ifct2017.loadGroups();
|
|
369
|
+
const a = ifct2017.groups('cereals');
|
|
370
|
+
const b = ifct2017.groups('Millet');
|
|
371
|
+
const c = [{
|
|
372
|
+
code: 'A', group: 'Cereals and Millets', entries: 24,
|
|
373
|
+
tags: 'vegetarian eggetarian fishetarian veg'
|
|
374
|
+
}];
|
|
375
|
+
assertEquals(a, c);
|
|
376
|
+
assertEquals(b, c);
|
|
377
|
+
});
|
|
378
|
+
|
|
379
|
+
|
|
380
|
+
Deno.test("Groups 2", async () => {
|
|
381
|
+
await ifct2017.loadGroups();
|
|
382
|
+
const a = ifct2017.groups('what is vegetable?');
|
|
383
|
+
const b = ifct2017.groups('vegetable group code?');
|
|
384
|
+
const c = [
|
|
385
|
+
{
|
|
386
|
+
code: 'D', group: 'Other Vegetables', entries: 78,
|
|
387
|
+
tags: 'vegetarian eggetarian fishetarian veg'
|
|
388
|
+
},
|
|
389
|
+
{
|
|
390
|
+
code: 'C', group: 'Green Leafy Vegetables', entries: 34,
|
|
391
|
+
tags: 'vegetarian eggetarian fishetarian veg'
|
|
392
|
+
}
|
|
393
|
+
];
|
|
394
|
+
assertEquals(a, c);
|
|
395
|
+
assertEquals(b, c);
|
|
396
|
+
});
|
|
397
|
+
//#endregion
|
|
398
|
+
|
|
399
|
+
|
|
400
|
+
|
|
401
|
+
|
|
402
|
+
//#region TEST HIERARCHY
|
|
403
|
+
Deno.test("Hierarchy 1", async () => {
|
|
404
|
+
await ifct2017.loadHierarchy();
|
|
405
|
+
const a = ifct2017.hierarchy('soluble oxalic acid');
|
|
406
|
+
const b = ifct2017.hierarchy('Soluble Oxalic Acid');
|
|
407
|
+
const c = {
|
|
408
|
+
code: 'oxals',
|
|
409
|
+
parents: 'oxalt',
|
|
410
|
+
ancestry: 'oxalt orgac',
|
|
411
|
+
children: '',
|
|
412
|
+
};
|
|
413
|
+
assertEquals(a, c);
|
|
414
|
+
assertEquals(b, c);
|
|
415
|
+
});
|
|
416
|
+
|
|
417
|
+
|
|
418
|
+
Deno.test("Hierarchy 2", async () => {
|
|
419
|
+
await ifct2017.loadHierarchy();
|
|
420
|
+
const a = ifct2017.hierarchy('what is hierarchy of total saturated fat?');
|
|
421
|
+
const b = ifct2017.hierarchy('who are children of total saturated fat?');
|
|
422
|
+
const c = {
|
|
423
|
+
code: 'fasat',
|
|
424
|
+
parents: 'fatce',
|
|
425
|
+
ancestry: 'fatce',
|
|
426
|
+
children: 'f4d0 f6d0 f8d0 f10d0 f11d0 f12d0 f14d0 f15d0 f16d0 f18d0 f20d0 f22d0 f24d0',
|
|
427
|
+
};
|
|
428
|
+
assertEquals(a, c);
|
|
429
|
+
assertEquals(b, c);
|
|
430
|
+
});
|
|
431
|
+
//#endregion
|
|
432
|
+
|
|
433
|
+
|
|
434
|
+
|
|
435
|
+
|
|
436
|
+
//#region TEST INTAKES
|
|
437
|
+
Deno.test("Intakes 1", async () => {
|
|
438
|
+
await ifct2017.loadIntakes();
|
|
439
|
+
const a = ifct2017.intakes('his');
|
|
440
|
+
const b = ifct2017.intakes('Histidine');
|
|
441
|
+
const c = {
|
|
442
|
+
code: 'his', whorda: -0.01, usear: NaN, usrdam: -0.014, usrdaf: NaN,
|
|
443
|
+
euprim: NaN, euprif: NaN, ulus: NaN, uleu: NaN, uljapan: NaN
|
|
444
|
+
};
|
|
445
|
+
assertEquals(a[0], c);
|
|
446
|
+
assertEquals(b[0], c);
|
|
447
|
+
});
|
|
448
|
+
|
|
449
|
+
|
|
450
|
+
Deno.test("Intakes 2", async () => {
|
|
451
|
+
await ifct2017.loadIntakes();
|
|
452
|
+
const a = ifct2017.intakes('intake of total fibre?');
|
|
453
|
+
const b = ifct2017.intakes('what is rda of total fiber?');
|
|
454
|
+
const c = {
|
|
455
|
+
code: 'fibtg', whorda: NaN, usear: NaN, usrdam: 38, usrdaf: 25,
|
|
456
|
+
euprim: NaN, euprif: NaN, ulus: NaN, uleu: NaN, uljapan: NaN
|
|
457
|
+
};
|
|
458
|
+
assertEquals(a[0], c);
|
|
459
|
+
assertEquals(b[0], c);
|
|
460
|
+
});
|
|
461
|
+
//#endregion
|
|
462
|
+
|
|
463
|
+
|
|
464
|
+
|
|
465
|
+
|
|
466
|
+
//#region TEST JONES FACTORS
|
|
467
|
+
Deno.test("Jones factors 1", async () => {
|
|
468
|
+
await ifct2017.loadJonesFactors();
|
|
469
|
+
const a = ifct2017.jonesFactors('maida');
|
|
470
|
+
const b = ifct2017.jonesFactors('Refined wheat');
|
|
471
|
+
const c = [{food: 'Refined wheat flour (Maida)', factor: 5.7}];
|
|
472
|
+
assertEquals(a, c);
|
|
473
|
+
assertEquals(b, c);
|
|
474
|
+
});
|
|
475
|
+
|
|
476
|
+
|
|
477
|
+
Deno.test("Jones factors 2", async () => {
|
|
478
|
+
await ifct2017.loadJonesFactors();
|
|
479
|
+
const a = ifct2017.jonesFactors('what is jones factor of barley?');
|
|
480
|
+
const b = ifct2017.jonesFactors('jones factor of oats');
|
|
481
|
+
const c = [{food: 'Barley and its flour;Rye and its flour;Oats', factor: 5.83}];
|
|
482
|
+
assertEquals(a, c);
|
|
483
|
+
assertEquals(b, c);
|
|
484
|
+
});
|
|
485
|
+
//#endregion
|
|
486
|
+
|
|
487
|
+
|
|
488
|
+
|
|
489
|
+
|
|
490
|
+
//#region TEST LANGUAGES
|
|
491
|
+
Deno.test("Languages 1", async () => {
|
|
492
|
+
await ifct2017.loadLanguages();
|
|
493
|
+
const a = ifct2017.languages('mal.');
|
|
494
|
+
const b = ifct2017.languages('Mal');
|
|
495
|
+
const c = {abbr: 'Mal.', lang: 'Malayalam'};
|
|
496
|
+
assertEquals(a, c);
|
|
497
|
+
assertEquals(b, c);
|
|
498
|
+
});
|
|
499
|
+
|
|
500
|
+
|
|
501
|
+
Deno.test("Languages 2", async () => {
|
|
502
|
+
await ifct2017.loadLanguages();
|
|
503
|
+
const a = ifct2017.languages('what is s.?');
|
|
504
|
+
const b = ifct2017.languages('S. stands for?');
|
|
505
|
+
const c = {abbr: 'S.', lang: 'Sanskrit'};
|
|
506
|
+
assertEquals(a, c);
|
|
507
|
+
assertEquals(b, c);
|
|
508
|
+
});
|
|
509
|
+
//#endregion
|
|
510
|
+
|
|
511
|
+
|
|
512
|
+
|
|
513
|
+
//#region TEST METHODS
|
|
514
|
+
Deno.test("Methods 1", async () => {
|
|
515
|
+
await ifct2017.loadMethods();
|
|
516
|
+
const a = ifct2017.methods('soluble oxalic acid');
|
|
517
|
+
const b = ifct2017.methods('Insoluble Oxalic Acid');
|
|
518
|
+
const c = {
|
|
519
|
+
analyte: 'Oxalic acid (Total), Soluble oxalic acid, Insoluble oxalic acid',
|
|
520
|
+
method: 'Fast- HPLC', reference: 'Moreau & Savage (2009)'
|
|
521
|
+
};
|
|
522
|
+
assertEquals(a, c);
|
|
523
|
+
assertEquals(b, c);
|
|
524
|
+
});
|
|
525
|
+
|
|
526
|
+
|
|
527
|
+
Deno.test("Methods 2", async () => {
|
|
528
|
+
await ifct2017.loadMethods();
|
|
529
|
+
const a = ifct2017.methods('what is analytical method of saponin?');
|
|
530
|
+
const b = ifct2017.methods('how is total saponin measured?');
|
|
531
|
+
const c = {
|
|
532
|
+
analyte: 'Total Saponin',
|
|
533
|
+
method: 'Colorimetry', reference: 'Dini et al. (2009)'
|
|
534
|
+
};
|
|
535
|
+
assertEquals(a, c);
|
|
536
|
+
assertEquals(b, c);
|
|
537
|
+
});
|
|
538
|
+
//#endregion
|
|
539
|
+
|
|
540
|
+
|
|
541
|
+
|
|
542
|
+
|
|
543
|
+
//#region TEST GROUPS
|
|
544
|
+
Deno.test("Groups 1", async () => {
|
|
545
|
+
await ifct2017.loadGroups();
|
|
546
|
+
const a = ifct2017.groups('cereals');
|
|
547
|
+
const b = ifct2017.groups('Millet');
|
|
548
|
+
const c = [{
|
|
549
|
+
code: 'A', group: 'Cereals and Millets', entries: 24,
|
|
550
|
+
tags: 'vegetarian eggetarian fishetarian veg'
|
|
551
|
+
}];
|
|
552
|
+
assertEquals(a, c);
|
|
553
|
+
assertEquals(b, c);
|
|
554
|
+
});
|
|
555
|
+
|
|
556
|
+
|
|
557
|
+
Deno.test("Groups 2", async () => {
|
|
558
|
+
await ifct2017.loadGroups();
|
|
559
|
+
const a = ifct2017.groups('what is vegetable?');
|
|
560
|
+
const b = ifct2017.groups('vegetable group code?');
|
|
561
|
+
const c = [
|
|
562
|
+
{
|
|
563
|
+
code: 'D', group: 'Other Vegetables', entries: 78,
|
|
564
|
+
tags: 'vegetarian eggetarian fishetarian veg'
|
|
565
|
+
},
|
|
566
|
+
{
|
|
567
|
+
code: 'C', group: 'Green Leafy Vegetables', entries: 34,
|
|
568
|
+
tags: 'vegetarian eggetarian fishetarian veg'
|
|
569
|
+
}
|
|
570
|
+
];
|
|
571
|
+
assertEquals(a, c);
|
|
572
|
+
assertEquals(b, c);
|
|
573
|
+
});
|
|
574
|
+
//#endregion
|
|
575
|
+
|
|
576
|
+
|
|
577
|
+
|
|
578
|
+
|
|
579
|
+
//#region TEST REGIONS
|
|
580
|
+
Deno.test("Regions 1", async () => {
|
|
581
|
+
await ifct2017.loadRegions();
|
|
582
|
+
const a = ifct2017.regions('central');
|
|
583
|
+
const b = ifct2017.regions('Uttaranchal');
|
|
584
|
+
const c = [{
|
|
585
|
+
region: 'Central',
|
|
586
|
+
states: 'Chhattisgarh;Madhya Pradesh;Uttar Pradesh;Uttaranchal'}];
|
|
587
|
+
assertEquals(a, c);
|
|
588
|
+
assertEquals(b, c);
|
|
589
|
+
});
|
|
590
|
+
|
|
591
|
+
|
|
592
|
+
Deno.test("Regions 2", async () => {
|
|
593
|
+
await ifct2017.loadRegions();
|
|
594
|
+
const a = ifct2017.regions('which region andhra pradesh belongs to?');
|
|
595
|
+
const b = ifct2017.regions('details of south region');
|
|
596
|
+
const c = [{
|
|
597
|
+
region: 'South',
|
|
598
|
+
states: 'Andaman & Nicobar Islands;Andhra Pradesh;Karnataka;Kerala;Lakshadweep;Pondicherry;Telangana;Tamil Nadu'}];
|
|
599
|
+
assertEquals(a, c);
|
|
600
|
+
assertEquals(b, c);
|
|
601
|
+
});
|
|
602
|
+
//#endregion
|
|
603
|
+
|
|
604
|
+
|
|
605
|
+
|
|
606
|
+
|
|
607
|
+
//#region TEST REPRESENTATIONS
|
|
608
|
+
Deno.test("Representations 1", async () => {
|
|
609
|
+
await ifct2017.loadRepresentations();
|
|
610
|
+
const a = ifct2017.representations('his');
|
|
611
|
+
const b = ifct2017.representations('Histidine');
|
|
612
|
+
const c = {code: 'his', type: 'mass', factor: 1e+3, unit: 'mg'};
|
|
613
|
+
assertEquals(a, c);
|
|
614
|
+
assertEquals(b, c);
|
|
615
|
+
});
|
|
616
|
+
|
|
617
|
+
|
|
618
|
+
Deno.test("Representations 2", async () => {
|
|
619
|
+
await ifct2017.loadRepresentations();
|
|
620
|
+
const a = ifct2017.representations('representation of vitamin d?');
|
|
621
|
+
const b = ifct2017.representations('what is unit of ergocalciferol?');
|
|
622
|
+
const c = {code: 'vitd', type: 'mass', factor: 1e+6, unit: 'ug'};
|
|
623
|
+
const d = {code: 'ergcal', type: 'mass', factor: 1e+6, unit: 'ug'};
|
|
624
|
+
assertEquals(a, c);
|
|
625
|
+
assertEquals(b, d);
|
|
626
|
+
});
|
|
627
|
+
//#endregion
|
|
628
|
+
|
|
629
|
+
|
|
630
|
+
|
|
631
|
+
|
|
632
|
+
//#region TEST SAMPLING UNITS
|
|
633
|
+
Deno.test("Sampling units 1", async () => {
|
|
634
|
+
await ifct2017.loadSamplingUnits();
|
|
635
|
+
const a = ifct2017.samplingUnits('andaman');
|
|
636
|
+
const b = ifct2017.samplingUnits('Nicobar');
|
|
637
|
+
const c = [{sno: 'A', state: 'Andaman & Nicobar', districts: 3, selected: 1}];
|
|
638
|
+
assertEquals(a, c);
|
|
639
|
+
assertEquals(b, c);
|
|
640
|
+
});
|
|
641
|
+
|
|
642
|
+
|
|
643
|
+
Deno.test("Sampling units 2", async () => {
|
|
644
|
+
await ifct2017.loadSamplingUnits();
|
|
645
|
+
const a = ifct2017.samplingUnits('sampling units in orissa?');
|
|
646
|
+
const b = ifct2017.samplingUnits('orissa\'s sampling units');
|
|
647
|
+
const c = [{sno: '20', state: 'Orissa', districts: 30, selected: 4}];
|
|
648
|
+
assertEquals(a, c);
|
|
649
|
+
assertEquals(b, c);
|
|
650
|
+
});
|
|
651
|
+
//#endregion
|
|
652
|
+
|
|
653
|
+
|
|
654
|
+
|
|
655
|
+
|
|
656
|
+
//#region TEST YIELD FACTORS
|
|
657
|
+
Deno.test("Yield factors 1", async () => {
|
|
658
|
+
await ifct2017.loadYieldFactors();
|
|
659
|
+
const a = ifct2017.yieldFactors('mango');
|
|
660
|
+
const b = ifct2017.yieldFactors('Mangifera indica');
|
|
661
|
+
const c = [{
|
|
662
|
+
code: 'D057',
|
|
663
|
+
name: 'Mango, green, raw',
|
|
664
|
+
scie: 'Mangifera indica',
|
|
665
|
+
lang: 'A. Keasa aam; B. Aam (kancha); G. Ambo; H. Katcha Aam; Kan. Mavinakayi; Kash. Kach Aamb; Kh. Soh pieng im; Mal. Manga; M. Heinou Ashangba; Mar. Amba; O. Ambu (kacha); P. Kaccha aam; Tam. Mangai; Tel. Mamidikaya; U. Kaccha aam.',
|
|
666
|
+
grup: 'Other Vegetables',
|
|
667
|
+
regn: 6,
|
|
668
|
+
tags: 'vegetarian eggetarian fishetarian veg',
|
|
669
|
+
yield: 0.6833333333,
|
|
670
|
+
preparation: 'Washing, Peeling, Seed removal',
|
|
671
|
+
}];
|
|
672
|
+
assertEquals(a[0], c[0]);
|
|
673
|
+
assertEquals(b[0], c[0]);
|
|
674
|
+
});
|
|
675
|
+
|
|
676
|
+
|
|
677
|
+
Deno.test("Yield factors 2", async () => {
|
|
678
|
+
await ifct2017.loadYieldFactors();
|
|
679
|
+
const a = ifct2017.yieldFactors('yield factor of cow milk?');
|
|
680
|
+
const b = ifct2017.yieldFactors('gai ka doodh');
|
|
681
|
+
const c = [{
|
|
682
|
+
code: 'L002',
|
|
683
|
+
name: 'Milk, whole, Cow',
|
|
684
|
+
scie: '',
|
|
685
|
+
lang: 'A. Garoor gakhir; B. Doodh (garu); G. Gai nu dhudh; H. Gai ka doodh; Kan. Hasuvina halu; Kash. Doodh; Kh. Dud masi; M. San Sanghom; Mar. Doodh (gay); O. Gai dudha; P. Gaan da doodh; S. Gow kshiram; Tam. Pasumpaal; Tel. Aavu paalu.',
|
|
686
|
+
grup: 'Milk and Milk Products',
|
|
687
|
+
regn: 6,
|
|
688
|
+
tags: 'vegetarian eggetarian fishetarian veg',
|
|
689
|
+
yield: 1,
|
|
690
|
+
preparation: 'None',
|
|
691
|
+
}];
|
|
692
|
+
assertEquals(a[0], c[0]);
|
|
693
|
+
assertEquals(b[0], c[0]);
|
|
694
|
+
});
|
|
695
|
+
//#endregion
|
|
696
|
+
|
|
697
|
+
|
|
698
|
+
|
|
699
|
+
|
|
700
|
+
//#region TEST COLUMN DESCRIPTIONS
|
|
701
|
+
Deno.test("Column descriptions 1", async () => {
|
|
702
|
+
await ifct2017.loadColumnDescriptions();
|
|
703
|
+
const a = ifct2017.columnDescriptions('vitamin c');
|
|
704
|
+
const b = ifct2017.columnDescriptions('c-vitamin');
|
|
705
|
+
assertEquals(a[0].code, 'vitc');
|
|
706
|
+
assertEquals(b[0].code, 'vitc');
|
|
707
|
+
});
|
|
708
|
+
|
|
709
|
+
|
|
710
|
+
Deno.test("Column descriptions 2", async () => {
|
|
711
|
+
await ifct2017.loadColumnDescriptions();
|
|
712
|
+
const a = ifct2017.columnDescriptions('what is butyric acid?');
|
|
713
|
+
const b = ifct2017.columnDescriptions('c4:0 stands for?');
|
|
714
|
+
assertEquals(a[0].code, 'f4d0');
|
|
715
|
+
assertEquals(b[0].code, 'f4d0');
|
|
716
|
+
});
|
|
717
|
+
//#endregion
|