@ccmaymay/concrete 4.15.0 → 4.15.1
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/ActiveLearnerClientService.js +249 -249
- package/ActiveLearnerServerService.js +642 -642
- package/AnnotateCommunicationService.js +696 -696
- package/AnnotateWithContextService.js +298 -298
- package/FeedbackService.js +750 -750
- package/FetchCommunicationService.js +709 -709
- package/README.md +125 -0
- package/ResultsServerService.js +2138 -2138
- package/SearchProxyService.js +962 -962
- package/SearchService.js +685 -685
- package/Service.js +373 -373
- package/StoreCommunicationService.js +255 -255
- package/SummarizationService.js +479 -479
- package/access_types.js +168 -168
- package/annotate_types.js +26 -26
- package/audio_types.js +110 -110
- package/cluster_types.js +398 -398
- package/communication_fu.js +432 -432
- package/communication_types.js +845 -845
- package/concrete.js +64 -64
- package/context_types.js +65 -65
- package/email_types.js +477 -477
- package/entities_types.js +658 -658
- package/ex_types.js +82 -82
- package/language_types.js +123 -123
- package/learn_types.js +207 -207
- package/linking_types.js +286 -286
- package/metadata_types.js +926 -926
- package/nitf_types.js +1005 -1005
- package/package.json +26 -5
- package/results_types.js +18 -18
- package/search_types.js +661 -661
- package/services_types.js +384 -384
- package/situations_types.js +1268 -1268
- package/spans_types.js +151 -151
- package/structure_types.js +2311 -2311
- package/summarization_types.js +433 -433
- package/tokenization_fu.js +33 -33
- package/tokentagging_fu.js +241 -241
- package/twitter_types.js +1553 -1553
- package/util.js +117 -117
- package/uuid_types.js +67 -67
package/SummarizationService.js
CHANGED
@@ -1,479 +1,479 @@
|
|
1
|
-
//
|
2
|
-
// Autogenerated by Thrift Compiler (0.15.0)
|
3
|
-
//
|
4
|
-
// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
|
5
|
-
//
|
6
|
-
"use strict";
|
7
|
-
|
8
|
-
const thrift = require('thrift');
|
9
|
-
const Thrift = thrift.Thrift;
|
10
|
-
const Int64 = require('node-int64');
|
11
|
-
|
12
|
-
const communication_ttypes = require('./communication_types');
|
13
|
-
const services_ttypes = require('./services_types');
|
14
|
-
const structure_ttypes = require('./structure_types');
|
15
|
-
const uuid_ttypes = require('./uuid_types');
|
16
|
-
|
17
|
-
|
18
|
-
const Service = require('./Service');
|
19
|
-
const ServiceClient = Service.Client;
|
20
|
-
const ServiceProcessor = Service.Processor;
|
21
|
-
const ttypes = require('./summarization_types');
|
22
|
-
//HELPER FUNCTIONS AND STRUCTURES
|
23
|
-
|
24
|
-
const SummarizationService_summarize_args = class {
|
25
|
-
constructor(args) {
|
26
|
-
this.query = null;
|
27
|
-
if (args) {
|
28
|
-
if (args.query !== undefined && args.query !== null) {
|
29
|
-
this.query = new ttypes.SummarizationRequest(args.query);
|
30
|
-
}
|
31
|
-
}
|
32
|
-
}
|
33
|
-
|
34
|
-
read (input) {
|
35
|
-
input.readStructBegin();
|
36
|
-
while (true) {
|
37
|
-
const ret = input.readFieldBegin();
|
38
|
-
const ftype = ret.ftype;
|
39
|
-
const fid = ret.fid;
|
40
|
-
if (ftype == Thrift.Type.STOP) {
|
41
|
-
break;
|
42
|
-
}
|
43
|
-
switch (fid) {
|
44
|
-
case 1:
|
45
|
-
if (ftype == Thrift.Type.STRUCT) {
|
46
|
-
this.query = new ttypes.SummarizationRequest();
|
47
|
-
this.query.read(input);
|
48
|
-
} else {
|
49
|
-
input.skip(ftype);
|
50
|
-
}
|
51
|
-
break;
|
52
|
-
case 0:
|
53
|
-
input.skip(ftype);
|
54
|
-
break;
|
55
|
-
default:
|
56
|
-
input.skip(ftype);
|
57
|
-
}
|
58
|
-
input.readFieldEnd();
|
59
|
-
}
|
60
|
-
input.readStructEnd();
|
61
|
-
return;
|
62
|
-
}
|
63
|
-
|
64
|
-
write (output) {
|
65
|
-
output.writeStructBegin('SummarizationService_summarize_args');
|
66
|
-
if (this.query !== null && this.query !== undefined) {
|
67
|
-
output.writeFieldBegin('query', Thrift.Type.STRUCT, 1);
|
68
|
-
this.query.write(output);
|
69
|
-
output.writeFieldEnd();
|
70
|
-
}
|
71
|
-
output.writeFieldStop();
|
72
|
-
output.writeStructEnd();
|
73
|
-
return;
|
74
|
-
}
|
75
|
-
|
76
|
-
};
|
77
|
-
const SummarizationService_summarize_result = class {
|
78
|
-
constructor(args) {
|
79
|
-
this.success = null;
|
80
|
-
this.ex = null;
|
81
|
-
if (args instanceof services_ttypes.ServicesException) {
|
82
|
-
this.ex = args;
|
83
|
-
return;
|
84
|
-
}
|
85
|
-
if (args) {
|
86
|
-
if (args.success !== undefined && args.success !== null) {
|
87
|
-
this.success = new ttypes.Summary(args.success);
|
88
|
-
}
|
89
|
-
if (args.ex !== undefined && args.ex !== null) {
|
90
|
-
this.ex = args.ex;
|
91
|
-
}
|
92
|
-
}
|
93
|
-
}
|
94
|
-
|
95
|
-
read (input) {
|
96
|
-
input.readStructBegin();
|
97
|
-
while (true) {
|
98
|
-
const ret = input.readFieldBegin();
|
99
|
-
const ftype = ret.ftype;
|
100
|
-
const fid = ret.fid;
|
101
|
-
if (ftype == Thrift.Type.STOP) {
|
102
|
-
break;
|
103
|
-
}
|
104
|
-
switch (fid) {
|
105
|
-
case 0:
|
106
|
-
if (ftype == Thrift.Type.STRUCT) {
|
107
|
-
this.success = new ttypes.Summary();
|
108
|
-
this.success.read(input);
|
109
|
-
} else {
|
110
|
-
input.skip(ftype);
|
111
|
-
}
|
112
|
-
break;
|
113
|
-
case 1:
|
114
|
-
if (ftype == Thrift.Type.STRUCT) {
|
115
|
-
this.ex = new services_ttypes.ServicesException();
|
116
|
-
this.ex.read(input);
|
117
|
-
} else {
|
118
|
-
input.skip(ftype);
|
119
|
-
}
|
120
|
-
break;
|
121
|
-
default:
|
122
|
-
input.skip(ftype);
|
123
|
-
}
|
124
|
-
input.readFieldEnd();
|
125
|
-
}
|
126
|
-
input.readStructEnd();
|
127
|
-
return;
|
128
|
-
}
|
129
|
-
|
130
|
-
write (output) {
|
131
|
-
output.writeStructBegin('SummarizationService_summarize_result');
|
132
|
-
if (this.success !== null && this.success !== undefined) {
|
133
|
-
output.writeFieldBegin('success', Thrift.Type.STRUCT, 0);
|
134
|
-
this.success.write(output);
|
135
|
-
output.writeFieldEnd();
|
136
|
-
}
|
137
|
-
if (this.ex !== null && this.ex !== undefined) {
|
138
|
-
output.writeFieldBegin('ex', Thrift.Type.STRUCT, 1);
|
139
|
-
this.ex.write(output);
|
140
|
-
output.writeFieldEnd();
|
141
|
-
}
|
142
|
-
output.writeFieldStop();
|
143
|
-
output.writeStructEnd();
|
144
|
-
return;
|
145
|
-
}
|
146
|
-
|
147
|
-
};
|
148
|
-
const SummarizationService_getCapabilities_args = class {
|
149
|
-
constructor(args) {
|
150
|
-
}
|
151
|
-
|
152
|
-
read (input) {
|
153
|
-
input.readStructBegin();
|
154
|
-
while (true) {
|
155
|
-
const ret = input.readFieldBegin();
|
156
|
-
const ftype = ret.ftype;
|
157
|
-
if (ftype == Thrift.Type.STOP) {
|
158
|
-
break;
|
159
|
-
}
|
160
|
-
input.skip(ftype);
|
161
|
-
input.readFieldEnd();
|
162
|
-
}
|
163
|
-
input.readStructEnd();
|
164
|
-
return;
|
165
|
-
}
|
166
|
-
|
167
|
-
write (output) {
|
168
|
-
output.writeStructBegin('SummarizationService_getCapabilities_args');
|
169
|
-
output.writeFieldStop();
|
170
|
-
output.writeStructEnd();
|
171
|
-
return;
|
172
|
-
}
|
173
|
-
|
174
|
-
};
|
175
|
-
const SummarizationService_getCapabilities_result = class {
|
176
|
-
constructor(args) {
|
177
|
-
this.success = null;
|
178
|
-
this.ex = null;
|
179
|
-
if (args instanceof services_ttypes.ServicesException) {
|
180
|
-
this.ex = args;
|
181
|
-
return;
|
182
|
-
}
|
183
|
-
if (args) {
|
184
|
-
if (args.success !== undefined && args.success !== null) {
|
185
|
-
this.success = Thrift.copyList(args.success, [ttypes.SummarizationCapability]);
|
186
|
-
}
|
187
|
-
if (args.ex !== undefined && args.ex !== null) {
|
188
|
-
this.ex = args.ex;
|
189
|
-
}
|
190
|
-
}
|
191
|
-
}
|
192
|
-
|
193
|
-
read (input) {
|
194
|
-
input.readStructBegin();
|
195
|
-
while (true) {
|
196
|
-
const ret = input.readFieldBegin();
|
197
|
-
const ftype = ret.ftype;
|
198
|
-
const fid = ret.fid;
|
199
|
-
if (ftype == Thrift.Type.STOP) {
|
200
|
-
break;
|
201
|
-
}
|
202
|
-
switch (fid) {
|
203
|
-
case 0:
|
204
|
-
if (ftype == Thrift.Type.LIST) {
|
205
|
-
this.success = [];
|
206
|
-
const _rtmp316 = input.readListBegin();
|
207
|
-
const _size15 = _rtmp316.size || 0;
|
208
|
-
for (let _i17 = 0; _i17 < _size15; ++_i17) {
|
209
|
-
let elem18 = null;
|
210
|
-
elem18 = new ttypes.SummarizationCapability();
|
211
|
-
elem18.read(input);
|
212
|
-
this.success.push(elem18);
|
213
|
-
}
|
214
|
-
input.readListEnd();
|
215
|
-
} else {
|
216
|
-
input.skip(ftype);
|
217
|
-
}
|
218
|
-
break;
|
219
|
-
case 1:
|
220
|
-
if (ftype == Thrift.Type.STRUCT) {
|
221
|
-
this.ex = new services_ttypes.ServicesException();
|
222
|
-
this.ex.read(input);
|
223
|
-
} else {
|
224
|
-
input.skip(ftype);
|
225
|
-
}
|
226
|
-
break;
|
227
|
-
default:
|
228
|
-
input.skip(ftype);
|
229
|
-
}
|
230
|
-
input.readFieldEnd();
|
231
|
-
}
|
232
|
-
input.readStructEnd();
|
233
|
-
return;
|
234
|
-
}
|
235
|
-
|
236
|
-
write (output) {
|
237
|
-
output.writeStructBegin('SummarizationService_getCapabilities_result');
|
238
|
-
if (this.success !== null && this.success !== undefined) {
|
239
|
-
output.writeFieldBegin('success', Thrift.Type.LIST, 0);
|
240
|
-
output.writeListBegin(Thrift.Type.STRUCT, this.success.length);
|
241
|
-
for (let iter19 in this.success) {
|
242
|
-
if (this.success.hasOwnProperty(iter19)) {
|
243
|
-
iter19 = this.success[iter19];
|
244
|
-
iter19.write(output);
|
245
|
-
}
|
246
|
-
}
|
247
|
-
output.writeListEnd();
|
248
|
-
output.writeFieldEnd();
|
249
|
-
}
|
250
|
-
if (this.ex !== null && this.ex !== undefined) {
|
251
|
-
output.writeFieldBegin('ex', Thrift.Type.STRUCT, 1);
|
252
|
-
this.ex.write(output);
|
253
|
-
output.writeFieldEnd();
|
254
|
-
}
|
255
|
-
output.writeFieldStop();
|
256
|
-
output.writeStructEnd();
|
257
|
-
return;
|
258
|
-
}
|
259
|
-
|
260
|
-
};
|
261
|
-
const SummarizationServiceClient = exports.Client = class SummarizationServiceClient extends ServiceClient {
|
262
|
-
constructor(output, pClass) {
|
263
|
-
super(output, pClass);
|
264
|
-
this.output = output;
|
265
|
-
this.pClass = pClass;
|
266
|
-
this._seqid = 0;
|
267
|
-
this._reqs = {};
|
268
|
-
}
|
269
|
-
seqid () { return this._seqid; }
|
270
|
-
new_seqid () { return this._seqid += 1; }
|
271
|
-
|
272
|
-
summarize (query) {
|
273
|
-
this._seqid = this.new_seqid();
|
274
|
-
const self = this;
|
275
|
-
return new Promise((resolve, reject) => {
|
276
|
-
self._reqs[self.seqid()] = (error, result) => {
|
277
|
-
return error ? reject(error) : resolve(result);
|
278
|
-
};
|
279
|
-
self.send_summarize(query);
|
280
|
-
});
|
281
|
-
}
|
282
|
-
|
283
|
-
send_summarize (query) {
|
284
|
-
const output = new this.pClass(this.output);
|
285
|
-
const params = {
|
286
|
-
query: query
|
287
|
-
};
|
288
|
-
const args = new SummarizationService_summarize_args(params);
|
289
|
-
try {
|
290
|
-
output.writeMessageBegin('summarize', Thrift.MessageType.CALL, this.seqid());
|
291
|
-
args.write(output);
|
292
|
-
output.writeMessageEnd();
|
293
|
-
return this.output.flush();
|
294
|
-
}
|
295
|
-
catch (e) {
|
296
|
-
delete this._reqs[this.seqid()];
|
297
|
-
if (typeof output.reset === 'function') {
|
298
|
-
output.reset();
|
299
|
-
}
|
300
|
-
throw e;
|
301
|
-
}
|
302
|
-
}
|
303
|
-
|
304
|
-
recv_summarize (input, mtype, rseqid) {
|
305
|
-
const callback = this._reqs[rseqid] || function() {};
|
306
|
-
delete this._reqs[rseqid];
|
307
|
-
if (mtype == Thrift.MessageType.EXCEPTION) {
|
308
|
-
const x = new Thrift.TApplicationException();
|
309
|
-
x.read(input);
|
310
|
-
input.readMessageEnd();
|
311
|
-
return callback(x);
|
312
|
-
}
|
313
|
-
const result = new SummarizationService_summarize_result();
|
314
|
-
result.read(input);
|
315
|
-
input.readMessageEnd();
|
316
|
-
|
317
|
-
if (null !== result.ex) {
|
318
|
-
return callback(result.ex);
|
319
|
-
}
|
320
|
-
if (null !== result.success) {
|
321
|
-
return callback(null, result.success);
|
322
|
-
}
|
323
|
-
return callback('summarize failed: unknown result');
|
324
|
-
}
|
325
|
-
|
326
|
-
getCapabilities () {
|
327
|
-
this._seqid = this.new_seqid();
|
328
|
-
const self = this;
|
329
|
-
return new Promise((resolve, reject) => {
|
330
|
-
self._reqs[self.seqid()] = (error, result) => {
|
331
|
-
return error ? reject(error) : resolve(result);
|
332
|
-
};
|
333
|
-
self.send_getCapabilities();
|
334
|
-
});
|
335
|
-
}
|
336
|
-
|
337
|
-
send_getCapabilities () {
|
338
|
-
const output = new this.pClass(this.output);
|
339
|
-
const args = new SummarizationService_getCapabilities_args();
|
340
|
-
try {
|
341
|
-
output.writeMessageBegin('getCapabilities', Thrift.MessageType.CALL, this.seqid());
|
342
|
-
args.write(output);
|
343
|
-
output.writeMessageEnd();
|
344
|
-
return this.output.flush();
|
345
|
-
}
|
346
|
-
catch (e) {
|
347
|
-
delete this._reqs[this.seqid()];
|
348
|
-
if (typeof output.reset === 'function') {
|
349
|
-
output.reset();
|
350
|
-
}
|
351
|
-
throw e;
|
352
|
-
}
|
353
|
-
}
|
354
|
-
|
355
|
-
recv_getCapabilities (input, mtype, rseqid) {
|
356
|
-
const callback = this._reqs[rseqid] || function() {};
|
357
|
-
delete this._reqs[rseqid];
|
358
|
-
if (mtype == Thrift.MessageType.EXCEPTION) {
|
359
|
-
const x = new Thrift.TApplicationException();
|
360
|
-
x.read(input);
|
361
|
-
input.readMessageEnd();
|
362
|
-
return callback(x);
|
363
|
-
}
|
364
|
-
const result = new SummarizationService_getCapabilities_result();
|
365
|
-
result.read(input);
|
366
|
-
input.readMessageEnd();
|
367
|
-
|
368
|
-
if (null !== result.ex) {
|
369
|
-
return callback(result.ex);
|
370
|
-
}
|
371
|
-
if (null !== result.success) {
|
372
|
-
return callback(null, result.success);
|
373
|
-
}
|
374
|
-
return callback('getCapabilities failed: unknown result');
|
375
|
-
}
|
376
|
-
};
|
377
|
-
const SummarizationServiceProcessor = exports.Processor = class SummarizationServiceProcessor extends ServiceProcessor {
|
378
|
-
constructor(handler) {
|
379
|
-
super(handler);
|
380
|
-
this._handler = handler;
|
381
|
-
}
|
382
|
-
process (input, output) {
|
383
|
-
const r = input.readMessageBegin();
|
384
|
-
if (this['process_' + r.fname]) {
|
385
|
-
return this['process_' + r.fname].call(this, r.rseqid, input, output);
|
386
|
-
} else {
|
387
|
-
input.skip(Thrift.Type.STRUCT);
|
388
|
-
input.readMessageEnd();
|
389
|
-
const x = new Thrift.TApplicationException(Thrift.TApplicationExceptionType.UNKNOWN_METHOD, 'Unknown function ' + r.fname);
|
390
|
-
output.writeMessageBegin(r.fname, Thrift.MessageType.EXCEPTION, r.rseqid);
|
391
|
-
x.write(output);
|
392
|
-
output.writeMessageEnd();
|
393
|
-
output.flush();
|
394
|
-
}
|
395
|
-
}
|
396
|
-
process_summarize (seqid, input, output) {
|
397
|
-
const args = new SummarizationService_summarize_args();
|
398
|
-
args.read(input);
|
399
|
-
input.readMessageEnd();
|
400
|
-
if (this._handler.summarize.length === 1) {
|
401
|
-
Promise.resolve(this._handler.summarize.bind(this._handler)(
|
402
|
-
args.query
|
403
|
-
)).then(result => {
|
404
|
-
const result_obj = new SummarizationService_summarize_result({success: result});
|
405
|
-
output.writeMessageBegin("summarize", Thrift.MessageType.REPLY, seqid);
|
406
|
-
result_obj.write(output);
|
407
|
-
output.writeMessageEnd();
|
408
|
-
output.flush();
|
409
|
-
}).catch(err => {
|
410
|
-
let result;
|
411
|
-
if (err instanceof services_ttypes.ServicesException) {
|
412
|
-
result = new SummarizationService_summarize_result(err);
|
413
|
-
output.writeMessageBegin("summarize", Thrift.MessageType.REPLY, seqid);
|
414
|
-
} else {
|
415
|
-
result = new Thrift.TApplicationException(Thrift.TApplicationExceptionType.UNKNOWN, err.message);
|
416
|
-
output.writeMessageBegin("summarize", Thrift.MessageType.EXCEPTION, seqid);
|
417
|
-
}
|
418
|
-
result.write(output);
|
419
|
-
output.writeMessageEnd();
|
420
|
-
output.flush();
|
421
|
-
});
|
422
|
-
} else {
|
423
|
-
this._handler.summarize(args.query, (err, result) => {
|
424
|
-
let result_obj;
|
425
|
-
if ((err === null || typeof err === 'undefined') || err instanceof services_ttypes.ServicesException) {
|
426
|
-
result_obj = new SummarizationService_summarize_result((err !== null || typeof err === 'undefined') ? err : {success: result});
|
427
|
-
output.writeMessageBegin("summarize", Thrift.MessageType.REPLY, seqid);
|
428
|
-
} else {
|
429
|
-
result_obj = new Thrift.TApplicationException(Thrift.TApplicationExceptionType.UNKNOWN, err.message);
|
430
|
-
output.writeMessageBegin("summarize", Thrift.MessageType.EXCEPTION, seqid);
|
431
|
-
}
|
432
|
-
result_obj.write(output);
|
433
|
-
output.writeMessageEnd();
|
434
|
-
output.flush();
|
435
|
-
});
|
436
|
-
}
|
437
|
-
}
|
438
|
-
process_getCapabilities (seqid, input, output) {
|
439
|
-
const args = new SummarizationService_getCapabilities_args();
|
440
|
-
args.read(input);
|
441
|
-
input.readMessageEnd();
|
442
|
-
if (this._handler.getCapabilities.length === 0) {
|
443
|
-
Promise.resolve(this._handler.getCapabilities.bind(this._handler)(
|
444
|
-
)).then(result => {
|
445
|
-
const result_obj = new SummarizationService_getCapabilities_result({success: result});
|
446
|
-
output.writeMessageBegin("getCapabilities", Thrift.MessageType.REPLY, seqid);
|
447
|
-
result_obj.write(output);
|
448
|
-
output.writeMessageEnd();
|
449
|
-
output.flush();
|
450
|
-
}).catch(err => {
|
451
|
-
let result;
|
452
|
-
if (err instanceof services_ttypes.ServicesException) {
|
453
|
-
result = new SummarizationService_getCapabilities_result(err);
|
454
|
-
output.writeMessageBegin("getCapabilities", Thrift.MessageType.REPLY, seqid);
|
455
|
-
} else {
|
456
|
-
result = new Thrift.TApplicationException(Thrift.TApplicationExceptionType.UNKNOWN, err.message);
|
457
|
-
output.writeMessageBegin("getCapabilities", Thrift.MessageType.EXCEPTION, seqid);
|
458
|
-
}
|
459
|
-
result.write(output);
|
460
|
-
output.writeMessageEnd();
|
461
|
-
output.flush();
|
462
|
-
});
|
463
|
-
} else {
|
464
|
-
this._handler.getCapabilities((err, result) => {
|
465
|
-
let result_obj;
|
466
|
-
if ((err === null || typeof err === 'undefined') || err instanceof services_ttypes.ServicesException) {
|
467
|
-
result_obj = new SummarizationService_getCapabilities_result((err !== null || typeof err === 'undefined') ? err : {success: result});
|
468
|
-
output.writeMessageBegin("getCapabilities", Thrift.MessageType.REPLY, seqid);
|
469
|
-
} else {
|
470
|
-
result_obj = new Thrift.TApplicationException(Thrift.TApplicationExceptionType.UNKNOWN, err.message);
|
471
|
-
output.writeMessageBegin("getCapabilities", Thrift.MessageType.EXCEPTION, seqid);
|
472
|
-
}
|
473
|
-
result_obj.write(output);
|
474
|
-
output.writeMessageEnd();
|
475
|
-
output.flush();
|
476
|
-
});
|
477
|
-
}
|
478
|
-
}
|
479
|
-
};
|
1
|
+
//
|
2
|
+
// Autogenerated by Thrift Compiler (0.15.0)
|
3
|
+
//
|
4
|
+
// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
|
5
|
+
//
|
6
|
+
"use strict";
|
7
|
+
|
8
|
+
const thrift = require('thrift');
|
9
|
+
const Thrift = thrift.Thrift;
|
10
|
+
const Int64 = require('node-int64');
|
11
|
+
|
12
|
+
const communication_ttypes = require('./communication_types');
|
13
|
+
const services_ttypes = require('./services_types');
|
14
|
+
const structure_ttypes = require('./structure_types');
|
15
|
+
const uuid_ttypes = require('./uuid_types');
|
16
|
+
|
17
|
+
|
18
|
+
const Service = require('./Service');
|
19
|
+
const ServiceClient = Service.Client;
|
20
|
+
const ServiceProcessor = Service.Processor;
|
21
|
+
const ttypes = require('./summarization_types');
|
22
|
+
//HELPER FUNCTIONS AND STRUCTURES
|
23
|
+
|
24
|
+
const SummarizationService_summarize_args = class {
|
25
|
+
constructor(args) {
|
26
|
+
this.query = null;
|
27
|
+
if (args) {
|
28
|
+
if (args.query !== undefined && args.query !== null) {
|
29
|
+
this.query = new ttypes.SummarizationRequest(args.query);
|
30
|
+
}
|
31
|
+
}
|
32
|
+
}
|
33
|
+
|
34
|
+
read (input) {
|
35
|
+
input.readStructBegin();
|
36
|
+
while (true) {
|
37
|
+
const ret = input.readFieldBegin();
|
38
|
+
const ftype = ret.ftype;
|
39
|
+
const fid = ret.fid;
|
40
|
+
if (ftype == Thrift.Type.STOP) {
|
41
|
+
break;
|
42
|
+
}
|
43
|
+
switch (fid) {
|
44
|
+
case 1:
|
45
|
+
if (ftype == Thrift.Type.STRUCT) {
|
46
|
+
this.query = new ttypes.SummarizationRequest();
|
47
|
+
this.query.read(input);
|
48
|
+
} else {
|
49
|
+
input.skip(ftype);
|
50
|
+
}
|
51
|
+
break;
|
52
|
+
case 0:
|
53
|
+
input.skip(ftype);
|
54
|
+
break;
|
55
|
+
default:
|
56
|
+
input.skip(ftype);
|
57
|
+
}
|
58
|
+
input.readFieldEnd();
|
59
|
+
}
|
60
|
+
input.readStructEnd();
|
61
|
+
return;
|
62
|
+
}
|
63
|
+
|
64
|
+
write (output) {
|
65
|
+
output.writeStructBegin('SummarizationService_summarize_args');
|
66
|
+
if (this.query !== null && this.query !== undefined) {
|
67
|
+
output.writeFieldBegin('query', Thrift.Type.STRUCT, 1);
|
68
|
+
this.query.write(output);
|
69
|
+
output.writeFieldEnd();
|
70
|
+
}
|
71
|
+
output.writeFieldStop();
|
72
|
+
output.writeStructEnd();
|
73
|
+
return;
|
74
|
+
}
|
75
|
+
|
76
|
+
};
|
77
|
+
const SummarizationService_summarize_result = class {
|
78
|
+
constructor(args) {
|
79
|
+
this.success = null;
|
80
|
+
this.ex = null;
|
81
|
+
if (args instanceof services_ttypes.ServicesException) {
|
82
|
+
this.ex = args;
|
83
|
+
return;
|
84
|
+
}
|
85
|
+
if (args) {
|
86
|
+
if (args.success !== undefined && args.success !== null) {
|
87
|
+
this.success = new ttypes.Summary(args.success);
|
88
|
+
}
|
89
|
+
if (args.ex !== undefined && args.ex !== null) {
|
90
|
+
this.ex = args.ex;
|
91
|
+
}
|
92
|
+
}
|
93
|
+
}
|
94
|
+
|
95
|
+
read (input) {
|
96
|
+
input.readStructBegin();
|
97
|
+
while (true) {
|
98
|
+
const ret = input.readFieldBegin();
|
99
|
+
const ftype = ret.ftype;
|
100
|
+
const fid = ret.fid;
|
101
|
+
if (ftype == Thrift.Type.STOP) {
|
102
|
+
break;
|
103
|
+
}
|
104
|
+
switch (fid) {
|
105
|
+
case 0:
|
106
|
+
if (ftype == Thrift.Type.STRUCT) {
|
107
|
+
this.success = new ttypes.Summary();
|
108
|
+
this.success.read(input);
|
109
|
+
} else {
|
110
|
+
input.skip(ftype);
|
111
|
+
}
|
112
|
+
break;
|
113
|
+
case 1:
|
114
|
+
if (ftype == Thrift.Type.STRUCT) {
|
115
|
+
this.ex = new services_ttypes.ServicesException();
|
116
|
+
this.ex.read(input);
|
117
|
+
} else {
|
118
|
+
input.skip(ftype);
|
119
|
+
}
|
120
|
+
break;
|
121
|
+
default:
|
122
|
+
input.skip(ftype);
|
123
|
+
}
|
124
|
+
input.readFieldEnd();
|
125
|
+
}
|
126
|
+
input.readStructEnd();
|
127
|
+
return;
|
128
|
+
}
|
129
|
+
|
130
|
+
write (output) {
|
131
|
+
output.writeStructBegin('SummarizationService_summarize_result');
|
132
|
+
if (this.success !== null && this.success !== undefined) {
|
133
|
+
output.writeFieldBegin('success', Thrift.Type.STRUCT, 0);
|
134
|
+
this.success.write(output);
|
135
|
+
output.writeFieldEnd();
|
136
|
+
}
|
137
|
+
if (this.ex !== null && this.ex !== undefined) {
|
138
|
+
output.writeFieldBegin('ex', Thrift.Type.STRUCT, 1);
|
139
|
+
this.ex.write(output);
|
140
|
+
output.writeFieldEnd();
|
141
|
+
}
|
142
|
+
output.writeFieldStop();
|
143
|
+
output.writeStructEnd();
|
144
|
+
return;
|
145
|
+
}
|
146
|
+
|
147
|
+
};
|
148
|
+
const SummarizationService_getCapabilities_args = class {
|
149
|
+
constructor(args) {
|
150
|
+
}
|
151
|
+
|
152
|
+
read (input) {
|
153
|
+
input.readStructBegin();
|
154
|
+
while (true) {
|
155
|
+
const ret = input.readFieldBegin();
|
156
|
+
const ftype = ret.ftype;
|
157
|
+
if (ftype == Thrift.Type.STOP) {
|
158
|
+
break;
|
159
|
+
}
|
160
|
+
input.skip(ftype);
|
161
|
+
input.readFieldEnd();
|
162
|
+
}
|
163
|
+
input.readStructEnd();
|
164
|
+
return;
|
165
|
+
}
|
166
|
+
|
167
|
+
write (output) {
|
168
|
+
output.writeStructBegin('SummarizationService_getCapabilities_args');
|
169
|
+
output.writeFieldStop();
|
170
|
+
output.writeStructEnd();
|
171
|
+
return;
|
172
|
+
}
|
173
|
+
|
174
|
+
};
|
175
|
+
const SummarizationService_getCapabilities_result = class {
|
176
|
+
constructor(args) {
|
177
|
+
this.success = null;
|
178
|
+
this.ex = null;
|
179
|
+
if (args instanceof services_ttypes.ServicesException) {
|
180
|
+
this.ex = args;
|
181
|
+
return;
|
182
|
+
}
|
183
|
+
if (args) {
|
184
|
+
if (args.success !== undefined && args.success !== null) {
|
185
|
+
this.success = Thrift.copyList(args.success, [ttypes.SummarizationCapability]);
|
186
|
+
}
|
187
|
+
if (args.ex !== undefined && args.ex !== null) {
|
188
|
+
this.ex = args.ex;
|
189
|
+
}
|
190
|
+
}
|
191
|
+
}
|
192
|
+
|
193
|
+
read (input) {
|
194
|
+
input.readStructBegin();
|
195
|
+
while (true) {
|
196
|
+
const ret = input.readFieldBegin();
|
197
|
+
const ftype = ret.ftype;
|
198
|
+
const fid = ret.fid;
|
199
|
+
if (ftype == Thrift.Type.STOP) {
|
200
|
+
break;
|
201
|
+
}
|
202
|
+
switch (fid) {
|
203
|
+
case 0:
|
204
|
+
if (ftype == Thrift.Type.LIST) {
|
205
|
+
this.success = [];
|
206
|
+
const _rtmp316 = input.readListBegin();
|
207
|
+
const _size15 = _rtmp316.size || 0;
|
208
|
+
for (let _i17 = 0; _i17 < _size15; ++_i17) {
|
209
|
+
let elem18 = null;
|
210
|
+
elem18 = new ttypes.SummarizationCapability();
|
211
|
+
elem18.read(input);
|
212
|
+
this.success.push(elem18);
|
213
|
+
}
|
214
|
+
input.readListEnd();
|
215
|
+
} else {
|
216
|
+
input.skip(ftype);
|
217
|
+
}
|
218
|
+
break;
|
219
|
+
case 1:
|
220
|
+
if (ftype == Thrift.Type.STRUCT) {
|
221
|
+
this.ex = new services_ttypes.ServicesException();
|
222
|
+
this.ex.read(input);
|
223
|
+
} else {
|
224
|
+
input.skip(ftype);
|
225
|
+
}
|
226
|
+
break;
|
227
|
+
default:
|
228
|
+
input.skip(ftype);
|
229
|
+
}
|
230
|
+
input.readFieldEnd();
|
231
|
+
}
|
232
|
+
input.readStructEnd();
|
233
|
+
return;
|
234
|
+
}
|
235
|
+
|
236
|
+
write (output) {
|
237
|
+
output.writeStructBegin('SummarizationService_getCapabilities_result');
|
238
|
+
if (this.success !== null && this.success !== undefined) {
|
239
|
+
output.writeFieldBegin('success', Thrift.Type.LIST, 0);
|
240
|
+
output.writeListBegin(Thrift.Type.STRUCT, this.success.length);
|
241
|
+
for (let iter19 in this.success) {
|
242
|
+
if (this.success.hasOwnProperty(iter19)) {
|
243
|
+
iter19 = this.success[iter19];
|
244
|
+
iter19.write(output);
|
245
|
+
}
|
246
|
+
}
|
247
|
+
output.writeListEnd();
|
248
|
+
output.writeFieldEnd();
|
249
|
+
}
|
250
|
+
if (this.ex !== null && this.ex !== undefined) {
|
251
|
+
output.writeFieldBegin('ex', Thrift.Type.STRUCT, 1);
|
252
|
+
this.ex.write(output);
|
253
|
+
output.writeFieldEnd();
|
254
|
+
}
|
255
|
+
output.writeFieldStop();
|
256
|
+
output.writeStructEnd();
|
257
|
+
return;
|
258
|
+
}
|
259
|
+
|
260
|
+
};
|
261
|
+
const SummarizationServiceClient = exports.Client = class SummarizationServiceClient extends ServiceClient {
|
262
|
+
constructor(output, pClass) {
|
263
|
+
super(output, pClass);
|
264
|
+
this.output = output;
|
265
|
+
this.pClass = pClass;
|
266
|
+
this._seqid = 0;
|
267
|
+
this._reqs = {};
|
268
|
+
}
|
269
|
+
seqid () { return this._seqid; }
|
270
|
+
new_seqid () { return this._seqid += 1; }
|
271
|
+
|
272
|
+
summarize (query) {
|
273
|
+
this._seqid = this.new_seqid();
|
274
|
+
const self = this;
|
275
|
+
return new Promise((resolve, reject) => {
|
276
|
+
self._reqs[self.seqid()] = (error, result) => {
|
277
|
+
return error ? reject(error) : resolve(result);
|
278
|
+
};
|
279
|
+
self.send_summarize(query);
|
280
|
+
});
|
281
|
+
}
|
282
|
+
|
283
|
+
send_summarize (query) {
|
284
|
+
const output = new this.pClass(this.output);
|
285
|
+
const params = {
|
286
|
+
query: query
|
287
|
+
};
|
288
|
+
const args = new SummarizationService_summarize_args(params);
|
289
|
+
try {
|
290
|
+
output.writeMessageBegin('summarize', Thrift.MessageType.CALL, this.seqid());
|
291
|
+
args.write(output);
|
292
|
+
output.writeMessageEnd();
|
293
|
+
return this.output.flush();
|
294
|
+
}
|
295
|
+
catch (e) {
|
296
|
+
delete this._reqs[this.seqid()];
|
297
|
+
if (typeof output.reset === 'function') {
|
298
|
+
output.reset();
|
299
|
+
}
|
300
|
+
throw e;
|
301
|
+
}
|
302
|
+
}
|
303
|
+
|
304
|
+
recv_summarize (input, mtype, rseqid) {
|
305
|
+
const callback = this._reqs[rseqid] || function() {};
|
306
|
+
delete this._reqs[rseqid];
|
307
|
+
if (mtype == Thrift.MessageType.EXCEPTION) {
|
308
|
+
const x = new Thrift.TApplicationException();
|
309
|
+
x.read(input);
|
310
|
+
input.readMessageEnd();
|
311
|
+
return callback(x);
|
312
|
+
}
|
313
|
+
const result = new SummarizationService_summarize_result();
|
314
|
+
result.read(input);
|
315
|
+
input.readMessageEnd();
|
316
|
+
|
317
|
+
if (null !== result.ex) {
|
318
|
+
return callback(result.ex);
|
319
|
+
}
|
320
|
+
if (null !== result.success) {
|
321
|
+
return callback(null, result.success);
|
322
|
+
}
|
323
|
+
return callback('summarize failed: unknown result');
|
324
|
+
}
|
325
|
+
|
326
|
+
getCapabilities () {
|
327
|
+
this._seqid = this.new_seqid();
|
328
|
+
const self = this;
|
329
|
+
return new Promise((resolve, reject) => {
|
330
|
+
self._reqs[self.seqid()] = (error, result) => {
|
331
|
+
return error ? reject(error) : resolve(result);
|
332
|
+
};
|
333
|
+
self.send_getCapabilities();
|
334
|
+
});
|
335
|
+
}
|
336
|
+
|
337
|
+
send_getCapabilities () {
|
338
|
+
const output = new this.pClass(this.output);
|
339
|
+
const args = new SummarizationService_getCapabilities_args();
|
340
|
+
try {
|
341
|
+
output.writeMessageBegin('getCapabilities', Thrift.MessageType.CALL, this.seqid());
|
342
|
+
args.write(output);
|
343
|
+
output.writeMessageEnd();
|
344
|
+
return this.output.flush();
|
345
|
+
}
|
346
|
+
catch (e) {
|
347
|
+
delete this._reqs[this.seqid()];
|
348
|
+
if (typeof output.reset === 'function') {
|
349
|
+
output.reset();
|
350
|
+
}
|
351
|
+
throw e;
|
352
|
+
}
|
353
|
+
}
|
354
|
+
|
355
|
+
recv_getCapabilities (input, mtype, rseqid) {
|
356
|
+
const callback = this._reqs[rseqid] || function() {};
|
357
|
+
delete this._reqs[rseqid];
|
358
|
+
if (mtype == Thrift.MessageType.EXCEPTION) {
|
359
|
+
const x = new Thrift.TApplicationException();
|
360
|
+
x.read(input);
|
361
|
+
input.readMessageEnd();
|
362
|
+
return callback(x);
|
363
|
+
}
|
364
|
+
const result = new SummarizationService_getCapabilities_result();
|
365
|
+
result.read(input);
|
366
|
+
input.readMessageEnd();
|
367
|
+
|
368
|
+
if (null !== result.ex) {
|
369
|
+
return callback(result.ex);
|
370
|
+
}
|
371
|
+
if (null !== result.success) {
|
372
|
+
return callback(null, result.success);
|
373
|
+
}
|
374
|
+
return callback('getCapabilities failed: unknown result');
|
375
|
+
}
|
376
|
+
};
|
377
|
+
const SummarizationServiceProcessor = exports.Processor = class SummarizationServiceProcessor extends ServiceProcessor {
|
378
|
+
constructor(handler) {
|
379
|
+
super(handler);
|
380
|
+
this._handler = handler;
|
381
|
+
}
|
382
|
+
process (input, output) {
|
383
|
+
const r = input.readMessageBegin();
|
384
|
+
if (this['process_' + r.fname]) {
|
385
|
+
return this['process_' + r.fname].call(this, r.rseqid, input, output);
|
386
|
+
} else {
|
387
|
+
input.skip(Thrift.Type.STRUCT);
|
388
|
+
input.readMessageEnd();
|
389
|
+
const x = new Thrift.TApplicationException(Thrift.TApplicationExceptionType.UNKNOWN_METHOD, 'Unknown function ' + r.fname);
|
390
|
+
output.writeMessageBegin(r.fname, Thrift.MessageType.EXCEPTION, r.rseqid);
|
391
|
+
x.write(output);
|
392
|
+
output.writeMessageEnd();
|
393
|
+
output.flush();
|
394
|
+
}
|
395
|
+
}
|
396
|
+
process_summarize (seqid, input, output) {
|
397
|
+
const args = new SummarizationService_summarize_args();
|
398
|
+
args.read(input);
|
399
|
+
input.readMessageEnd();
|
400
|
+
if (this._handler.summarize.length === 1) {
|
401
|
+
Promise.resolve(this._handler.summarize.bind(this._handler)(
|
402
|
+
args.query
|
403
|
+
)).then(result => {
|
404
|
+
const result_obj = new SummarizationService_summarize_result({success: result});
|
405
|
+
output.writeMessageBegin("summarize", Thrift.MessageType.REPLY, seqid);
|
406
|
+
result_obj.write(output);
|
407
|
+
output.writeMessageEnd();
|
408
|
+
output.flush();
|
409
|
+
}).catch(err => {
|
410
|
+
let result;
|
411
|
+
if (err instanceof services_ttypes.ServicesException) {
|
412
|
+
result = new SummarizationService_summarize_result(err);
|
413
|
+
output.writeMessageBegin("summarize", Thrift.MessageType.REPLY, seqid);
|
414
|
+
} else {
|
415
|
+
result = new Thrift.TApplicationException(Thrift.TApplicationExceptionType.UNKNOWN, err.message);
|
416
|
+
output.writeMessageBegin("summarize", Thrift.MessageType.EXCEPTION, seqid);
|
417
|
+
}
|
418
|
+
result.write(output);
|
419
|
+
output.writeMessageEnd();
|
420
|
+
output.flush();
|
421
|
+
});
|
422
|
+
} else {
|
423
|
+
this._handler.summarize(args.query, (err, result) => {
|
424
|
+
let result_obj;
|
425
|
+
if ((err === null || typeof err === 'undefined') || err instanceof services_ttypes.ServicesException) {
|
426
|
+
result_obj = new SummarizationService_summarize_result((err !== null || typeof err === 'undefined') ? err : {success: result});
|
427
|
+
output.writeMessageBegin("summarize", Thrift.MessageType.REPLY, seqid);
|
428
|
+
} else {
|
429
|
+
result_obj = new Thrift.TApplicationException(Thrift.TApplicationExceptionType.UNKNOWN, err.message);
|
430
|
+
output.writeMessageBegin("summarize", Thrift.MessageType.EXCEPTION, seqid);
|
431
|
+
}
|
432
|
+
result_obj.write(output);
|
433
|
+
output.writeMessageEnd();
|
434
|
+
output.flush();
|
435
|
+
});
|
436
|
+
}
|
437
|
+
}
|
438
|
+
process_getCapabilities (seqid, input, output) {
|
439
|
+
const args = new SummarizationService_getCapabilities_args();
|
440
|
+
args.read(input);
|
441
|
+
input.readMessageEnd();
|
442
|
+
if (this._handler.getCapabilities.length === 0) {
|
443
|
+
Promise.resolve(this._handler.getCapabilities.bind(this._handler)(
|
444
|
+
)).then(result => {
|
445
|
+
const result_obj = new SummarizationService_getCapabilities_result({success: result});
|
446
|
+
output.writeMessageBegin("getCapabilities", Thrift.MessageType.REPLY, seqid);
|
447
|
+
result_obj.write(output);
|
448
|
+
output.writeMessageEnd();
|
449
|
+
output.flush();
|
450
|
+
}).catch(err => {
|
451
|
+
let result;
|
452
|
+
if (err instanceof services_ttypes.ServicesException) {
|
453
|
+
result = new SummarizationService_getCapabilities_result(err);
|
454
|
+
output.writeMessageBegin("getCapabilities", Thrift.MessageType.REPLY, seqid);
|
455
|
+
} else {
|
456
|
+
result = new Thrift.TApplicationException(Thrift.TApplicationExceptionType.UNKNOWN, err.message);
|
457
|
+
output.writeMessageBegin("getCapabilities", Thrift.MessageType.EXCEPTION, seqid);
|
458
|
+
}
|
459
|
+
result.write(output);
|
460
|
+
output.writeMessageEnd();
|
461
|
+
output.flush();
|
462
|
+
});
|
463
|
+
} else {
|
464
|
+
this._handler.getCapabilities((err, result) => {
|
465
|
+
let result_obj;
|
466
|
+
if ((err === null || typeof err === 'undefined') || err instanceof services_ttypes.ServicesException) {
|
467
|
+
result_obj = new SummarizationService_getCapabilities_result((err !== null || typeof err === 'undefined') ? err : {success: result});
|
468
|
+
output.writeMessageBegin("getCapabilities", Thrift.MessageType.REPLY, seqid);
|
469
|
+
} else {
|
470
|
+
result_obj = new Thrift.TApplicationException(Thrift.TApplicationExceptionType.UNKNOWN, err.message);
|
471
|
+
output.writeMessageBegin("getCapabilities", Thrift.MessageType.EXCEPTION, seqid);
|
472
|
+
}
|
473
|
+
result_obj.write(output);
|
474
|
+
output.writeMessageEnd();
|
475
|
+
output.flush();
|
476
|
+
});
|
477
|
+
}
|
478
|
+
}
|
479
|
+
};
|