fix sweep unTag with an array, fixes #1009
This commit is contained in:
1 parent
75a5b5e4de
commit
7a829e015b
2 files changed
+20
-1
No files matched your search
@@ -47,7 +47,8 @@ const tagger = function (list, document, world) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (todo.unTag !== undefined) {
|
if (todo.unTag !== undefined) {
|
||||||
unTag(terms, todo.unTag, model.one.tagSet, reason)
|
const tags = Array.isArray(todo.unTag) ? todo.unTag : [todo.unTag]
|
||||||
|
tags.forEach(tag => unTag(terms, tag, model.one.tagSet, reason))
|
||||||
}
|
}
|
||||||
// allow setting chunks, too
|
// allow setting chunks, too
|
||||||
if (todo.chunk) {
|
if (todo.chunk) {
|
||||||
|
|||||||
@@ -38,3 +38,21 @@ test('sweep-freeze:', function (t) {
|
|||||||
t.equal(m.has('#Adjective'), false, here + 'front steps frozen')
|
t.equal(m.has('#Adjective'), false, here + 'front steps frozen')
|
||||||
t.end()
|
t.end()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test('sweep-untag:', function (t) {
|
||||||
|
const matches = [
|
||||||
|
{ match: 'clinic', unTag: ['ProperNoun', 'Person'] },
|
||||||
|
{ match: 'walked', unTag: 'Verb' },
|
||||||
|
]
|
||||||
|
const net = nlp.buildNet(matches)
|
||||||
|
let doc = nlp('There are thirty days in the January Clinic')
|
||||||
|
doc.sweep(net)
|
||||||
|
const m = doc.match('clinic')
|
||||||
|
t.equal(m.has('#ProperNoun'), false, here + 'untag array first')
|
||||||
|
t.equal(m.has('#Person'), false, here + 'untag array second')
|
||||||
|
|
||||||
|
doc = nlp('Spencer walked')
|
||||||
|
doc.sweep(net)
|
||||||
|
t.equal(doc.has('#PastTense'), false, here + 'untag children')
|
||||||
|
t.end()
|
||||||
|
})
|
||||||
Reference in new issue
Block a user