1
+ /* eslint-disable camelcase */
1
2
import { JSONSchemaType } from 'ajv' ;
2
3
import _ , { merge , partial } from 'lodash' ;
3
4
@@ -12,6 +13,8 @@ export const typeNameMap = {
12
13
stopwords : 'Stopwords' ,
13
14
collation : 'Collation' ,
14
15
segmentation : 'Segmentation' ,
16
+ nearest_neighbors : 'Nearest Neighbors' ,
17
+ classification : 'Classification' ,
15
18
pipeline : 'Pipeline' ,
16
19
geojson : 'GeoJSON' ,
17
20
geopoint : 'GeoPoint'
@@ -105,23 +108,41 @@ export type AqlState = {
105
108
} ;
106
109
107
110
export type StopwordsState = StopwordsProperty & {
108
- type : 'stopwords' ,
111
+ type : 'stopwords' ;
109
112
properties : {
110
113
hex ?: boolean ;
111
- }
114
+ } ;
112
115
} ;
113
116
114
117
export type CollationState = LocaleProperty & {
115
118
type : 'collation' ;
116
119
} ;
117
120
118
121
export type SegmentationState = CaseProperty & {
119
- type : 'segmentation' ,
122
+ type : 'segmentation' ;
120
123
properties : {
121
124
break ?: 'all' | 'alpha' | 'graphic' ;
122
125
} ;
123
126
} ;
124
127
128
+ export type ModelProperty = {
129
+ properties : {
130
+ model_location : string ;
131
+ top_k ?: number ; // [0, 2147483647]
132
+ } ;
133
+ } ;
134
+
135
+ export type NearestNeighborsState = ModelProperty & {
136
+ type : 'nearest_neighbors' ;
137
+ } ;
138
+
139
+ export type ClassificationState = ModelProperty & {
140
+ type : 'classification' ;
141
+ properties : {
142
+ threshold ?: number ; // [0.0, 1.0]
143
+ } ;
144
+ } ;
145
+
125
146
export type PipelineState = DelimiterState
126
147
| StemState
127
148
| NormState
@@ -130,7 +151,9 @@ export type PipelineState = DelimiterState
130
151
| AqlState
131
152
| StopwordsState
132
153
| CollationState
133
- | SegmentationState ;
154
+ | SegmentationState
155
+ | NearestNeighborsState
156
+ | ClassificationState ;
134
157
135
158
export type PipelineStates = {
136
159
type : 'pipeline' ;
@@ -174,6 +197,8 @@ export type AnalyzerTypeState = IdentityState
174
197
| StopwordsState
175
198
| CollationState
176
199
| SegmentationState
200
+ | NearestNeighborsState
201
+ | ClassificationState
177
202
| PipelineStates
178
203
| GeoJsonState
179
204
| GeoPointState ;
@@ -247,7 +272,7 @@ const mergeBase = partial(merge, _, baseSchema);
247
272
248
273
const identitySchema = mergeBase ( {
249
274
properties : {
250
- type : {
275
+ ' type' : {
251
276
const : 'identity'
252
277
}
253
278
} ,
@@ -256,7 +281,7 @@ const identitySchema = mergeBase({
256
281
257
282
const delimiterSchema = mergeBase ( {
258
283
properties : {
259
- type : {
284
+ ' type' : {
260
285
const : 'delimiter'
261
286
} ,
262
287
'properties' : {
@@ -281,7 +306,7 @@ const delimiterSchema = mergeBase({
281
306
282
307
const stemSchema = mergeBase ( {
283
308
properties : {
284
- type : {
309
+ ' type' : {
285
310
const : 'stem'
286
311
} ,
287
312
'properties' : {
@@ -302,7 +327,7 @@ const stemSchema = mergeBase({
302
327
303
328
const normSchema = mergeBase ( {
304
329
properties : {
305
- type : {
330
+ ' type' : {
306
331
const : 'norm'
307
332
} ,
308
333
'properties' : {
@@ -325,7 +350,7 @@ const normSchema = mergeBase({
325
350
326
351
const ngramSchema = mergeBase ( {
327
352
properties : {
328
- type : {
353
+ ' type' : {
329
354
const : 'ngram'
330
355
} ,
331
356
'properties' : {
@@ -378,7 +403,7 @@ const ngramSchema = mergeBase({
378
403
379
404
const textSchema = mergeBase ( {
380
405
properties : {
381
- type : {
406
+ ' type' : {
382
407
const : 'text'
<
7802
td data-grid-cell-id="diff-b2bfa1d94103aa367f3b32952b303d677fac74721e734ff14925c31933ae594a-383-408-0" data-selected="false" role="gridcell" style="background-color:var(--bgColor-default);text-align:center" tabindex="-1" valign="top" class="focusable-grid-cell diff-line-number position-relative diff-line-number-neutral left-side">383
408
} ,
384
409
'properties' : {
@@ -437,7 +462,7 @@ const textSchema = mergeBase({
437
462
438
463
const aqlSchema = mergeBase ( {
439
464
properties : {
440
- type : {
465
+ ' type' : {
441
466
const : 'aql'
442
467
} ,
443
468
'properties' : {
@@ -486,7 +511,7 @@ const aqlSchema = mergeBase({
486
511
487
512
const stopwordsSchema = mergeBase ( {
488
513
properties : {
489
- type : {
514
+ ' type' : {
490
515
const : 'stopwords'
491
516
} ,
492
517
'properties' : {
@@ -518,7 +543,7 @@ const stopwordsSchema = mergeBase({
518
543
519
544
const collationSchema = mergeBase ( {
520
545
properties : {
521
- type : {
546
+ ' type' : {
522
547
const : 'collation'
523
548
} ,
524
549
'properties' : {
@@ -539,7 +564,7 @@ const collationSchema = mergeBase({
539
564
540
565
const segmentationSchema = mergeBase ( {
541
566
properties : {
542
- type : {
567
+ ' type' : {
543
568
const : 'segmentation'
544
569
} ,
545
570
'properties' : {
@@ -560,6 +585,67 @@ const segmentationSchema = mergeBase({
560
585
required : [ 'type' , 'properties' ]
561
586
} ) ;
562
587
588
+ const nearestNeighborsSchema = mergeBase ( {
589
+ properties : {
590
+ 'type' : {
591
+ const : 'nearest_neighbors'
592
+ } ,
593
+ 'properties' : {
594
+ type : 'object' ,
595
+ nullable : false ,
596
+ properties : {
597
+ model_location : {
598
+ type : 'string' ,
599
+ nullable : false
600
+ } ,
601
+ top_k : {
602
+ type : 'integer' ,
603
+ minimum : 0 ,
604
+ maximum : 2147483647 ,
605
+ nullable : false
606
+ }
607
+ }
608
+ } ,
609
+ additionalProperties : false ,
610
+ default : { }
611
+ } ,
612
+ required : [ 'type' , 'properties' ]
613
+ } ) ;
614
+
615
+ const classificationSchema = mergeBase ( {
616
+ properties : {
617
+ 'type' : {
618
+ const : 'classification'
619
+ } ,
620
+ 'properties' : {
621
+ type : 'object' ,
622
+ nullable : false ,
623
+ properties : {
624
+ model_location : {
625
+ type : 'string' ,
626
+ nullable : false
627
+ } ,
628
+ top_k : {
629
+ type : 'integer' ,
630
+ minimum : 0 ,
631
+ maximum : 2147483647 ,
632
+ nullable : false
633
+ } ,
634
+ threshold : {
635
+ type : 'number' ,
636
+ nullable : false ,
637
+ minimum : 0 ,
638
+ maximum : 1 ,
639
+ default : 0
640
+ }
641
+ }
642
+ } ,
643
+ additionalProperties : false ,
644
+ default : { }
645
+ } ,
646
+ required : [ 'type' , 'properties' ]
647
+ } ) ;
648
+
563
649
const pipelineSchema = mergeBase ( {
564
650
properties : {
565
651
type : {
@@ -586,7 +672,9 @@ const pipelineSchema = mergeBase({
586
672
aqlSchema ,
587
673
stopwordsSchema ,
588
674
collationSchema ,
589
- segmentationSchema
675
+ segmentationSchema ,
676
+ nearestNeighborsSchema ,
677
+ classificationSchema
590
678
] ,
591
679
errorMessage : {
592
680
discriminator : '/type should be one of "delimiter", "stem", "norm", "ngram", "text", "aql",' +
@@ -677,6 +765,8 @@ export const formSchema: JSONSchemaType<FormState> = {
677
765
stopwordsSchema ,
678
766
collationSchema ,
679
767
segmentationSchema ,
768
+ nearestNeighborsSchema ,
769
+ classificationSchema ,
680
770
pipelineSchema ,
681
771
geojsonSchema ,
682
772
geopointSchema
0 commit comments