triangle-utils 1.0.30 → 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/{index.js → Utils.js} +2 -0
- package/package.json +2 -2
- package/utils/Utils_Misc.js +13 -0
package/{index.js → Utils.js}
RENAMED
|
@@ -5,6 +5,7 @@ import Utils_DynamoDB from "./utils/Utils_DynamoDB.js"
|
|
|
5
5
|
import Utils_S3 from "./utils/Utils_S3.js"
|
|
6
6
|
import Utils_Bedrock from "./utils/Utils_Bedrock.js"
|
|
7
7
|
import Utils_Bee from "./utils/Utils_Bee.js"
|
|
8
|
+
import Utils_S3Vectors from "./utils/Utils_S3Vectors.js"
|
|
8
9
|
|
|
9
10
|
export default class Utils extends Utils_Misc {
|
|
10
11
|
constructor(config) {
|
|
@@ -14,6 +15,7 @@ export default class Utils extends Utils_Misc {
|
|
|
14
15
|
if (config.region !== undefined) {
|
|
15
16
|
this.dynamodb = new Utils_DynamoDB(config)
|
|
16
17
|
this.s3 = new Utils_S3(config)
|
|
18
|
+
this.s3vectors = new Utils_S3Vectors(config)
|
|
17
19
|
this.bedrock = new Utils_Bedrock(config)
|
|
18
20
|
}
|
|
19
21
|
if (config.scraping_bee_api_key !== undefined) {
|
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
|
}
|