Skip the verb of a relative clause after the subject
This commit is contained in:
1 parent
dfd30c3b15
commit
64db6b2acb
2 files changed
+15
-2
No files matched your search
@@ -21,12 +21,24 @@ const parse = function (s) {
|
||||
let subj = s.none()
|
||||
let verb = s.none()
|
||||
let pred = s.none()
|
||||
// a relative clause right after the subject has a verb of its own
|
||||
// ('the boy who you saw at the store committed a robbery')
|
||||
const relative =
|
||||
chunks.length > 2 &&
|
||||
!chunks.eq(0).has('<Verb>') &&
|
||||
chunks.eq(1).has('^(who|whom|whose|which|that)$') &&
|
||||
chunks.filter(ch => ch.has('<Verb>')).length > 1
|
||||
let skipped = false
|
||||
chunks.forEach((ch, i) => {
|
||||
if (i === 0 && !ch.has('<Verb>')) {
|
||||
subj = ch
|
||||
return
|
||||
}
|
||||
if (!verb.found && ch.has('<Verb>')) {
|
||||
if (relative && !skipped) {
|
||||
skipped = true
|
||||
return
|
||||
}
|
||||
verb = ch
|
||||
return
|
||||
}
|
||||
|
||||
@@ -47,10 +47,11 @@ test('svo parser', function (t) {
|
||||
],
|
||||
['He bought the car that the dealer, the bank, and the broker all recommended.', 'he', 'bought'],
|
||||
['I ate dinner before I went to bed.', 'i', 'ate'],
|
||||
['The man who called yesterday is my uncle.', 'the man', 'is'],
|
||||
|
||||
// ['every day the kitten tries to eat the mouse', 'the kitten', 'tries to eat'],
|
||||
// ['The boy who you saw at the store committed a robbery.', 'the boy', 'committed'],
|
||||
// ['After dripping mustard all over his chest, the man who was wearing a red shirt wished that he had instead chosen ketchup for his hotdog.', 'the man', 'wished'],
|
||||
['The boy who you saw at the store committed a robbery.', 'the boy', 'committed'],
|
||||
['After dripping mustard all over his chest, the man who was wearing a red shirt wished that he had instead chosen ketchup for his hotdog.', 'the man', 'wished'],
|
||||
// ["please tell me you'll address the issue", 'you', 'will address'],
|
||||
// ['The store that the boy robbed is on the corner.', 'the store', 'is'],
|
||||
]
|
||||
|
||||
Reference in new issue
Block a user