@keymanapp/kmc-model 18.0.53-alpha → 18.0.54-alpha

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.
@@ -1,56 +1,56 @@
1
- /// <reference types="@keymanapp/models-types" />
2
- /**
3
- * Converts wordforms into an indexable form. It does this by
4
- * normalizing the letter case of characters INDIVIDUALLY (to disregard
5
- * context-sensitive case transformations), normalizing to NFKD form,
6
- * and removing common diacritical marks.
7
- *
8
- * This is a very speculative implementation, that might work with
9
- * your language. We don't guarantee that this will be perfect for your
10
- * language, but it's a start.
11
- *
12
- * This uses String.prototype.normalize() to convert normalize into NFKD.
13
- * NFKD neutralizes some funky distinctions, e.g., ꬲ, e, e should all be the
14
- * same character; plus, it's an easy way to separate a Latin character from
15
- * its diacritics; Even then, orthographies regularly use code points
16
- * that, under NFKD normalization, do NOT decompose appropriately for your
17
- * language (e.g., SENĆOŦEN, Plains Cree in syllabics).
18
- *
19
- * Use this in early iterations of the model. For a production lexical model,
20
- * you will probably write/generate your own key function, tailored to your
21
- * language. There is a chance the default will work properly out of the box.
22
- */
23
- export declare function defaultSearchTermToKey(wordform: string): string;
24
- /**
25
- * Converts wordforms into an indexable form. It does this by
26
- * normalizing the letter case of characters INDIVIDUALLY (to disregard
27
- * context-sensitive case transformations), normalizing to NFKD form,
28
- * and removing common diacritical marks.
29
- *
30
- * This is a very speculative implementation, that might work with
31
- * your language. We don't guarantee that this will be perfect for your
32
- * language, but it's a start.
33
- *
34
- * This uses String.prototype.normalize() to convert normalize into NFKD.
35
- * NFKD neutralizes some funky distinctions, e.g., ꬲ, e, e should all be the
36
- * same character; plus, it's an easy way to separate a Latin character from
37
- * its diacritics; Even then, orthographies regularly use code points
38
- * that, under NFKD normalization, do NOT decompose appropriately for your
39
- * language (e.g., SENĆOŦEN, Plains Cree in syllabics).
40
- *
41
- * Use this in early iterations of the model. For a production lexical model,
42
- * you will probably write/generate your own key function, tailored to your
43
- * language. There is a chance the default will work properly out of the box.
44
- */
45
- export declare function defaultCasedSearchTermToKey(wordform: string, applyCasing: CasingFunction): string;
46
- /**
47
- * Specifies default casing behavior for lexical models when `languageUsesCasing` is
48
- * set to true.
49
- * @param casing One of 'lower' (lowercased), 'upper' (uppercased), or 'initial'.
50
- *
51
- * 'initial' is designed to cover cases like sentence-initial & proper noun capitalization in English.
52
- * This may be overwritten as appropriate in model-specific implementations.
53
- * @param text The text to be modified.
54
- */
55
- export declare function defaultApplyCasing(casing: CasingForm, text: string): string;
1
+ /// <reference types="@keymanapp/models-types" />
2
+ /**
3
+ * Converts wordforms into an indexable form. It does this by
4
+ * normalizing the letter case of characters INDIVIDUALLY (to disregard
5
+ * context-sensitive case transformations), normalizing to NFKD form,
6
+ * and removing common diacritical marks.
7
+ *
8
+ * This is a very speculative implementation, that might work with
9
+ * your language. We don't guarantee that this will be perfect for your
10
+ * language, but it's a start.
11
+ *
12
+ * This uses String.prototype.normalize() to convert normalize into NFKD.
13
+ * NFKD neutralizes some funky distinctions, e.g., ꬲ, e, e should all be the
14
+ * same character; plus, it's an easy way to separate a Latin character from
15
+ * its diacritics; Even then, orthographies regularly use code points
16
+ * that, under NFKD normalization, do NOT decompose appropriately for your
17
+ * language (e.g., SENĆOŦEN, Plains Cree in syllabics).
18
+ *
19
+ * Use this in early iterations of the model. For a production lexical model,
20
+ * you will probably write/generate your own key function, tailored to your
21
+ * language. There is a chance the default will work properly out of the box.
22
+ */
23
+ export declare function defaultSearchTermToKey(wordform: string): string;
24
+ /**
25
+ * Converts wordforms into an indexable form. It does this by
26
+ * normalizing the letter case of characters INDIVIDUALLY (to disregard
27
+ * context-sensitive case transformations), normalizing to NFKD form,
28
+ * and removing common diacritical marks.
29
+ *
30
+ * This is a very speculative implementation, that might work with
31
+ * your language. We don't guarantee that this will be perfect for your
32
+ * language, but it's a start.
33
+ *
34
+ * This uses String.prototype.normalize() to convert normalize into NFKD.
35
+ * NFKD neutralizes some funky distinctions, e.g., ꬲ, e, e should all be the
36
+ * same character; plus, it's an easy way to separate a Latin character from
37
+ * its diacritics; Even then, orthographies regularly use code points
38
+ * that, under NFKD normalization, do NOT decompose appropriately for your
39
+ * language (e.g., SENĆOŦEN, Plains Cree in syllabics).
40
+ *
41
+ * Use this in early iterations of the model. For a production lexical model,
42
+ * you will probably write/generate your own key function, tailored to your
43
+ * language. There is a chance the default will work properly out of the box.
44
+ */
45
+ export declare function defaultCasedSearchTermToKey(wordform: string, applyCasing: CasingFunction): string;
46
+ /**
47
+ * Specifies default casing behavior for lexical models when `languageUsesCasing` is
48
+ * set to true.
49
+ * @param casing One of 'lower' (lowercased), 'upper' (uppercased), or 'initial'.
50
+ *
51
+ * 'initial' is designed to cover cases like sentence-initial & proper noun capitalization in English.
52
+ * This may be overwritten as appropriate in model-specific implementations.
53
+ * @param text The text to be modified.
54
+ */
55
+ export declare function defaultApplyCasing(casing: CasingForm, text: string): string;
56
56
  //# sourceMappingURL=model-defaults.d.ts.map
