triangle-utils 1.0.31 → 1.0.32

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "triangle-utils",
3
- "version": "1.0.31",
3
+ "version": "1.0.32",
4
4
  "main": "Utils.js",
5
5
  "author": "",
6
6
  "license": "ISC",
@@ -137,4 +137,17 @@ export default class Utils_Misc {
137
137
  }
138
138
  return election_id
139
139
  }
140
+
141
+ get_chunk_indices(text_length, max_length = 2500, overlap = 50) {
142
+ const num_chunks = Math.ceil((text_length + overlap) / max_length)
143
+ const chunk_length = Math.ceil((text_length - overlap) / num_chunks + overlap)
144
+ const chunk_indices = []
145
+ for (let i = 0; i < num_chunks; i++) {
146
+ chunk_indices.push([
147
+ (chunk_length - overlap) * i,
148
+ (chunk_length - overlap) * i + chunk_length
149
+ ])
150
+ }
151
+ return chunk_indices
152
+ }
140
153
  }