segment-any-text / wtpsplit

Toolkit to segment text into sentences or other semantic units in a robust, efficient and adaptable way.
MIT License
665 stars 39 forks source link

node.js: unload wasm module #34

Closed loretoparisi closed 1 year ago

loretoparisi commented 3 years ago

Hello, thanks for this project! I'm trying to unload the wasm module in my node code:

const nnsplit = require("nnsplit");

function run() {
    nnsplit.NNSplit.new("/root/nnsplit_models/en/model.onnx")
    .then(splitter => {
        return splitter.split(["This is a test This is another test."])
    })
    .then(results => {
        let splits = results[0];
        console.log(splits.parts.map((x) => x.text)); // to log sentences, or x.parts to get the smaller subsplits
    })
    .catch(error => {
        console.error(error);
    })
}
run();

when running this script, the console keeps opened, since some resource must be released. I assume is the tractjs model that should be released in some way (likely using destroy())

Thanks

bminixhofer commented 3 years ago

Hi, thanks for this issue! Good point. A destroy method should definitely be added. Would you be willing to implement this? It should be fairly trivial.

I can do it myself but can't make any promises regarding the timeline as I'm currently focusing on nlprule.

bminixhofer commented 1 year ago

Hi, closing this as something I will not fix, I just released a major update to this library dropping Node.js support since I'm not really in the position to maintain it (feel free to use the Node.js version of nnsplit though, but I will unfortunately not maintain it).