@@ -1,102 +1,102 @@
1
- /**
2
- * Converts wordforms into an indexable form. It does this by
3
- * normalizing the letter case of characters INDIVIDUALLY (to disregard
4
- * context-sensitive case transformations), normalizing to NFKD form,
5
- * and removing common diacritical marks.
6
- *
7
- * This is a very speculative implementation, that might work with
8
- * your language. We don't guarantee that this will be perfect for your
9
- * language, but it's a start.
10
- *
11
- * This uses String.prototype.normalize() to convert normalize into NFKD.
12
- * NFKD neutralizes some funky distinctions, e.g., ꬲ, e, e should all be the
13
- * same character; plus, it's an easy way to separate a Latin character from
14
- * its diacritics; Even then, orthographies regularly use code points
15
- * that, under NFKD normalization, do NOT decompose appropriately for your
16
- * language (e.g., SENĆOŦEN, Plains Cree in syllabics).
17
- *
18
- * Use this in early iterations of the model. For a production lexical model,
19
- * you will probably write/generate your own key function, tailored to your
20
- * language. There is a chance the default will work properly out of the box.
21
- */
22
- export function defaultSearchTermToKey(wordform) {
23
- return wordform
24
- .normalize('NFKD')
25
- // Remove any combining diacritics (if input is in NFKD)
26
- .replace(/[\u0300-\u036F]/g, '')
27
- // Replace directional quotation marks with plain apostrophes
28
- .replace(/[‘’]/g, "'")
29
- // Also double-quote marks.
30
- .replace(/[“”]/g, '"');
31
- }
32
- /**
33
- * Converts wordforms into an indexable form. It does this by
34
- * normalizing the letter case of characters INDIVIDUALLY (to disregard
35
- * context-sensitive case transformations), normalizing to NFKD form,
36
- * and removing common diacritical marks.
37
- *
38
- * This is a very speculative implementation, that might work with
39
- * your language. We don't guarantee that this will be perfect for your
40
- * language, but it's a start.
41
- *
42
- * This uses String.prototype.normalize() to convert normalize into NFKD.
43
- * NFKD neutralizes some funky distinctions, e.g., ꬲ, e, e should all be the
44
- * same character; plus, it's an easy way to separate a Latin character from
45
- * its diacritics; Even then, orthographies regularly use code points
46
- * that, under NFKD normalization, do NOT decompose appropriately for your
47
- * language (e.g., SENĆOŦEN, Plains Cree in syllabics).
48
- *
49
- * Use this in early iterations of the model. For a production lexical model,
50
- * you will probably write/generate your own key function, tailored to your
51
- * language. There is a chance the default will work properly out of the box.
52
- */
53
- export function defaultCasedSearchTermToKey(wordform, applyCasing) {
54
- // While this is a bit WET, as the basic `defaultSearchTermToKey` exists and performs some of
55
- // the same functions, repetition is the easiest way to allow the function to be safely compiled
56
- // with ease by use of `.toString()`.
57
- return Array.from(wordform
58
- .normalize('NFKD')
59
- // Remove any combining diacritics (if input is in NFKD)
60
- .replace(/[\u0300-\u036F]/g, '')) // end of `Array.from`
61
- .map(function (c) { return applyCasing('lower', c); })
62
- .join('')
63
- // Replace directional quotation marks with plain apostrophes
64
- .replace(/[‘’]/g, "'")
65
- // Also double-quote marks.
66
- .replace(/[“”]/g, '"');
67
- }
68
- /**
69
- * Specifies default casing behavior for lexical models when `languageUsesCasing` is
70
- * set to true.
71
- * @param casing One of 'lower' (lowercased), 'upper' (uppercased), or 'initial'.
72
- *
73
- * 'initial' is designed to cover cases like sentence-initial & proper noun capitalization in English.
74
- * This may be overwritten as appropriate in model-specific implementations.
75
- * @param text The text to be modified.
76
- */
77
- export function defaultApplyCasing(casing, text) {
78
- switch (casing) {
79
- case 'lower':
80
- return text.toLowerCase();
81
- case 'upper':
82
- return text.toUpperCase();
83
- case 'initial':
84
- var headCode = text.charCodeAt(0);
85
- // The length of the first code unit, as measured in code points.
86
- var headUnitLength = 1;
87
- // Is the first character a high surrogate, indicating possible use of UTF-16
88
- // surrogate pairs? Also, is the string long enough for there to BE a pair?
89
- if (text.length > 1 && headCode >= 0xD800 && headCode <= 0xDBFF) {
90
- // It's possible, so now we check for low surrogates.
91
- var lowSurrogateCode = text.charCodeAt(1);
92
- if (lowSurrogateCode >= 0xDC00 && lowSurrogateCode <= 0xDFFF) {
93
- // We have a surrogate pair; this pair is the 'first' character.
94
- headUnitLength++;
95
- }
96
- }
97
- // Capitalizes the first code unit of the string, leaving the rest intact.
98
- return text.substring(0, headUnitLength).toUpperCase() // head - uppercased
99
- .concat(text.substring(headUnitLength)); // tail - lowercased
100
- }
101
- }
1
+ /**
2
+ * Converts wordforms into an indexable form. It does this by
3
+ * normalizing the letter case of characters INDIVIDUALLY (to disregard
4
+ * context-sensitive case transformations), normalizing to NFKD form,
5
+ * and removing common diacritical marks.
6
+ *
7
+ * This is a very speculative implementation, that might work with
8
+ * your language. We don't guarantee that this will be perfect for your
9
+ * language, but it's a start.
10
+ *
11
+ * This uses String.prototype.normalize() to convert normalize into NFKD.
12
+ * NFKD neutralizes some funky distinctions, e.g., ꬲ, e, e should all be the
13
+ * same character; plus, it's an easy way to separate a Latin character from
14
+ * its diacritics; Even then, orthographies regularly use code points
15
+ * that, under NFKD normalization, do NOT decompose appropriately for your
16
+ * language (e.g., SENĆOŦEN, Plains Cree in syllabics).
17
+ *
18
+ * Use this in early iterations of the model. For a production lexical model,
19
+ * you will probably write/generate your own key function, tailored to your
20
+ * language. There is a chance the default will work properly out of the box.
21
+ */
22
+ export function defaultSearchTermToKey(wordform) {
23
+ return wordform
24
+ .normalize('NFKD')
25
+ // Remove any combining diacritics (if input is in NFKD)
26
+ .replace(/[\u0300-\u036F]/g, '')
27
+ // Replace directional quotation marks with plain apostrophes
28
+ .replace(/[‘’]/g, "'")
29
+ // Also double-quote marks.
30
+ .replace(/[“”]/g, '"');
31
+ }
32
+ /**
33
+ * Converts wordforms into an indexable form. It does this by
34
+ * normalizing the letter case of characters INDIVIDUALLY (to disregard
35
+ * context-sensitive case transformations), normalizing to NFKD form,
36
+ * and removing common diacritical marks.
37
+ *
38
+ * This is a very speculative implementation, that might work with
39
+ * your language. We don't guarantee that this will be perfect for your
40
+ * language, but it's a start.
41
+ *
42
+ * This uses String.prototype.normalize() to convert normalize into NFKD.
43
+ * NFKD neutralizes some funky distinctions, e.g., ꬲ, e, e should all be the
44
+ * same character; plus, it's an easy way to separate a Latin character from
45
+ * its diacritics; Even then, orthographies regularly use code points
46
+ * that, under NFKD normalization, do NOT decompose appropriately for your
47
+ * language (e.g., SENĆOŦEN, Plains Cree in syllabics).
48
+ *
49
+ * Use this in early iterations of the model. For a production lexical model,
50
+ * you will probably write/generate your own key function, tailored to your
51
+ * language. There is a chance the default will work properly out of the box.
52
+ */
53
+ export function defaultCasedSearchTermToKey(wordform, applyCasing) {
54
+ // While this is a bit WET, as the basic `defaultSearchTermToKey` exists and performs some of
55
+ // the same functions, repetition is the easiest way to allow the function to be safely compiled
56
+ // with ease by use of `.toString()`.
57
+ return Array.from(wordform
58
+ .normalize('NFKD')
59
+ // Remove any combining diacritics (if input is in NFKD)
60
+ .replace(/[\u0300-\u036F]/g, '')) // end of `Array.from`
61
+ .map(function (c) { return applyCasing('lower', c); })
62
+ .join('')
63
+ // Replace directional quotation marks with plain apostrophes
64
+ .replace(/[‘’]/g, "'")
65
+ // Also double-quote marks.
66
+ .replace(/[“”]/g, '"');
67
+ }
68
+ /**
69
+ * Specifies default casing behavior for lexical models when `languageUsesCasing` is
70
+ * set to true.
71
+ * @param casing One of 'lower' (lowercased), 'upper' (uppercased), or 'initial'.
72
+ *
73
+ * 'initial' is designed to cover cases like sentence-initial & proper noun capitalization in English.
74
+ * This may be overwritten as appropriate in model-specific implementations.
75
+ * @param text The text to be modified.
76
+ */
77
+ export function defaultApplyCasing(casing, text) {
78
+ switch (casing) {
79
+ case 'lower':
80
+ return text.toLowerCase();
81
+ case 'upper':
82
+ return text.toUpperCase();
83
+ case 'initial':
84
+ var headCode = text.charCodeAt(0);
85
+ // The length of the first code unit, as measured in code points.
86
+ var headUnitLength = 1;
87
+ // Is the first character a high surrogate, indicating possible use of UTF-16
88
+ // surrogate pairs? Also, is the string long enough for there to BE a pair?
89
+ if (text.length > 1 && headCode >= 0xD800 && headCode <= 0xDBFF) {
90
+ // It's possible, so now we check for low surrogates.
91
+ var lowSurrogateCode = text.charCodeAt(1);
92
+ if (lowSurrogateCode >= 0xDC00 && lowSurrogateCode <= 0xDFFF) {
93
+ // We have a surrogate pair; this pair is the 'first' character.
94
+ headUnitLength++;
95
+ }
96
+ }
97
+ // Capitalizes the first code unit of the string, leaving the rest intact.
98
+ return text.substring(0, headUnitLength).toUpperCase() // head - uppercased
99
+ .concat(text.substring(headUnitLength)); // tail - lowercased
100
+ }
101
+ }
102
102
  //# sourceMappingURL=model-defaults.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"model-defaults.js","sourceRoot":"","sources":["../../src/model-defaults.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,sBAAsB,CAAC,QAAgB;IACrD,OAAO,QAAQ;SACV,SAAS,CAAC,MAAM,CAAC;QAClB,wDAAwD;SACvD,OAAO,CAAC,kBAAkB,EAAE,EAAE,CAAC;QAChC,6DAA6D;SAC5D,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC;QACtB,2BAA2B;SAC1B,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;AAC7B,CAAC;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,2BAA2B,CAAC,QAAgB,EAAE,WAA2B;IACvF,6FAA6F;IAC7F,gGAAgG;IACh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C,WAAW,EAAE,CAAC;QAC5B,KAAK,SAAS;YACZ,IAAI,QAAQ,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;YAClC,iEAAiE;YACjE,IAAI,cAAc,GAAG,CAAC,CAAC;YAEvB,6EAA6E;YAC7E,4EAA4E;YAC5E,IAAG,IAAI,CAAC,MAAM,GAAG,CAAC,IAAI,QAAQ,IAAI,MAAM,IAAI,QAAQ,IAAI,MAAM,EAAE,CAAC;gBAC/D,qDAAqD;gBACrD,IAAI,gBAAgB,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;gBAE1C,IAAG,gBAAgB,IAAI,MAAM,IAAI,gBAAgB,IAAI,MAAM,EAAE,CAAC;oBAC5D,gEAAgE;oBAChE,cAAc,EAAE,CAAC;gBACnB,CAAC;YACH,CAAC;YAED,0EAA0E;YAC1E,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,cAAc,CAAC,CAAC,WAAW,EAAE,CAAC,oBAAoB;iBACnE,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC,CAAC,CAAQ,oBAAoB;IAC/E,CAAC;AACH,CAAC"}
