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 +1 -1
- package/utils/Utils_Misc.js +13 -0
package/package.json
CHANGED
package/utils/Utils_Misc.js
CHANGED
|
@@ -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
|
}
|