Changes to nlp clone still affects original nlp
See original GitHub issueHi I’m trying to use multiple instances of nlp each with different plugins nlp.clone().extend()
. However, since the world
variable is global, any changes effect all nlp instances.
This can be seen by updating the following test and adding a copy of the first check to the end.
test('persistent-lexicon-change', function(t) {
let nlp2 = nlp.clone()
let doc = nlp('he is marko')
t.equal(doc.match('#Place+').length, 0, 'default-no-place')
t.equal(doc.match('#Person+').length, 1, 'default-one-person')
nlp2.extend((Doc, world) => {
world.addWords({
marko: 'Place',
})
})
doc = nlp2('he is marko')
t.equal(doc.match('#Place+').length, 1, 'now-one-place')
t.equal(doc.match('#Person+').length, 0, 'now-no-person')
// ....
// Tests fail here - original nlp should not be affected?
doc = nlp('he is marko')
t.equal(doc.match('#Place+').length, 0, 'default-no-place')
t.equal(doc.match('#Person+').length, 1, 'default-one-person')
t.end()
})
Am I misunderstanding the intention behind the clone()
function? Thanks in advance!
Issue Analytics
- State:
- Created 4 years ago
- Comments:16 (16 by maintainers)
Top Results From Across the Web
The Unreasonable Progress of Deep Neural Networks in ...
Big Changes in Natural Language Processing (NLP Due to Deep Learning. Humans have a lot of senses, and yet our sensory experiences are ......
Read more >Does not 'removing the stopwords' affect Natural Language ...
Removing such words from the text almost always changes the meaning drastically. The questions are: How reliable is removing stopwords? Does it ...
Read more >Natural language processing to identify the creation and ...
NLP to develop new measures for novelty and impact based on patent text. Validate improvement over measures based on patent classification and citations....
Read more >A Survey of Data Augmentation Approaches for NLP
Data augmentation has recently seen increased interest in NLP due to more work in low- resource domains, new tasks, and the popu-.
Read more >Natural language processing: an introduction - PMC - NCBI
NLP began in the 1950s as the intersection of artificial intelligence and linguistics. NLP was originally distinct from text information retrieval (IR), which ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
True, but we’d only do it because a person specifically chose to make a fresh instance, so their choosing to using more memory 😄.
Maybe we just fix clone to create a fresh instance with cloned world? Breaking change if people are using it currently with the assumption changes go backwards. So no global world, and no new worlds. Just selective cloning. Again can always have a Boolean for empty clone.
Haha 😄
.new
feels weird in JS. Also it’s not original or default considering it’s still uses the global world (could always add a Boolean for totally fresh)Shame clone is used 😄
copy()
?Edit: Maybe the global world thing is confusing. Maybe with argument or extra function the choices are: new nlp with world cloned from old one, or nlp with fresh world. No global extend/world.