@digipair/skill-vespa 0.116.1 → 0.116.3
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/dist/index.cjs.js +57302 -5
- package/dist/index.esm.js +292 -425
- package/package.json +3 -2
package/dist/index.esm.js
CHANGED
|
@@ -56696,6 +56696,7 @@ function _ts_generator(thisArg, body) {
|
|
|
56696
56696
|
};
|
|
56697
56697
|
}
|
|
56698
56698
|
}
|
|
56699
|
+
//#region src/text_splitter.ts
|
|
56699
56700
|
var TextSplitter = /*#__PURE__*/ function(BaseDocumentTransformer) {
|
|
56700
56701
|
_inherits$l(TextSplitter, BaseDocumentTransformer);
|
|
56701
56702
|
var _super = _create_super$l(TextSplitter);
|
|
@@ -56703,40 +56704,15 @@ var TextSplitter = /*#__PURE__*/ function(BaseDocumentTransformer) {
|
|
|
56703
56704
|
_class_call_check$B(this, TextSplitter);
|
|
56704
56705
|
var _this;
|
|
56705
56706
|
_this = _super.call(this, fields);
|
|
56706
|
-
|
|
56707
|
-
|
|
56708
|
-
|
|
56709
|
-
|
|
56710
|
-
|
|
56711
|
-
|
|
56712
|
-
|
|
56713
|
-
|
|
56714
|
-
|
|
56715
|
-
});
|
|
56716
|
-
Object.defineProperty(_assert_this_initialized$l(_this), "chunkSize", {
|
|
56717
|
-
enumerable: true,
|
|
56718
|
-
configurable: true,
|
|
56719
|
-
writable: true,
|
|
56720
|
-
value: 1000
|
|
56721
|
-
});
|
|
56722
|
-
Object.defineProperty(_assert_this_initialized$l(_this), "chunkOverlap", {
|
|
56723
|
-
enumerable: true,
|
|
56724
|
-
configurable: true,
|
|
56725
|
-
writable: true,
|
|
56726
|
-
value: 200
|
|
56727
|
-
});
|
|
56728
|
-
Object.defineProperty(_assert_this_initialized$l(_this), "keepSeparator", {
|
|
56729
|
-
enumerable: true,
|
|
56730
|
-
configurable: true,
|
|
56731
|
-
writable: true,
|
|
56732
|
-
value: false
|
|
56733
|
-
});
|
|
56734
|
-
Object.defineProperty(_assert_this_initialized$l(_this), "lengthFunction", {
|
|
56735
|
-
enumerable: true,
|
|
56736
|
-
configurable: true,
|
|
56737
|
-
writable: true,
|
|
56738
|
-
value: void 0
|
|
56739
|
-
});
|
|
56707
|
+
_define_property$5(_assert_this_initialized$l(_this), "lc_namespace", [
|
|
56708
|
+
"langchain",
|
|
56709
|
+
"document_transformers",
|
|
56710
|
+
"text_splitters"
|
|
56711
|
+
]);
|
|
56712
|
+
_define_property$5(_assert_this_initialized$l(_this), "chunkSize", 1e3);
|
|
56713
|
+
_define_property$5(_assert_this_initialized$l(_this), "chunkOverlap", 200);
|
|
56714
|
+
_define_property$5(_assert_this_initialized$l(_this), "keepSeparator", false);
|
|
56715
|
+
_define_property$5(_assert_this_initialized$l(_this), "lengthFunction", void 0);
|
|
56740
56716
|
var _fields_chunkSize;
|
|
56741
56717
|
_this.chunkSize = (_fields_chunkSize = fields === null || fields === void 0 ? void 0 : fields.chunkSize) !== null && _fields_chunkSize !== void 0 ? _fields_chunkSize : _this.chunkSize;
|
|
56742
56718
|
var _fields_chunkOverlap;
|
|
@@ -56747,9 +56723,7 @@ var TextSplitter = /*#__PURE__*/ function(BaseDocumentTransformer) {
|
|
|
56747
56723
|
_this.lengthFunction = (_fields_lengthFunction = fields === null || fields === void 0 ? void 0 : fields.lengthFunction) !== null && _fields_lengthFunction !== void 0 ? _fields_lengthFunction : function(text) {
|
|
56748
56724
|
return text.length;
|
|
56749
56725
|
};
|
|
56750
|
-
if (_this.chunkOverlap >= _this.chunkSize)
|
|
56751
|
-
throw new Error("Cannot have chunkOverlap >= chunkSize");
|
|
56752
|
-
}
|
|
56726
|
+
if (_this.chunkOverlap >= _this.chunkSize) throw new Error("Cannot have chunkOverlap >= chunkSize");
|
|
56753
56727
|
return _this;
|
|
56754
56728
|
}
|
|
56755
56729
|
_create_class$w(TextSplitter, [
|
|
@@ -56772,16 +56746,11 @@ var TextSplitter = /*#__PURE__*/ function(BaseDocumentTransformer) {
|
|
|
56772
56746
|
key: "splitOnSeparator",
|
|
56773
56747
|
value: function splitOnSeparator(text, separator) {
|
|
56774
56748
|
var splits;
|
|
56775
|
-
if (separator) {
|
|
56776
|
-
|
|
56777
|
-
|
|
56778
|
-
|
|
56779
|
-
|
|
56780
|
-
splits = text.split(separator);
|
|
56781
|
-
}
|
|
56782
|
-
} else {
|
|
56783
|
-
splits = text.split("");
|
|
56784
|
-
}
|
|
56749
|
+
if (separator) if (this.keepSeparator) {
|
|
56750
|
+
var regexEscapedSeparator = separator.replace(/[/\-\\^$*+?.()|[\]{}]/g, "\\$&");
|
|
56751
|
+
splits = text.split(/* @__PURE__ */ new RegExp("(?=".concat(regexEscapedSeparator, ")")));
|
|
56752
|
+
} else splits = text.split(separator);
|
|
56753
|
+
else splits = text.split("");
|
|
56785
56754
|
return splits.filter(function(s) {
|
|
56786
56755
|
return s !== "";
|
|
56787
56756
|
});
|
|
@@ -56790,16 +56759,13 @@ var TextSplitter = /*#__PURE__*/ function(BaseDocumentTransformer) {
|
|
|
56790
56759
|
{
|
|
56791
56760
|
key: "createDocuments",
|
|
56792
56761
|
value: function createDocuments(texts) {
|
|
56793
|
-
var
|
|
56794
|
-
metadatas = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : [], chunkHeaderOptions = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
|
|
56762
|
+
var metadatas = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : [], chunkHeaderOptions = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
|
|
56795
56763
|
var _this = this;
|
|
56796
56764
|
return _async_to_generator(function() {
|
|
56797
56765
|
var _metadatas, _chunkHeaderOptions_chunkHeader, chunkHeader, _chunkHeaderOptions_chunkOverlapHeader, chunkOverlapHeader, _chunkHeaderOptions_appendChunkOverlapHeader, appendChunkOverlapHeader, documents, i, text, lineCounterIndex, prevChunk, indexPrevChunk, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, chunk, pageContent, indexChunk, newLinesBeforeFirstChunk, indexEndPrevChunk, numberOfIntermediateNewLines, numberOfIntermediateNewLines1, newLinesCount, loc, metadataWithLinesNumber, err;
|
|
56798
56766
|
return _ts_generator(this, function(_state) {
|
|
56799
56767
|
switch(_state.label){
|
|
56800
56768
|
case 0:
|
|
56801
|
-
// if no metadata is provided, we create an empty one for each text
|
|
56802
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
56803
56769
|
_metadatas = metadatas.length > 0 ? metadatas : _to_consumable_array$7(Array(texts.length)).map(function() {
|
|
56804
56770
|
return {};
|
|
56805
56771
|
});
|
|
@@ -56839,7 +56805,6 @@ var TextSplitter = /*#__PURE__*/ function(BaseDocumentTransformer) {
|
|
|
56839
56805
|
];
|
|
56840
56806
|
chunk = _step.value;
|
|
56841
56807
|
pageContent = chunkHeader;
|
|
56842
|
-
// we need to count the \n that are in the text before getting removed by the splitting
|
|
56843
56808
|
indexChunk = text.indexOf(chunk, indexPrevChunk + 1);
|
|
56844
56809
|
if (!(prevChunk === null)) return [
|
|
56845
56810
|
3,
|
|
@@ -56865,9 +56830,7 @@ var TextSplitter = /*#__PURE__*/ function(BaseDocumentTransformer) {
|
|
|
56865
56830
|
numberOfIntermediateNewLines1 = _this.numberOfNewLines(text, indexChunk, indexEndPrevChunk);
|
|
56866
56831
|
lineCounterIndex -= numberOfIntermediateNewLines1;
|
|
56867
56832
|
}
|
|
56868
|
-
if (appendChunkOverlapHeader)
|
|
56869
|
-
pageContent += chunkOverlapHeader;
|
|
56870
|
-
}
|
|
56833
|
+
if (appendChunkOverlapHeader) pageContent += chunkOverlapHeader;
|
|
56871
56834
|
_state.label = 7;
|
|
56872
56835
|
case 7:
|
|
56873
56836
|
newLinesCount = _this.numberOfNewLines(chunk);
|
|
@@ -56952,7 +56915,7 @@ var TextSplitter = /*#__PURE__*/ function(BaseDocumentTransformer) {
|
|
|
56952
56915
|
var selectedDocuments, texts, metadatas;
|
|
56953
56916
|
return _ts_generator(this, function(_state) {
|
|
56954
56917
|
selectedDocuments = documents.filter(function(doc) {
|
|
56955
|
-
return doc.pageContent !==
|
|
56918
|
+
return doc.pageContent !== void 0;
|
|
56956
56919
|
});
|
|
56957
56920
|
texts = selectedDocuments.map(function(doc) {
|
|
56958
56921
|
return doc.pageContent;
|
|
@@ -56980,7 +56943,7 @@ var TextSplitter = /*#__PURE__*/ function(BaseDocumentTransformer) {
|
|
|
56980
56943
|
value: function mergeSplits(splits, separator) {
|
|
56981
56944
|
var _this = this;
|
|
56982
56945
|
return _async_to_generator(function() {
|
|
56983
|
-
var docs, currentDoc, total, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, d, _len, doc, err,
|
|
56946
|
+
var docs, currentDoc, total, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, d, _len, doc$1, err, doc;
|
|
56984
56947
|
return _ts_generator(this, function(_state) {
|
|
56985
56948
|
switch(_state.label){
|
|
56986
56949
|
case 0:
|
|
@@ -57014,17 +56977,13 @@ var TextSplitter = /*#__PURE__*/ function(BaseDocumentTransformer) {
|
|
|
57014
56977
|
3,
|
|
57015
56978
|
6
|
|
57016
56979
|
];
|
|
57017
|
-
if (total > _this.chunkSize)
|
|
57018
|
-
console.warn("Created a chunk of size ".concat(total, ", +\nwhich is longer than the specified ").concat(_this.chunkSize));
|
|
57019
|
-
}
|
|
56980
|
+
if (total > _this.chunkSize) console.warn("Created a chunk of size ".concat(total, ", +\nwhich is longer than the specified ").concat(_this.chunkSize));
|
|
57020
56981
|
if (!(currentDoc.length > 0)) return [
|
|
57021
56982
|
3,
|
|
57022
56983
|
6
|
|
57023
56984
|
];
|
|
57024
|
-
doc = _this.joinDocs(currentDoc, separator);
|
|
57025
|
-
if (doc !== null)
|
|
57026
|
-
docs.push(doc);
|
|
57027
|
-
}
|
|
56985
|
+
doc$1 = _this.joinDocs(currentDoc, separator);
|
|
56986
|
+
if (doc$1 !== null) docs.push(doc$1);
|
|
57028
56987
|
_state.label = 4;
|
|
57029
56988
|
case 4:
|
|
57030
56989
|
if (!(total > _this.chunkOverlap || total + _len + currentDoc.length * separator.length > _this.chunkSize && total > 0)) return [
|
|
@@ -57079,10 +57038,8 @@ var TextSplitter = /*#__PURE__*/ function(BaseDocumentTransformer) {
|
|
|
57079
57038
|
7
|
|
57080
57039
|
];
|
|
57081
57040
|
case 11:
|
|
57082
|
-
|
|
57083
|
-
if (
|
|
57084
|
-
docs.push(doc1);
|
|
57085
|
-
}
|
|
57041
|
+
doc = _this.joinDocs(currentDoc, separator);
|
|
57042
|
+
if (doc !== null) docs.push(doc);
|
|
57086
57043
|
return [
|
|
57087
57044
|
2,
|
|
57088
57045
|
docs
|
|
@@ -57102,17 +57059,12 @@ var RecursiveCharacterTextSplitter = /*#__PURE__*/ function(TextSplitter) {
|
|
|
57102
57059
|
_class_call_check$B(this, RecursiveCharacterTextSplitter);
|
|
57103
57060
|
var _this;
|
|
57104
57061
|
_this = _super.call(this, fields);
|
|
57105
|
-
|
|
57106
|
-
|
|
57107
|
-
|
|
57108
|
-
|
|
57109
|
-
|
|
57110
|
-
|
|
57111
|
-
"\n",
|
|
57112
|
-
" ",
|
|
57113
|
-
""
|
|
57114
|
-
]
|
|
57115
|
-
});
|
|
57062
|
+
_define_property$5(_assert_this_initialized$l(_this), "separators", [
|
|
57063
|
+
"\n\n",
|
|
57064
|
+
"\n",
|
|
57065
|
+
" ",
|
|
57066
|
+
""
|
|
57067
|
+
]);
|
|
57116
57068
|
var _fields_separators;
|
|
57117
57069
|
_this.separators = (_fields_separators = fields === null || fields === void 0 ? void 0 : fields.separators) !== null && _fields_separators !== void 0 ? _fields_separators : _this.separators;
|
|
57118
57070
|
var _fields_keepSeparator;
|
|
@@ -57130,7 +57082,6 @@ var RecursiveCharacterTextSplitter = /*#__PURE__*/ function(TextSplitter) {
|
|
|
57130
57082
|
switch(_state.label){
|
|
57131
57083
|
case 0:
|
|
57132
57084
|
finalChunks = [];
|
|
57133
|
-
// Get appropriate separator to use
|
|
57134
57085
|
separator = separators[separators.length - 1];
|
|
57135
57086
|
for(i = 0; i < separators.length; i += 1){
|
|
57136
57087
|
s = separators[i];
|
|
@@ -57144,9 +57095,7 @@ var RecursiveCharacterTextSplitter = /*#__PURE__*/ function(TextSplitter) {
|
|
|
57144
57095
|
break;
|
|
57145
57096
|
}
|
|
57146
57097
|
}
|
|
57147
|
-
// Now that we have the separator, split the text
|
|
57148
57098
|
splits = _this.splitOnSeparator(text, separator);
|
|
57149
|
-
// Now go merging things, recursively splitting longer texts.
|
|
57150
57099
|
goodSplits = [];
|
|
57151
57100
|
_separator = _this.keepSeparator ? "" : separator;
|
|
57152
57101
|
_iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
@@ -57300,349 +57249,267 @@ var RecursiveCharacterTextSplitter = /*#__PURE__*/ function(TextSplitter) {
|
|
|
57300
57249
|
{
|
|
57301
57250
|
key: "getSeparatorsForLanguage",
|
|
57302
57251
|
value: function getSeparatorsForLanguage(language) {
|
|
57303
|
-
if (language === "cpp")
|
|
57304
|
-
|
|
57305
|
-
|
|
57306
|
-
|
|
57307
|
-
|
|
57308
|
-
|
|
57309
|
-
|
|
57310
|
-
|
|
57311
|
-
|
|
57312
|
-
|
|
57313
|
-
|
|
57314
|
-
|
|
57315
|
-
|
|
57316
|
-
|
|
57317
|
-
|
|
57318
|
-
|
|
57319
|
-
|
|
57320
|
-
|
|
57321
|
-
|
|
57322
|
-
|
|
57323
|
-
|
|
57324
|
-
|
|
57325
|
-
|
|
57326
|
-
|
|
57327
|
-
|
|
57328
|
-
|
|
57329
|
-
|
|
57330
|
-
|
|
57331
|
-
|
|
57332
|
-
|
|
57333
|
-
|
|
57334
|
-
|
|
57335
|
-
|
|
57336
|
-
|
|
57337
|
-
|
|
57338
|
-
|
|
57339
|
-
|
|
57340
|
-
|
|
57341
|
-
|
|
57342
|
-
|
|
57343
|
-
|
|
57344
|
-
|
|
57345
|
-
|
|
57346
|
-
|
|
57347
|
-
|
|
57348
|
-
|
|
57349
|
-
|
|
57350
|
-
|
|
57351
|
-
|
|
57352
|
-
|
|
57353
|
-
|
|
57354
|
-
|
|
57355
|
-
|
|
57356
|
-
|
|
57357
|
-
|
|
57358
|
-
|
|
57359
|
-
|
|
57360
|
-
|
|
57361
|
-
|
|
57362
|
-
|
|
57363
|
-
|
|
57364
|
-
|
|
57365
|
-
|
|
57366
|
-
|
|
57367
|
-
|
|
57368
|
-
|
|
57369
|
-
|
|
57370
|
-
|
|
57371
|
-
|
|
57372
|
-
|
|
57373
|
-
|
|
57374
|
-
|
|
57375
|
-
|
|
57376
|
-
|
|
57377
|
-
|
|
57378
|
-
|
|
57379
|
-
|
|
57380
|
-
|
|
57381
|
-
|
|
57382
|
-
|
|
57383
|
-
|
|
57384
|
-
|
|
57385
|
-
|
|
57386
|
-
|
|
57387
|
-
|
|
57388
|
-
|
|
57389
|
-
|
|
57390
|
-
|
|
57391
|
-
|
|
57392
|
-
|
|
57393
|
-
|
|
57394
|
-
|
|
57395
|
-
|
|
57396
|
-
|
|
57397
|
-
|
|
57398
|
-
|
|
57399
|
-
|
|
57400
|
-
|
|
57401
|
-
|
|
57402
|
-
|
|
57403
|
-
|
|
57404
|
-
|
|
57405
|
-
|
|
57406
|
-
|
|
57407
|
-
|
|
57408
|
-
|
|
57409
|
-
|
|
57410
|
-
|
|
57411
|
-
|
|
57412
|
-
|
|
57413
|
-
|
|
57414
|
-
|
|
57415
|
-
|
|
57416
|
-
|
|
57417
|
-
|
|
57418
|
-
|
|
57419
|
-
|
|
57420
|
-
|
|
57421
|
-
|
|
57422
|
-
|
|
57423
|
-
|
|
57424
|
-
|
|
57425
|
-
|
|
57426
|
-
|
|
57427
|
-
|
|
57428
|
-
|
|
57429
|
-
|
|
57430
|
-
|
|
57431
|
-
|
|
57432
|
-
|
|
57433
|
-
|
|
57434
|
-
|
|
57435
|
-
|
|
57436
|
-
|
|
57437
|
-
|
|
57438
|
-
|
|
57439
|
-
|
|
57440
|
-
|
|
57441
|
-
|
|
57442
|
-
|
|
57443
|
-
|
|
57444
|
-
|
|
57445
|
-
|
|
57446
|
-
|
|
57447
|
-
|
|
57448
|
-
|
|
57449
|
-
|
|
57450
|
-
|
|
57451
|
-
|
|
57452
|
-
|
|
57453
|
-
|
|
57454
|
-
|
|
57455
|
-
|
|
57456
|
-
|
|
57457
|
-
|
|
57458
|
-
|
|
57459
|
-
|
|
57460
|
-
|
|
57461
|
-
|
|
57462
|
-
|
|
57463
|
-
|
|
57464
|
-
|
|
57465
|
-
|
|
57466
|
-
|
|
57467
|
-
|
|
57468
|
-
|
|
57469
|
-
|
|
57470
|
-
|
|
57471
|
-
|
|
57472
|
-
|
|
57473
|
-
|
|
57474
|
-
|
|
57475
|
-
|
|
57476
|
-
|
|
57477
|
-
|
|
57478
|
-
|
|
57479
|
-
|
|
57480
|
-
|
|
57481
|
-
|
|
57482
|
-
|
|
57483
|
-
|
|
57484
|
-
|
|
57485
|
-
|
|
57486
|
-
|
|
57487
|
-
|
|
57488
|
-
|
|
57489
|
-
|
|
57490
|
-
|
|
57491
|
-
|
|
57492
|
-
|
|
57493
|
-
|
|
57494
|
-
|
|
57495
|
-
|
|
57496
|
-
|
|
57497
|
-
|
|
57498
|
-
|
|
57499
|
-
|
|
57500
|
-
|
|
57501
|
-
|
|
57502
|
-
|
|
57503
|
-
|
|
57504
|
-
|
|
57505
|
-
|
|
57506
|
-
|
|
57507
|
-
|
|
57508
|
-
|
|
57509
|
-
|
|
57510
|
-
|
|
57511
|
-
|
|
57512
|
-
|
|
57513
|
-
|
|
57514
|
-
|
|
57515
|
-
|
|
57516
|
-
|
|
57517
|
-
|
|
57518
|
-
|
|
57519
|
-
|
|
57520
|
-
|
|
57521
|
-
|
|
57522
|
-
|
|
57523
|
-
|
|
57524
|
-
|
|
57525
|
-
|
|
57526
|
-
|
|
57527
|
-
|
|
57528
|
-
|
|
57529
|
-
|
|
57530
|
-
|
|
57531
|
-
|
|
57532
|
-
|
|
57533
|
-
|
|
57534
|
-
|
|
57535
|
-
|
|
57536
|
-
|
|
57537
|
-
|
|
57538
|
-
|
|
57539
|
-
|
|
57540
|
-
|
|
57541
|
-
|
|
57542
|
-
|
|
57543
|
-
|
|
57544
|
-
|
|
57545
|
-
|
|
57546
|
-
|
|
57547
|
-
|
|
57548
|
-
|
|
57549
|
-
|
|
57550
|
-
|
|
57551
|
-
|
|
57552
|
-
|
|
57553
|
-
|
|
57554
|
-
|
|
57555
|
-
|
|
57556
|
-
|
|
57557
|
-
|
|
57558
|
-
|
|
57559
|
-
|
|
57560
|
-
|
|
57561
|
-
|
|
57562
|
-
|
|
57563
|
-
|
|
57564
|
-
"\n\\begin{list}",
|
|
57565
|
-
"\n\\begin{quote}",
|
|
57566
|
-
"\n\\begin{quotation}",
|
|
57567
|
-
"\n\\begin{verse}",
|
|
57568
|
-
"\n\\begin{verbatim}",
|
|
57569
|
-
// Now split by math environments
|
|
57570
|
-
"\n\\begin{align}",
|
|
57571
|
-
"$$",
|
|
57572
|
-
"$",
|
|
57573
|
-
// Now split by the normal type of lines
|
|
57574
|
-
"\n\n",
|
|
57575
|
-
"\n",
|
|
57576
|
-
" ",
|
|
57577
|
-
""
|
|
57578
|
-
];
|
|
57579
|
-
} else if (language === "html") {
|
|
57580
|
-
return [
|
|
57581
|
-
// First, try to split along HTML tags
|
|
57582
|
-
"<body>",
|
|
57583
|
-
"<div>",
|
|
57584
|
-
"<p>",
|
|
57585
|
-
"<br>",
|
|
57586
|
-
"<li>",
|
|
57587
|
-
"<h1>",
|
|
57588
|
-
"<h2>",
|
|
57589
|
-
"<h3>",
|
|
57590
|
-
"<h4>",
|
|
57591
|
-
"<h5>",
|
|
57592
|
-
"<h6>",
|
|
57593
|
-
"<span>",
|
|
57594
|
-
"<table>",
|
|
57595
|
-
"<tr>",
|
|
57596
|
-
"<td>",
|
|
57597
|
-
"<th>",
|
|
57598
|
-
"<ul>",
|
|
57599
|
-
"<ol>",
|
|
57600
|
-
"<header>",
|
|
57601
|
-
"<footer>",
|
|
57602
|
-
"<nav>",
|
|
57603
|
-
// Head
|
|
57604
|
-
"<head>",
|
|
57605
|
-
"<style>",
|
|
57606
|
-
"<script>",
|
|
57607
|
-
"<meta>",
|
|
57608
|
-
"<title>",
|
|
57609
|
-
// Normal type of lines
|
|
57610
|
-
" ",
|
|
57611
|
-
""
|
|
57612
|
-
];
|
|
57613
|
-
} else if (language === "sol") {
|
|
57614
|
-
return [
|
|
57615
|
-
// Split along compiler informations definitions
|
|
57616
|
-
"\npragma ",
|
|
57617
|
-
"\nusing ",
|
|
57618
|
-
// Split along contract definitions
|
|
57619
|
-
"\ncontract ",
|
|
57620
|
-
"\ninterface ",
|
|
57621
|
-
"\nlibrary ",
|
|
57622
|
-
// Split along method definitions
|
|
57623
|
-
"\nconstructor ",
|
|
57624
|
-
"\ntype ",
|
|
57625
|
-
"\nfunction ",
|
|
57626
|
-
"\nevent ",
|
|
57627
|
-
"\nmodifier ",
|
|
57628
|
-
"\nerror ",
|
|
57629
|
-
"\nstruct ",
|
|
57630
|
-
"\nenum ",
|
|
57631
|
-
// Split along control flow statements
|
|
57632
|
-
"\nif ",
|
|
57633
|
-
"\nfor ",
|
|
57634
|
-
"\nwhile ",
|
|
57635
|
-
"\ndo while ",
|
|
57636
|
-
"\nassembly ",
|
|
57637
|
-
// Split by the normal type of lines
|
|
57638
|
-
"\n\n",
|
|
57639
|
-
"\n",
|
|
57640
|
-
" ",
|
|
57641
|
-
""
|
|
57642
|
-
];
|
|
57643
|
-
} else {
|
|
57644
|
-
throw new Error("Language ".concat(language, " is not supported."));
|
|
57645
|
-
}
|
|
57252
|
+
if (language === "cpp") return [
|
|
57253
|
+
"\nclass ",
|
|
57254
|
+
"\nvoid ",
|
|
57255
|
+
"\nint ",
|
|
57256
|
+
"\nfloat ",
|
|
57257
|
+
"\ndouble ",
|
|
57258
|
+
"\nif ",
|
|
57259
|
+
"\nfor ",
|
|
57260
|
+
"\nwhile ",
|
|
57261
|
+
"\nswitch ",
|
|
57262
|
+
"\ncase ",
|
|
57263
|
+
"\n\n",
|
|
57264
|
+
"\n",
|
|
57265
|
+
" ",
|
|
57266
|
+
""
|
|
57267
|
+
];
|
|
57268
|
+
else if (language === "go") return [
|
|
57269
|
+
"\nfunc ",
|
|
57270
|
+
"\nvar ",
|
|
57271
|
+
"\nconst ",
|
|
57272
|
+
"\ntype ",
|
|
57273
|
+
"\nif ",
|
|
57274
|
+
"\nfor ",
|
|
57275
|
+
"\nswitch ",
|
|
57276
|
+
"\ncase ",
|
|
57277
|
+
"\n\n",
|
|
57278
|
+
"\n",
|
|
57279
|
+
" ",
|
|
57280
|
+
""
|
|
57281
|
+
];
|
|
57282
|
+
else if (language === "java") return [
|
|
57283
|
+
"\nclass ",
|
|
57284
|
+
"\npublic ",
|
|
57285
|
+
"\nprotected ",
|
|
57286
|
+
"\nprivate ",
|
|
57287
|
+
"\nstatic ",
|
|
57288
|
+
"\nif ",
|
|
57289
|
+
"\nfor ",
|
|
57290
|
+
"\nwhile ",
|
|
57291
|
+
"\nswitch ",
|
|
57292
|
+
"\ncase ",
|
|
57293
|
+
"\n\n",
|
|
57294
|
+
"\n",
|
|
57295
|
+
" ",
|
|
57296
|
+
""
|
|
57297
|
+
];
|
|
57298
|
+
else if (language === "js") return [
|
|
57299
|
+
"\nfunction ",
|
|
57300
|
+
"\nconst ",
|
|
57301
|
+
"\nlet ",
|
|
57302
|
+
"\nvar ",
|
|
57303
|
+
"\nclass ",
|
|
57304
|
+
"\nif ",
|
|
57305
|
+
"\nfor ",
|
|
57306
|
+
"\nwhile ",
|
|
57307
|
+
"\nswitch ",
|
|
57308
|
+
"\ncase ",
|
|
57309
|
+
"\ndefault ",
|
|
57310
|
+
"\n\n",
|
|
57311
|
+
"\n",
|
|
57312
|
+
" ",
|
|
57313
|
+
""
|
|
57314
|
+
];
|
|
57315
|
+
else if (language === "php") return [
|
|
57316
|
+
"\nfunction ",
|
|
57317
|
+
"\nclass ",
|
|
57318
|
+
"\nif ",
|
|
57319
|
+
"\nforeach ",
|
|
57320
|
+
"\nwhile ",
|
|
57321
|
+
"\ndo ",
|
|
57322
|
+
"\nswitch ",
|
|
57323
|
+
"\ncase ",
|
|
57324
|
+
"\n\n",
|
|
57325
|
+
"\n",
|
|
57326
|
+
" ",
|
|
57327
|
+
""
|
|
57328
|
+
];
|
|
57329
|
+
else if (language === "proto") return [
|
|
57330
|
+
"\nmessage ",
|
|
57331
|
+
"\nservice ",
|
|
57332
|
+
"\nenum ",
|
|
57333
|
+
"\noption ",
|
|
57334
|
+
"\nimport ",
|
|
57335
|
+
"\nsyntax ",
|
|
57336
|
+
"\n\n",
|
|
57337
|
+
"\n",
|
|
57338
|
+
" ",
|
|
57339
|
+
""
|
|
57340
|
+
];
|
|
57341
|
+
else if (language === "python") return [
|
|
57342
|
+
"\nclass ",
|
|
57343
|
+
"\ndef ",
|
|
57344
|
+
"\n def ",
|
|
57345
|
+
"\n\n",
|
|
57346
|
+
"\n",
|
|
57347
|
+
" ",
|
|
57348
|
+
""
|
|
57349
|
+
];
|
|
57350
|
+
else if (language === "rst") return [
|
|
57351
|
+
"\n===\n",
|
|
57352
|
+
"\n---\n",
|
|
57353
|
+
"\n***\n",
|
|
57354
|
+
"\n.. ",
|
|
57355
|
+
"\n\n",
|
|
57356
|
+
"\n",
|
|
57357
|
+
" ",
|
|
57358
|
+
""
|
|
57359
|
+
];
|
|
57360
|
+
else if (language === "ruby") return [
|
|
57361
|
+
"\ndef ",
|
|
57362
|
+
"\nclass ",
|
|
57363
|
+
"\nif ",
|
|
57364
|
+
"\nunless ",
|
|
57365
|
+
"\nwhile ",
|
|
57366
|
+
"\nfor ",
|
|
57367
|
+
"\ndo ",
|
|
57368
|
+
"\nbegin ",
|
|
57369
|
+
"\nrescue ",
|
|
57370
|
+
"\n\n",
|
|
57371
|
+
"\n",
|
|
57372
|
+
" ",
|
|
57373
|
+
""
|
|
57374
|
+
];
|
|
57375
|
+
else if (language === "rust") return [
|
|
57376
|
+
"\nfn ",
|
|
57377
|
+
"\nconst ",
|
|
57378
|
+
"\nlet ",
|
|
57379
|
+
"\nif ",
|
|
57380
|
+
"\nwhile ",
|
|
57381
|
+
"\nfor ",
|
|
57382
|
+
"\nloop ",
|
|
57383
|
+
"\nmatch ",
|
|
57384
|
+
"\nconst ",
|
|
57385
|
+
"\n\n",
|
|
57386
|
+
"\n",
|
|
57387
|
+
" ",
|
|
57388
|
+
""
|
|
57389
|
+
];
|
|
57390
|
+
else if (language === "scala") return [
|
|
57391
|
+
"\nclass ",
|
|
57392
|
+
"\nobject ",
|
|
57393
|
+
"\ndef ",
|
|
57394
|
+
"\nval ",
|
|
57395
|
+
"\nvar ",
|
|
57396
|
+
"\nif ",
|
|
57397
|
+
"\nfor ",
|
|
57398
|
+
"\nwhile ",
|
|
57399
|
+
"\nmatch ",
|
|
57400
|
+
"\ncase ",
|
|
57401
|
+
"\n\n",
|
|
57402
|
+
"\n",
|
|
57403
|
+
" ",
|
|
57404
|
+
""
|
|
57405
|
+
];
|
|
57406
|
+
else if (language === "swift") return [
|
|
57407
|
+
"\nfunc ",
|
|
57408
|
+
"\nclass ",
|
|
57409
|
+
"\nstruct ",
|
|
57410
|
+
"\nenum ",
|
|
57411
|
+
"\nif ",
|
|
57412
|
+
"\nfor ",
|
|
57413
|
+
"\nwhile ",
|
|
57414
|
+
"\ndo ",
|
|
57415
|
+
"\nswitch ",
|
|
57416
|
+
"\ncase ",
|
|
57417
|
+
"\n\n",
|
|
57418
|
+
"\n",
|
|
57419
|
+
" ",
|
|
57420
|
+
""
|
|
57421
|
+
];
|
|
57422
|
+
else if (language === "markdown") return [
|
|
57423
|
+
"\n## ",
|
|
57424
|
+
"\n### ",
|
|
57425
|
+
"\n#### ",
|
|
57426
|
+
"\n##### ",
|
|
57427
|
+
"\n###### ",
|
|
57428
|
+
"```\n\n",
|
|
57429
|
+
"\n\n***\n\n",
|
|
57430
|
+
"\n\n---\n\n",
|
|
57431
|
+
"\n\n___\n\n",
|
|
57432
|
+
"\n\n",
|
|
57433
|
+
"\n",
|
|
57434
|
+
" ",
|
|
57435
|
+
""
|
|
57436
|
+
];
|
|
57437
|
+
else if (language === "latex") return [
|
|
57438
|
+
"\n\\chapter{",
|
|
57439
|
+
"\n\\section{",
|
|
57440
|
+
"\n\\subsection{",
|
|
57441
|
+
"\n\\subsubsection{",
|
|
57442
|
+
"\n\\begin{enumerate}",
|
|
57443
|
+
"\n\\begin{itemize}",
|
|
57444
|
+
"\n\\begin{description}",
|
|
57445
|
+
"\n\\begin{list}",
|
|
57446
|
+
"\n\\begin{quote}",
|
|
57447
|
+
"\n\\begin{quotation}",
|
|
57448
|
+
"\n\\begin{verse}",
|
|
57449
|
+
"\n\\begin{verbatim}",
|
|
57450
|
+
"\n\\begin{align}",
|
|
57451
|
+
"$$",
|
|
57452
|
+
"$",
|
|
57453
|
+
"\n\n",
|
|
57454
|
+
"\n",
|
|
57455
|
+
" ",
|
|
57456
|
+
""
|
|
57457
|
+
];
|
|
57458
|
+
else if (language === "html") return [
|
|
57459
|
+
"<body>",
|
|
57460
|
+
"<div>",
|
|
57461
|
+
"<p>",
|
|
57462
|
+
"<br>",
|
|
57463
|
+
"<li>",
|
|
57464
|
+
"<h1>",
|
|
57465
|
+
"<h2>",
|
|
57466
|
+
"<h3>",
|
|
57467
|
+
"<h4>",
|
|
57468
|
+
"<h5>",
|
|
57469
|
+
"<h6>",
|
|
57470
|
+
"<span>",
|
|
57471
|
+
"<table>",
|
|
57472
|
+
"<tr>",
|
|
57473
|
+
"<td>",
|
|
57474
|
+
"<th>",
|
|
57475
|
+
"<ul>",
|
|
57476
|
+
"<ol>",
|
|
57477
|
+
"<header>",
|
|
57478
|
+
"<footer>",
|
|
57479
|
+
"<nav>",
|
|
57480
|
+
"<head>",
|
|
57481
|
+
"<style>",
|
|
57482
|
+
"<script>",
|
|
57483
|
+
"<meta>",
|
|
57484
|
+
"<title>",
|
|
57485
|
+
" ",
|
|
57486
|
+
""
|
|
57487
|
+
];
|
|
57488
|
+
else if (language === "sol") return [
|
|
57489
|
+
"\npragma ",
|
|
57490
|
+
"\nusing ",
|
|
57491
|
+
"\ncontract ",
|
|
57492
|
+
"\ninterface ",
|
|
57493
|
+
"\nlibrary ",
|
|
57494
|
+
"\nconstructor ",
|
|
57495
|
+
"\ntype ",
|
|
57496
|
+
"\nfunction ",
|
|
57497
|
+
"\nevent ",
|
|
57498
|
+
"\nmodifier ",
|
|
57499
|
+
"\nerror ",
|
|
57500
|
+
"\nstruct ",
|
|
57501
|
+
"\nenum ",
|
|
57502
|
+
"\nif ",
|
|
57503
|
+
"\nfor ",
|
|
57504
|
+
"\nwhile ",
|
|
57505
|
+
"\ndo while ",
|
|
57506
|
+
"\nassembly ",
|
|
57507
|
+
"\n\n",
|
|
57508
|
+
"\n",
|
|
57509
|
+
" ",
|
|
57510
|
+
""
|
|
57511
|
+
];
|
|
57512
|
+
else throw new Error("Language ".concat(language, " is not supported."));
|
|
57646
57513
|
}
|
|
57647
57514
|
}
|
|
57648
57515
|
]);
|