mirror of
https://github.com/supermemoryai/supermemory.git
synced 2026-05-09 19:45:34 +00:00
commit
5af20f7b6f
2 changed files with 10 additions and 0 deletions
|
|
@ -1,5 +1,8 @@
|
|||
import nlp from "compromise";
|
||||
|
||||
/**
|
||||
* Split text into chunks of specified max size with some overlap for continuity.
|
||||
*/
|
||||
export default function chunkText(
|
||||
text: string,
|
||||
maxChunkSize: number,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,9 @@
|
|||
import { MersenneTwister19937, integer } from "random-js";
|
||||
|
||||
/**
|
||||
* Hashes a string to a 32-bit integer.
|
||||
* @param {string} seed - The input string to hash.
|
||||
*/
|
||||
function hashString(seed: string) {
|
||||
let hash = 0;
|
||||
for (let i = 0; i < seed.length; i++) {
|
||||
|
|
@ -10,6 +14,9 @@ function hashString(seed: string) {
|
|||
return hash;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns a funtion that generates same sequence of random numbers for a given seed between 0 and 1.
|
||||
*/
|
||||
export function seededRandom(seed: string) {
|
||||
const seedHash = hashString(seed);
|
||||
const engine = MersenneTwister19937.seed(seedHash);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue