@shaxpir/duiduidui-models 1.0.1 → 1.2.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.
Files changed (226) hide show
  1. package/dist/models/{content/ArrayView.d.ts → ArrayView.d.ts} +1 -1
  2. package/dist/models/{content/ArrayView.js → ArrayView.js} +14 -14
  3. package/dist/models/BayesianScore.d.ts +9 -0
  4. package/dist/models/BayesianScore.js +27 -0
  5. package/dist/models/{markup/ChangeModel.d.ts → ChangeModel.d.ts} +2 -3
  6. package/dist/models/{markup/ChangeModel.js → ChangeModel.js} +20 -10
  7. package/dist/models/{content/Content.d.ts → Content.d.ts} +9 -10
  8. package/dist/models/{content/Content.js → Content.js} +2 -6
  9. package/dist/models/{content/ContentKind.d.ts → ContentKind.d.ts} +3 -0
  10. package/dist/models/{content/ContentKind.js → ContentKind.js} +5 -1
  11. package/dist/models/{content/Device.d.ts → Device.d.ts} +15 -7
  12. package/dist/models/{content/Device.js → Device.js} +14 -18
  13. package/dist/models/Hanzi.d.ts +15 -0
  14. package/dist/models/{content/Manifest.d.ts → Manifest.d.ts} +7 -3
  15. package/dist/models/{content/Manifest.js → Manifest.js} +12 -8
  16. package/dist/models/{content/Media.d.ts → Media.d.ts} +2 -3
  17. package/dist/models/{content/Media.js → Media.js} +4 -5
  18. package/dist/models/{content/Metric.d.ts → Metric.d.ts} +2 -3
  19. package/dist/models/{content/Metric.js → Metric.js} +18 -20
  20. package/dist/models/{content/Model.d.ts → Model.d.ts} +3 -5
  21. package/dist/models/{content/Model.js → Model.js} +5 -6
  22. package/dist/models/{markup/Operation.d.ts → Operation.d.ts} +2 -5
  23. package/dist/models/{markup/Operation.js → Operation.js} +30 -25
  24. package/dist/models/Phrase.d.ts +39 -0
  25. package/dist/models/{content/Profile.d.ts → Profile.d.ts} +1 -2
  26. package/dist/models/{content/Profile.js → Profile.js} +7 -9
  27. package/dist/models/Progress.d.ts +26 -0
  28. package/dist/models/Progress.js +39 -0
  29. package/dist/models/Review.d.ts +14 -0
  30. package/dist/models/{content/Session.d.ts → Session.d.ts} +7 -15
  31. package/dist/models/Session.js +103 -0
  32. package/dist/models/Term.d.ts +36 -0
  33. package/dist/models/Term.js +82 -0
  34. package/dist/models/User.d.ts +32 -0
  35. package/dist/models/User.js +65 -0
  36. package/dist/models/Workspace.d.ts +37 -0
  37. package/dist/models/Workspace.js +94 -0
  38. package/dist/models/index.d.ts +22 -2
  39. package/dist/models/index.js +22 -2
  40. package/dist/repo/PermissiveJson1.d.ts +16 -16
  41. package/dist/repo/PermissiveJson1.js +17 -7
  42. package/dist/repo/ShareSync.d.ts +6 -6
  43. package/dist/repo/ShareSync.js +26 -19
  44. package/dist/repo/index.d.ts +1 -0
  45. package/dist/repo/index.js +1 -0
  46. package/dist/util/Encryption.d.ts +1 -1
  47. package/dist/util/index.d.ts +0 -6
  48. package/dist/util/index.js +0 -6
  49. package/lib/models/{content/ArrayView.ts → ArrayView.ts} +2 -2
  50. package/lib/models/BayesianScore.ts +32 -0
  51. package/lib/models/{markup/ChangeModel.ts → ChangeModel.ts} +3 -4
  52. package/lib/models/{content/Content.ts → Content.ts} +15 -18
  53. package/lib/models/{content/ContentKind.ts → ContentKind.ts} +6 -1
  54. package/lib/models/{content/Device.ts → Device.ts} +26 -22
  55. package/lib/models/Hanzi.ts +16 -0
  56. package/lib/models/{content/Manifest.ts → Manifest.ts} +15 -6
  57. package/lib/models/{content/Media.ts → Media.ts} +3 -4
  58. package/lib/models/Metric.ts +233 -0
  59. package/lib/models/{content/Model.ts → Model.ts} +4 -6
  60. package/lib/models/{markup/Operation.ts → Operation.ts} +6 -16
  61. package/lib/models/{content/Permissions.ts → Permissions.ts} +0 -2
  62. package/lib/models/Phrase.ts +53 -0
  63. package/lib/models/{content/Profile.ts → Profile.ts} +4 -6
  64. package/lib/models/Progress.ts +66 -0
  65. package/lib/models/Review.ts +18 -0
  66. package/lib/models/Session.ts +140 -0
  67. package/lib/models/Term.ts +139 -0
  68. package/lib/models/User.ts +97 -0
  69. package/lib/models/Workspace.ts +129 -0
  70. package/lib/models/index.ts +22 -2
  71. package/lib/repo/ShareSync.ts +9 -13
  72. package/lib/repo/index.ts +1 -0
  73. package/lib/util/Encryption.ts +1 -1
  74. package/lib/util/index.ts +0 -6
  75. package/package.json +4 -15
  76. package/dist/models/OutboundMessage.d.ts +0 -18
  77. package/dist/models/OutboundMessage.js +0 -25
  78. package/dist/models/content/Activity.d.ts +0 -10
  79. package/dist/models/content/Billing.d.ts +0 -144
  80. package/dist/models/content/Billing.js +0 -418
  81. package/dist/models/content/Book.d.ts +0 -77
  82. package/dist/models/content/Book.js +0 -407
  83. package/dist/models/content/Category.d.ts +0 -16
  84. package/dist/models/content/Category.js +0 -20
  85. package/dist/models/content/Checkpointable.d.ts +0 -21
  86. package/dist/models/content/Checkpointable.js +0 -156
  87. package/dist/models/content/Comment.d.ts +0 -19
  88. package/dist/models/content/Comment.js +0 -53
  89. package/dist/models/content/ConceptArt.d.ts +0 -31
  90. package/dist/models/content/ConceptArt.js +0 -84
  91. package/dist/models/content/Context.d.ts +0 -28
  92. package/dist/models/content/Context.js +0 -162
  93. package/dist/models/content/DevEnv.d.ts +0 -5
  94. package/dist/models/content/DevEnv.js +0 -9
  95. package/dist/models/content/Dictionary.d.ts +0 -31
  96. package/dist/models/content/Dictionary.js +0 -5
  97. package/dist/models/content/DictionaryEntry.d.ts +0 -20
  98. package/dist/models/content/DictionaryEntry.js +0 -2
  99. package/dist/models/content/ElasticModel.d.ts +0 -149
  100. package/dist/models/content/ElasticModel.js +0 -179
  101. package/dist/models/content/Environment.d.ts +0 -61
  102. package/dist/models/content/Environment.js +0 -124
  103. package/dist/models/content/ExportOptions.d.ts +0 -64
  104. package/dist/models/content/ExportOptions.js +0 -213
  105. package/dist/models/content/Folder.d.ts +0 -16
  106. package/dist/models/content/Folder.js +0 -33
  107. package/dist/models/content/Fragment.d.ts +0 -54
  108. package/dist/models/content/Fragment.js +0 -181
  109. package/dist/models/content/Hanzi.d.ts +0 -21
  110. package/dist/models/content/HighlightRule.d.ts +0 -9
  111. package/dist/models/content/HighlightRule.js +0 -2
  112. package/dist/models/content/Migration.d.ts +0 -68
  113. package/dist/models/content/Migration.js +0 -155
  114. package/dist/models/content/Phrase.d.ts +0 -8
  115. package/dist/models/content/Placeholder.d.ts +0 -8
  116. package/dist/models/content/Placeholder.js +0 -36
  117. package/dist/models/content/RichText.d.ts +0 -58
  118. package/dist/models/content/RichText.js +0 -79
  119. package/dist/models/content/Session.js +0 -173
  120. package/dist/models/content/Speech.d.ts +0 -67
  121. package/dist/models/content/Speech.js +0 -97
  122. package/dist/models/content/Stub.d.ts +0 -24
  123. package/dist/models/content/Stub.js +0 -179
  124. package/dist/models/content/Time.d.ts +0 -56
  125. package/dist/models/content/Time.js +0 -295
  126. package/dist/models/content/User.d.ts +0 -36
  127. package/dist/models/content/User.js +0 -95
  128. package/dist/models/content/Workspace.d.ts +0 -71
  129. package/dist/models/content/Workspace.js +0 -237
  130. package/dist/models/content/index.d.ts +0 -17
  131. package/dist/models/content/index.js +0 -34
  132. package/dist/models/legacy/LegacyBodyFormat.d.ts +0 -9
  133. package/dist/models/legacy/LegacyBodyFormat.js +0 -2
  134. package/dist/models/legacy/LegacyComment.d.ts +0 -12
  135. package/dist/models/legacy/LegacyComment.js +0 -2
  136. package/dist/models/legacy/LegacyContent.d.ts +0 -53
  137. package/dist/models/legacy/LegacyContent.js +0 -55
  138. package/dist/models/legacy/LegacyConversion.d.ts +0 -55
  139. package/dist/models/legacy/LegacyConversion.js +0 -401
  140. package/dist/models/legacy/LegacyFragment.d.ts +0 -21
  141. package/dist/models/legacy/LegacyFragment.js +0 -2
  142. package/dist/models/legacy/LegacyLocator.d.ts +0 -8
  143. package/dist/models/legacy/LegacyLocator.js +0 -31
  144. package/dist/models/legacy/LegacyOutboundMessage.d.ts +0 -16
  145. package/dist/models/legacy/LegacyOutboundMessage.js +0 -13
  146. package/dist/models/legacy/LegacyPicture.d.ts +0 -14
  147. package/dist/models/legacy/LegacyPicture.js +0 -2
  148. package/dist/models/legacy/LegacyProfile.d.ts +0 -9
  149. package/dist/models/legacy/LegacyProfile.js +0 -2
  150. package/dist/models/legacy/LegacySession.d.ts +0 -41
  151. package/dist/models/legacy/LegacySession.js +0 -35
  152. package/dist/models/legacy/LegacyStory.d.ts +0 -23
  153. package/dist/models/legacy/LegacyStory.js +0 -2
  154. package/dist/models/legacy/LegacyStub.d.ts +0 -15
  155. package/dist/models/legacy/LegacyStub.js +0 -2
  156. package/dist/models/legacy/LegacyTransaction.d.ts +0 -14
  157. package/dist/models/legacy/LegacyTransaction.js +0 -49
  158. package/dist/models/legacy/LegacyUser.d.ts +0 -28
  159. package/dist/models/legacy/LegacyUser.js +0 -32
  160. package/dist/models/legacy/LegacyWorkspace.d.ts +0 -23
  161. package/dist/models/legacy/LegacyWorkspace.js +0 -6
  162. package/dist/models/legacy/index.d.ts +0 -15
  163. package/dist/models/legacy/index.js +0 -32
  164. package/dist/models/markup/BodyFormat.d.ts +0 -14
  165. package/dist/models/markup/BodyFormat.js +0 -190
  166. package/dist/models/markup/DeltaOps.d.ts +0 -5
  167. package/dist/models/markup/DeltaOps.js +0 -74
  168. package/dist/models/markup/HtmlMarkup.d.ts +0 -4
  169. package/dist/models/markup/HtmlMarkup.js +0 -21
  170. package/dist/models/markup/index.d.ts +0 -4
  171. package/dist/models/markup/index.js +0 -21
  172. package/dist/util/Async.d.ts +0 -8
  173. package/dist/util/Async.js +0 -18
  174. package/dist/util/Base62.d.ts +0 -6
  175. package/dist/util/Base62.js +0 -47
  176. package/dist/util/BinarySearch.d.ts +0 -7
  177. package/dist/util/BinarySearch.js +0 -46
  178. package/dist/util/CachingHasher.d.ts +0 -8
  179. package/dist/util/CachingHasher.js +0 -41
  180. package/dist/util/Color.d.ts +0 -32
  181. package/dist/util/Color.js +0 -204
  182. package/dist/util/Dispatch.d.ts +0 -15
  183. package/dist/util/Dispatch.js +0 -79
  184. package/dist/util/EditDistance.d.ts +0 -13
  185. package/dist/util/EditDistance.js +0 -184
  186. package/dist/util/NumberFormat.d.ts +0 -14
  187. package/dist/util/NumberFormat.js +0 -224
  188. package/dist/util/Struct.d.ts +0 -4
  189. package/dist/util/Struct.js +0 -15
  190. package/dist/util/Template.d.ts +0 -16
  191. package/dist/util/Template.js +0 -128
  192. package/dist/util/Text.d.ts +0 -45
  193. package/dist/util/Text.js +0 -243
  194. package/dist/util/Tuples.d.ts +0 -9
  195. package/dist/util/Tuples.js +0 -135
  196. package/dist/util/Validate.d.ts +0 -4
  197. package/dist/util/Validate.js +0 -11
  198. package/dist/util/Vocabulary.d.ts +0 -3
  199. package/dist/util/Vocabulary.js +0 -35
  200. package/lib/models/content/Billing.ts +0 -558
  201. package/lib/models/content/DevEnv.ts +0 -5
  202. package/lib/models/content/DictionaryEntry.ts +0 -22
  203. package/lib/models/content/Hanzi.ts +0 -25
  204. package/lib/models/content/Phrase.ts +0 -10
  205. package/lib/models/content/Time.ts +0 -328
  206. package/lib/models/content/User.ts +0 -130
  207. package/lib/models/content/index.ts +0 -19
  208. package/lib/models/markup/DeltaOps.ts +0 -71
  209. package/lib/models/markup/index.ts +0 -6
  210. package/lib/util/Base62.ts +0 -47
  211. package/lib/util/CachingHasher.ts +0 -38
  212. package/lib/util/Dispatch.ts +0 -92
  213. package/lib/util/NumberFormat.ts +0 -194
  214. package/lib/util/Struct.ts +0 -14
  215. package/lib/util/Tuples.ts +0 -131
  216. /package/dist/models/{content/GeoLocation.d.ts → GeoLocation.d.ts} +0 -0
  217. /package/dist/models/{content/GeoLocation.js → GeoLocation.js} +0 -0
  218. /package/dist/models/{content/Hanzi.js → Hanzi.js} +0 -0
  219. /package/dist/models/{content/Permissions.d.ts → Permissions.d.ts} +0 -0
  220. /package/dist/models/{content/Permissions.js → Permissions.js} +0 -0
  221. /package/dist/models/{content/Phrase.js → Phrase.js} +0 -0
  222. /package/dist/models/{content/Activity.js → Review.js} +0 -0
  223. /package/dist/{models/markup → repo}/TextEditOps.d.ts +0 -0
  224. /package/dist/{models/markup → repo}/TextEditOps.js +0 -0
  225. /package/lib/models/{content/GeoLocation.ts → GeoLocation.ts} +0 -0
  226. /package/lib/{models/markup → repo}/TextEditOps.ts +0 -0
