diff --git a/src/2-two/contraction-two/compute/isPossessive.js b/src/2-two/contraction-two/compute/isPossessive.js index f5d91d2..f27bfbc 100644 --- a/src/2-two/contraction-two/compute/isPossessive.js +++ b/src/2-two/contraction-two/compute/isPossessive.js @@ -13,6 +13,8 @@ const beforePossessive = { } const adjLike = new Set(['too', 'also', 'enough', 'about']) const nounLike = new Set(['is', 'are', 'did', 'were', 'could', 'should', 'must', 'had', 'have']) +// "is was" or "has was" can't happen, so a copula means the 's is possessive +const copulas = new Set(['is', 'are', 'was', 'were', 'am']) const isPossessive = (terms, i) => { const term = terms[i] @@ -68,6 +70,10 @@ const isPossessive = (terms, i) => { } //a gerund suggests 'is walking' if (nextTerm.tags.has('Verb')) { + // 'leonard's was closed' + if (copulas.has(nextTerm.normal)) { + return true + } //fix 'jamie's bite' if (nextTerm.tags.has('Infinitive')) { return true diff --git a/src/2-two/postTagger/model/adjective/adj-verb.js b/src/2-two/postTagger/model/adjective/adj-verb.js index 3848629..5962228 100644 --- a/src/2-two/postTagger/model/adjective/adj-verb.js +++ b/src/2-two/postTagger/model/adjective/adj-verb.js @@ -58,7 +58,7 @@ export default [ // became involved { match: '(become|became|becoming|becomes) [#Verb]', group: 0, tag: 'Adjective', reason: 'become-verb' }, // their declared intentions - { match: '#Possessive [#PastTense] #Noun', group: 0, tag: 'Adjective', reason: 'declared-intentions' }, + { match: '#Possessive [#PastTense] #Noun', group: 0, notIf: '#Copula', tag: 'Adjective', reason: 'declared-intentions' }, // is he cool { match: '#Copula #Pronoun [%Adj|Present%]', group: 0, tag: 'Adjective', reason: 'is-he-cool' }, // is crowded with diff --git a/tests/two/contractions/is-has-possessive.test.js b/tests/two/contractions/is-has-possessive.test.js index e7e95b1..109599d 100644 --- a/tests/two/contractions/is-has-possessive.test.js +++ b/tests/two/contractions/is-has-possessive.test.js @@ -141,6 +141,9 @@ test('is-has', function (t) { ["The librarian's knowledge of books was vast", '#Possessive'], ["The manager's decision was unexpected", '#Possessive'], ["The meeting's been rescheduled", 'has'], + ["Leonard's was Randall", '#Possessive'], + ["Toronto's was Canada", '#Possessive'], + ["Leonard's was closed on Monday", '#Possessive'], ["The meeting's scheduled for 3 PM", 'is'], ["The mountain's peak is covered in snow", '#Possessive'], ["The movie's already started", 'has'], @@ -202,3 +205,11 @@ test('is-has', function (t) { }) t.end() }) + +test('possessive before a copula keeps its whitespace', function (t) { + const doc = nlp(`Leonard's was Randall`) + t.equal(doc.match('#Noun').text(), `Leonard's Randall`, here + 'noun match') + t.ok(doc.match('was').has('#Copula'), here + 'was stays a verb') + t.notOk(doc.match('was').has('#Adjective'), here + 'was is not an adjective') + t.end() +})