@@ -1,71 +1,71 @@
1
- /// <reference types="@keymanapp/models-types" />
2
- import { LexicalModelSource, WordformToKeySpec } from "./lexical-model.js";
3
- /**
4
- * Processes certain defined model behaviors in such a way that the needed closures
5
- * may be safely compiled to a JS file and loaded within the LMLayer.
6
- *
7
- * This is accomplished by writing out a 'pseudoclosure' within the model's IIFE,
8
- * then used to build _actual_ closures at LMLayer load time. This 'pseudoclosure'
9
- * will very closely match the organizational patterns of this class in order to
10
- * facilitate the maintenance of this approach.
11
- */
12
- export declare class ModelDefinitions {
13
- static readonly COMPILED_NAME = "definitions";
14
- /**
15
- * A closure fully implementing the model's defined `applyCasing` behavior with
16
- * the function parameter preset to the version-appropriate default.
17
- * `defaults.applyCasing` is captured as part of the closure.
18
- *
19
- * During compilation of some models (such as Trie-based wordlist templated models),
20
- * this closure will be directly used as part of searchTermToKey.
21
- *
22
- * In compiled code, this will instead be defined in-line as an autogenerated closure
23
- * using the other properties of the pseudoclosure.
24
- */
25
- applyCasing?: CasingFunction;
26
- /**
27
- * A closure fully implementing the model's defined `searchTermToKey` behavior
28
- * based upon the model's specified casing rules. The `applyCasing` closure is
29
- * itself captured within this closure.
30
- *
31
- * During compilation of some models (such as Trie-based wordlist templated models),
32
- * this closure will be directly utilized when compiling the lexicon.
33
- *
34
- * In compiled code, this will instead be defined in-line as an autogenerated closure
35
- * using the other properties of the pseudoclosure.
36
- */
37
- searchTermToKey?: WordformToKeySpec;
38
- /**
39
- * Contains embedded 'default' implementations that may be needed for
40
- * closures in the compiled version, annotated with the current version
41
- * of Developer.
42
- */
43
- private defaults;
44
- /**
45
- * Contains the model-specific definitions specified in the model's source.
46
- *
47
- * These definitions may expect `defaults.applyCasing` as a parameter in
48
- * their final closures.
49
- */
50
- private model;
51
- constructor(modelSource: LexicalModelSource);
52
- /**
53
- * Writes out a compiled JS version of the pseudoclosure, preserving all function
54
- * implementations.
55
- *
56
- * This should be written to the file within the same IIFE as the model but BEFORE
57
- * the model itself, as the model will need to refer to the definitions herein.
58
- */
59
- compileDefinitions(): string;
60
- /**
61
- * Compiles the model-options entry for `searchTermToKey` in reference to the
62
- * compiled pseudoclosure.
63
- */
64
- compileSearchTermToKey(): string;
65
- /**
66
- * Compiles the model-options entry for `applyCasing` in reference to the
67
- * compiled pseudoclosure.
68
- */
69
- compileApplyCasing(): string;
70
- }
1
+ /// <reference types="@keymanapp/models-types" />
2
+ import { LexicalModelSource, WordformToKeySpec } from "./lexical-model.js";
3
+ /**
4
+ * Processes certain defined model behaviors in such a way that the needed closures
5
+ * may be safely compiled to a JS file and loaded within the LMLayer.
6
+ *
7
+ * This is accomplished by writing out a 'pseudoclosure' within the model's IIFE,
8
+ * then used to build _actual_ closures at LMLayer load time. This 'pseudoclosure'
9
+ * will very closely match the organizational patterns of this class in order to
10
+ * facilitate the maintenance of this approach.
11
+ */
12
+ export declare class ModelDefinitions {
13
+ static readonly COMPILED_NAME = "definitions";
14
+ /**
15
+ * A closure fully implementing the model's defined `applyCasing` behavior with
16
+ * the function parameter preset to the version-appropriate default.
17
+ * `defaults.applyCasing` is captured as part of the closure.
18
+ *
19
+ * During compilation of some models (such as Trie-based wordlist templated models),
20
+ * this closure will be directly used as part of searchTermToKey.
21
+ *
22
+ * In compiled code, this will instead be defined in-line as an autogenerated closure
23
+ * using the other properties of the pseudoclosure.
24
+ */
25
+ applyCasing?: CasingFunction;
26
+ /**
27
+ * A closure fully implementing the model's defined `searchTermToKey` behavior
28
+ * based upon the model's specified casing rules. The `applyCasing` closure is
29
+ * itself captured within this closure.
30
+ *
31
+ * During compilation of some models (such as Trie-based wordlist templated models),
32
+ * this closure will be directly utilized when compiling the lexicon.
33
+ *
34
+ * In compiled code, this will instead be defined in-line as an autogenerated closure
35
+ * using the other properties of the pseudoclosure.
36
+ */
37
+ searchTermToKey?: WordformToKeySpec;
38
+ /**
39
+ * Contains embedded 'default' implementations that may be needed for
40
+ * closures in the compiled version, annotated with the current version
41
+ * of Developer.
42
+ */
43
+ private defaults;
44
+ /**
45
+ * Contains the model-specific definitions specified in the model's source.
46
+ *
47
+ * These definitions may expect `defaults.applyCasing` as a parameter in
48
+ * their final closures.
49
+ */
50
+ private model;
51
+ constructor(modelSource: LexicalModelSource);
52
+ /**
53
+ * Writes out a compiled JS version of the pseudoclosure, preserving all function
54
+ * implementations.
55
+ *
56
+ * This should be written to the file within the same IIFE as the model but BEFORE
57
+ * the model itself, as the model will need to refer to the definitions herein.
58
+ */
59
+ compileDefinitions(): string;
60
+ /**
61
+ * Compiles the model-options entry for `searchTermToKey` in reference to the
62
+ * compiled pseudoclosure.
63
+ */
64
+ compileSearchTermToKey(): string;
65
+ /**
66
+ * Compiles the model-options entry for `applyCasing` in reference to the
67
+ * compiled pseudoclosure.
68
+ */
69
+ compileApplyCasing(): string;
70
+ }
71
71
  //# sourceMappingURL=model-definitions.d.ts.map