package/dist/util/Text.js DELETED
@@ -1,243 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.Text = void 0;
27
- const pluralize = __importStar(require("pluralize"));
28
- class Text {
29
- static countWords(text) {
30
- let wordCount = 0;
31
- if (text.length && text.length > 0) {
32
- let match;
33
- while ((match = Text.WORD_REGEX.exec(text)) !== null) {
34
- wordCount++;
35
- }
36
- }
37
- return wordCount;
38
- }
39
- static tokenizeWords(text, keepSeparators) {
40
- let chunks = [];
41
- let prevMatchEnd = 0;
42
- if (text.length && text.length > 0) {
43
- let match;
44
- while ((match = Text.WORD_REGEX.exec(text)) !== null) {
45
- let matchText = match[0];
46
- let matchStart = match.index;
47
- let matchEnd = matchStart + matchText.length;
48
- if (keepSeparators && matchStart - prevMatchEnd > 0) {
49
- let prevText = text.substring(prevMatchEnd, matchStart);
50
- chunks.push(prevText);
51
- }
52
- chunks.push(matchText);
53
- prevMatchEnd = matchEnd;
54
- }
55
- }
56
- if (keepSeparators && prevMatchEnd < text.length) {
57
- let textAfterFinalWord = text.substring(prevMatchEnd);
58
- chunks.push(textAfterFinalWord);
59
- }
60
- return chunks;
61
- }
62
- static getUniqueWords(text) {
63
- let words = [];
64
- let map = {};
65
- let match;
66
- while ((match = Text.WORD_REGEX.exec(text)) !== null) {
67
- let word = match[0];
68
- if (!map.hasOwnProperty(word)) {
69
- map[word] = true;
70
- words.push(word);
71
- }
72
- }
73
- return words;
74
- }
75
- static capitalizeWords(text) {
76
- return text.toLowerCase().replace(/\b[a-z]/g, function (letter) {
77
- return letter.toUpperCase();
78
- });
79
- }
80
- static normalizeText(text) {
81
- text = Text.normalizeDashes(text);
82
- text = Text.normalizeApostrophes(text);
83
- return text;
84
- }
85
- static normalizeDashes(text) {
86
- return text.replace(/[\u2010-\u2015]/g, "-");
87
- }
88
- static makeCurlyQuotes(text) {
89
- text = text.replace(/(^|\s+)"/gmu, "$1“");
90
- text = text.replace(/"(\\s+|$)/gmu, "”$1");
91
- text = text.replace(/"$/gmu, "”");
92
- text = text.replace(/(\p{L})"([.,:;?!)])/gmu, "$1”$2");
93
- text = text.replace(/(^|\s+)'/gmu, "$1‘");
94
- text = text.replace(/'/gmu, "’");
95
- return text;
96
- }
97
- static normalizeApostrophes(text) {
98
- return text.replace(/[\u2018\u2019]/g, "'");
99
- }
100
- static removeDashes(text) {
101
- return text.replace(/[\-\u2010-\u2015]/g, "");
102
- }
103
- static removeApostrophes(text) {
104
- return text.replace(/['\u2018\u2019]/g, "");
105
- }
106
- static removePosessive(text) {
107
- return Text.normalizeApostrophes(text).replace(/'s?$/, "");
108
- }
109
- static removePlural(word) {
110
- return pluralize.singular(word);
111
- }
112
- static removeSuffixes(word, suffixes) {
113
- for (let i = 0, len = suffixes.length; i < len; i++) {
114
- let suffix = suffixes[i];
115
- // We will only remove suffixes from root words having three or more letters.
116
- if (word.length > suffix.length + 3) {
117
- // The suffix must occur at the end
118
- let suffixStart = word.indexOf(suffix);
119
- if (suffixStart === word.length - suffix.length) {
120
- // Remove the actual suffix.
121
- word = word.substring(0, suffixStart);
122
- // If the word ends in a duble-consonant, remove the last char too.
123
- let lastLetter = word.charAt(word.length - 1);
124
- let prevLastLetter = word.charAt(word.length - 2);
125
- if (lastLetter === prevLastLetter) {
126
- word = word.substring(0, word.length - 1);
127
- }
128
- }
129
- }
130
- }
131
- return word;
132
- }
133
- static stripNonWordChars(text) {
134
- return text.replace(Text.NON_WORD_CHARS, "");
135
- }
136
- static endsWithAnySuffix(text, suffixes) {
137
- for (let i = 0, len = suffixes.length; i < len; i++) {
138
- let suffix = suffixes[i];
139
- if (text.lastIndexOf(suffix) === text.length - suffix.length) {
140
- return true;
141
- }
142
- }
143
- return false;
144
- }
145
- static endsWithWordChar(text) {
146
- const lastChar = text.charAt(text.length - 1);
147
- return text.length > 0 && !Text.isPunctuation(lastChar) && Text.isWordChar(lastChar);
148
- }
149
- static isWordChar(c) {
150
- return c.length === 1 &&
151
- (c >= 'a' && c <= 'z') ||
152
- (c >= 'A' && c <= 'Z') ||
153
- (c >= '0' && c <= '9') ||
154
- "-'‘’ÀÈÌÒÙàèìòùÁÉÍÓÚÝáéíóúýÂÊÎÔÛâêîôûÃÑÕãñõÄËÏÖÜäëïöüçÇߨøÅ寿ÞþÐðĀĒĪŌŪȲǢāēīōūȳǣ".indexOf(c) >= 0;
155
- }
156
- static isAllWordChars(text) {
157
- return Text.allCharsMatch(text, Text.isWordChar);
158
- }
159
- static hasAnyWordChars(text) {
160
- return Text.anyCharsMatch(text, Text.isWordChar);
161
- }
162
- static isPunctuation(c) {
163
- return c.length === 1 && ".,'?!-:;|\\\"<>/[]{}()_+=@#$%^&*".indexOf(c) >= 0;
164
- }
165
- static isAllPunctuation(text) {
166
- return Text.allCharsMatch(text, Text.isPunctuation);
167
- }
168
- static hasAnyPunctuation(text) {
169
- return Text.anyCharsMatch(text, Text.isPunctuation);
170
- }
171
- static isWhitspace(c) {
172
- return c.length === 1 && " \t\r\n".indexOf(c) >= 0;
173
- }
174
- static isAllWhitspace(text) {
175
- return Text.allCharsMatch(text, Text.isWhitspace);
176
- }
177
- static hasAnyWhitspace(text) {
178
- return Text.anyCharsMatch(text, Text.isWhitspace);
179
- }
180
- static isDigit(c) {
181
- return c.length === 1 && c >= '0' && c <= '9';
182
- }
183
- static isAllDigits(text) {
184
- return Text.allCharsMatch(text, Text.isDigit);
185
- }
186
- static hasAnyDigits(text) {
187
- return Text.anyCharsMatch(text, Text.isDigit);
188
- }
189
- static isCapitalLetter(c) {
190
- return c.length === 1 && (c >= 'A' && c <= 'Z') || "ÀÈÌÒÙÁÉÍÓÚÝÂÊÎÔÛÃÑÕÄËÏÖÜÇߨůÞÐĀĒĪŌŪȲǢ".indexOf(c) >= 0;
191
- }
192
- static isAllCapitalLetters(text) {
193
- return Text.allCharsMatch(text, Text.isCapitalLetter);
194
- }
195
- static hasAnyCapitalLetters(text) {
196
- return Text.anyCharsMatch(text, Text.isCapitalLetter);
197
- }
198
- static allCharsMatch(text, predicate) {
199
- if (text.length > 0) {
200
- for (let i = 0, len = text.length; i < len; i++) {
201
- let c = text.charAt(i);
202
- if (!predicate(c)) {
203
- return false;
204
- }
205
- }
206
- return true;
207
- }
208
- return false;
209
- }
210
- static anyCharsMatch(text, predicate) {
211
- for (let i = 0, len = text.length; i < len; i++) {
212
- let c = text.charAt(i);
213
- if (predicate(c)) {
214
- return true;
215
- }
216
- }
217
- return false;
218
- }
219
- }
220
- exports.Text = Text;
221
- Text.WORD_START_CHAR_CLASS = "[a-zA-Z0-9B̌b̌F̌f̌ĞğJ̌M̌m̌ńọP̌p̌Q̌q̌V̌v̌W̌w̌X̌x̌Y̌y̌ßÀàÁáÂâÃãÄäÅ寿ÇçÈèÉéÊêÊ̌ê̌ËëÌìÍíÎîÏïİi̇ıÐðÑñÒòÓóÔôÕõÖöØøÙùÚúÛûÜüÝýÞþĀāČčČ̣č̣ĎďĒēĚěĪīĽľŁłŇňŌōŘřŘ̩ř̩ŞşŠšŤťŪūŻżŽžǍǎǏǐǑǒǓǔǙǚǢǣǦǧǨǩǮǯǰȘșȞȟȲȳṦṧẾếỄễỌọ́]";
222
- Text.WORD_MIDDLE_CHAR_CLASS = "[a-zA-Z0-9B̌b̌F̌f̌ĞğJ̌M̌m̌ńọP̌p̌Q̌q̌V̌v̌W̌w̌X̌x̌Y̌y̌ßÀàÁáÂâÃãÄäÅ寿ÇçÈèÉéÊêÊ̌ê̌ËëÌìÍíÎîÏïİi̇ıÐðÑñÒòÓóÔôÕõÖöØøÙùÚúÛûÜüÝýÞþĀāČčČ̣č̣ĎďĒēĚěĪīĽľŁłŇňŌōŘřŘ̩ř̩ŞşŠšŤťŪūŻżŽžǍǎǏǐǑǒǓǔǙǚǢǣǦǧǨǩǮǯǰȘșȞȟȲȳṦṧẾếỄễỌọ́\\.\\-]";
223
- Text.WORD_END_CHAR_CLASS = "[a-zA-Z0-9B̌b̌F̌f̌ĞğJ̌M̌m̌ńọP̌p̌Q̌q̌V̌v̌W̌w̌X̌x̌Y̌y̌ßÀàÁáÂâÃãÄäÅ寿ÇçÈèÉéÊêÊ̌ê̌ËëÌìÍíÎîÏïİi̇ıÐðÑñÒòÓóÔôÕõÖöØøÙùÚúÛûÜüÝýÞþĀāČčČ̣č̣ĎďĒēĚěĪīĽľŁłŇňŌōŘřŘ̩ř̩ŞşŠšŤťŪūŻżŽžǍǎǏǐǑǒǓǔǙǚǢǣǦǧǨǩǮǯǰȘșȞȟȲȳṦṧẾếỄễỌọ́]";
224
- Text.APOSTROPHE_CHAR_CLASS = "[\u0027\u2018\u2019]";
225
- Text.WORD_POST_APOS_CHAR_CLASS = "[a-zA-ZB̌b̌F̌Ğğf̌J̌M̌m̌ńọP̌p̌Q̌q̌V̌v̌W̌w̌X̌x̌Y̌y̌ßÀàÁáÂâÃãÄäÅ寿ÇçÈèÉéÊêÊ̌ê̌ËëÌìÍíÎîÏïİi̇ıÐðÑñÒòÓóÔôÕõÖöØøÙùÚúÛûÜüÝýÞþĀāČčČ̣č̣ĎďĒēĚěĪīĽľŁłŇňŌōŘřŘ̩ř̩ŞşŠšŤťŪūŻżŽžǍǎǏǐǑǒǓǔǙǚǢǣǦǧǨǩǮǯǰȘșȞȟȲȳṦṧẾếỄễỌọ́]";
226
- // Since we need to match on unicode text, we can't use the normal \b word boundary assertion,
227
- // because it only matches on ASCII word boundaries. Instead, we use our own word boundary
228
- // assertions that match on unicode word boundaries, based on negative lookbehind and lookahead.
229
- Text.WORD_BOUNDARY_BEFORE = "(?<![\\p{Letter}\\p{Number}])";
230
- Text.WORD_BOUNDARY_AFTER = "(?![\\p{Letter}\\p{Number}])";
231
- Text.WORD_PATTERN = Text.WORD_BOUNDARY_BEFORE +
232
- Text.WORD_START_CHAR_CLASS +
233
- "(?:" +
234
- Text.WORD_MIDDLE_CHAR_CLASS + "*" +
235
- Text.WORD_END_CHAR_CLASS +
236
- ")?" +
237
- "(?:" +
238
- Text.APOSTROPHE_CHAR_CLASS +
239
- Text.WORD_POST_APOS_CHAR_CLASS + "+" +
240
- ")*" +
241
- Text.WORD_BOUNDARY_AFTER;
242
- Text.WORD_REGEX = new RegExp(Text.WORD_PATTERN, "gu");
243
- Text.NON_WORD_CHARS = /[^a-zA-Z0-9B̌b̌F̌f̌ĞğJ̌M̌m̌ńọP̌p̌Q̌q̌V̌v̌W̌w̌X̌x̌Y̌y̌ßÀàÁáÂâÃãÄäÅ寿ÇçÈèÉéÊêÊ̌ê̌ËëÌìÍíÎîÏïİi̇ıÐðÑñÒòÓóÔôÕõÖöØøÙùÚúÛûÜüÝýÞþĀāČčČ̣č̣ĎďĒēĚěĪīĽľŁłŇňŌōŘřŘ̩ř̩ŞşŠšŤťŪūŻżŽžǍǎǏǐǑǒǓǔǙǚǢǣǦǧǨǩǮǯǰȘșȞȟȲȳṦṧẾếỄễỌọ́]/g;
@@ -1,9 +0,0 @@
1
- import { JsonPath, PathVal } from "../models/markup/Operation";
2
- export declare class Tuples {
3
- static of(value: any): PathVal[];
4
- static stringifyPath(prefix: string, path: JsonPath): string;
5
- private static collectFromArray;
6
- private static collectFromObject;
7
- private static collectTuplesAtPath;
8
- private static sort;
9
- }
@@ -1,135 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Tuples = void 0;
4
- const Struct_1 = require("./Struct");
5
- class Tuples {
6
- static of(value) {
7
- let tuples = [];
8
- if (Array.isArray(value)) {
9
- Tuples.collectFromArray(tuples, [], value);
10
- }
11
- else if (value !== null) {
12
- const type = typeof (value);
13
- if (type === "object") {
14
- Tuples.collectFromObject(tuples, [], value);
15
- }
16
- }
17
- return Tuples.sort(tuples);
18
- }
19
- static stringifyPath(prefix, path) {
20
- if (prefix == null || prefix.trim() == "") {
21
- prefix = "$";
22
- }
23
- if (!prefix.startsWith("$")) {
24
- prefix = "$" + prefix;
25
- }
26
- let str = prefix;
27
- for (let i = 0; i < path.length; i++) {
28
- let pathItem = path[i];
29
- if (typeof (pathItem) === 'string') {
30
- str += '.' + pathItem;
31
- }
32
- else {
33
- str += '[' + pathItem + ']';
34
- }
35
- }
36
- return str;
37
- }
38
- static collectFromArray(tuples, path, array) {
39
- for (let i = 0; i < array.length; i++) {
40
- path.push(i);
41
- let item = array[i];
42
- Tuples.collectTuplesAtPath(tuples, path, item);
43
- path.pop();
44
- }
45
- }
46
- static collectFromObject(tuples, path, object) {
47
- const keys = Object.keys(object);
48
- for (let i = 0; i < keys.length; i++) {
49
- const key = keys[i];
50
- if (object.hasOwnProperty(key)) {
51
- path.push(key);
52
- let item = object[key];
53
- Tuples.collectTuplesAtPath(tuples, path, item);
54
- path.pop();
55
- }
56
- }
57
- }
58
- static collectTuplesAtPath(tuples, path, item) {
59
- if (Struct_1.Struct.equals(item, {}) || Struct_1.Struct.equals(item, [])) {
60
- tuples.push({ path: Struct_1.Struct.clone(path), val: item });
61
- }
62
- else if (Array.isArray(item)) {
63
- Tuples.collectFromArray(tuples, path, item);
64
- }
65
- else {
66
- const type = typeof (item);
67
- if (item === null ||
68
- type === "string" ||
69
- type === "number" ||
70
- type === "boolean") {
71
- tuples.push({ path: Struct_1.Struct.clone(path), val: item });
72
- }
73
- else if (type === "function" || type == "symbol" || type == "bigint" || type === "undefined") {
74
- throw new Error(`can't create tuple from '${type}' item at path: ${JSON.stringify(path)}`);
75
- }
76
- else {
77
- Tuples.collectFromObject(tuples, path, item);
78
- }
79
- }
80
- }
81
- static sort(tuples) {
82
- // NOTE: tuples are sorted ONLY according to their PATH. The val is never considered. This is
83
- // because we assume there can never be two identical paths anyhow, in a valid JSON tuple array.
84
- tuples.sort((a, b) => {
85
- const aPath = a.path;
86
- const bPath = b.path;
87
- const aPathLength = aPath.length;
88
- const bPathLength = bPath.length;
89
- let length = Math.min(aPathLength, bPathLength);
90
- for (let i = 0; i < length; i++) {
91
- const aPathElement = aPath[i];
92
- const bPathElement = bPath[i];
93
- const aPathElementType = typeof (aPathElement);
94
- const bPathElementType = typeof (bPathElement);
95
- let comparison = 0;
96
- if (aPathElementType === "string" && bPathElementType === "string") {
97
- const aString = aPathElement;
98
- const bString = bPathElement;
99
- comparison = aString.localeCompare(bString);
100
- }
101
- else if (aPathElementType === "number" && bPathElementType === "number") {
102
- const aNumber = aPathElement;
103
- const bNumber = bPathElement;
104
- if (aNumber < bNumber) {
105
- comparison = -1;
106
- }
107
- else if (aNumber > bNumber) {
108
- comparison = 1;
109
- }
110
- }
111
- else if (aPathElementType === "string" && bPathElementType === "number") {
112
- comparison = -1;
113
- }
114
- else if (aPathElementType === "number" && bPathElementType === "string") {
115
- comparison = 1;
116
- }
117
- if (comparison !== 0) {
118
- return comparison;
119
- }
120
- }
121
- if (aPathLength < bPathLength) {
122
- return -1;
123
- }
124
- else if (aPathLength > bPathLength) {
125
- return 1;
126
- }
127
- else {
128
- // If we never do want to incorporate value comparisons into sort order, this is where we'd do it.
129
- return 0;
130
- }
131
- });
132
- return tuples;
133
- }
134
- }
135
- exports.Tuples = Tuples;
@@ -1,4 +0,0 @@
1
- export declare class Validate {
2
- private static EMAIL_PATTERN;
3
- static email(text: string): boolean;
4
- }
@@ -1,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Validate = void 0;
4
- class Validate {
5
- static email(text) {
6
- return Validate.EMAIL_PATTERN.test(text);
7
- }
8
- }
9
- exports.Validate = Validate;
10
- // COPIED FROM HERE: http://emailregex.com
11
- Validate.EMAIL_PATTERN = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
@@ -1,3 +0,0 @@
1
- export declare class Vocabulary {
2
- static calculateSizePercentile(wordCount: number, uniqueCount: number): number;
3
- }
@@ -1,35 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Vocabulary = void 0;
4
- class Vocabulary {
5
- static calculateSizePercentile(wordCount, uniqueCount) {
6
- // This function returns a percentile value (between 0.01 and 0.99) telling us the relative
7
- // size of this vocabulary (the unique word count), based on the expected size of the vocabulary
8
- // for a body of prose with the designated total word count. We start by creating three different
9
- // parametric estimates (lo, mid, hi) representing the 10th percentile, 50th percentile, and 90th
10
- // percentile. Then we use the actual unique word count to interpolate between these values. The
11
- // coefficients in these formulae were generated by performing a power-law regression over 9570
12
- // works of fiction, having various different lengths and vocabulary sizes, and then adjusting
13
- // the values to satisfy the 10th, 50th, and 90th percentile counts. Finally, although this
14
- // parametric model is more accurate in estimating actual vocabulary sizes, it's also handy
15
- // to remember this convenient shorthand: "vocabulary size scales proportionally to the square
16
- // root of the total word count".
17
- let coefficient = 9.3676;
18
- let loEstimate = coefficient * Math.pow(wordCount, 0.5701);
19
- let midEstimate = coefficient * Math.pow(wordCount, 0.5884);
20
- let hiEstimate = coefficient * Math.pow(wordCount, 0.6070);
21
- if (uniqueCount < loEstimate - ((midEstimate - loEstimate) / 4)) {
22
- return 0.01;
23
- }
24
- else if (uniqueCount > hiEstimate + ((hiEstimate - midEstimate) / 4)) {
25
- return 0.99;
26
- }
27
- else if (uniqueCount < midEstimate) {
28
- return 0.1 + (0.4 * (uniqueCount - loEstimate) / (midEstimate - loEstimate));
29
- }
30
- else {
31
- return 0.9 - (0.4 * (hiEstimate - uniqueCount) / (hiEstimate - midEstimate));
32
- }
33
- }
34
- }
35
- exports.Vocabulary = Vocabulary;