-
Notifications
You must be signed in to change notification settings - Fork 654
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clear plugin #493
Comments
hey @lukeyt yeah, you can do this with let nlp2 = nlp.clone();
nlp.plugin({
words: {
trex: 'plugin'
}
});
nlp('trex').debug();
nlp2('trex').debug(); cheers |
Great - thank you @spencermountain - I will give it a go! |
I have tried this - however its not quite working as I expected after all - var nlp2 = nlp.clone(); nlp2.plugin({ will error with nlp2.plugin is not a function. What I had hoped was that I could use the approach above to clone nlp each time I wanted to load a different plugin, discarding the clone each time. But it seems clone does not clone the methods (or at least the plugin method)? |
yeah, rats. i was afraid of that. check out this issue, where someone reloads the library using require-reload. i can look at cleaning up the library clone stuff, but it's behind a backlog right now. |
Is there a solution to clear nlp plugin? |
hey @playground yes, |
so how would you do this? Ah, I was still on version 11, just upgraded to the latest 13.1.1 but getting nlp.plugin is not a function. |
yes, please read the v12 release notes and the documentation for .clone() |
There does not seem to be any way to clear a previously loaded plugin. For instance if I use the example:
`let plugin = {
words: {
'trex': 'Dinosaur'
},
tags: {
Dinosaur: {
isA: 'Animal'
}
}
};
nlp.plugin(plugin);
let doc = nlp('i saw a HUUUUGE trex');
doc.match('#Dinosaur').out('normal')// 'trex'`
There doesn't seem to be any way to unload 'plugin', so that
doc.match('#Dinosaur').out('normal')
Will always return 'trex'. Am I missing something? I want to be able to switch out a plugin and load another one without reloading the browser window.
The text was updated successfully, but these errors were encountered: