diff --git a/README.md b/README.md index 6160f35ec..05427191b 100644 --- a/README.md +++ b/README.md @@ -857,7 +857,7 @@ nlp.extend({ ##### Comparisons - [Compromise and Spacy](https://observablehq.com/@spencermountain/compromise-and-spacy) -- [Compromise and NLTK](https://observablehq.com/@spencermountain/compromise-and-NLTK) +- [Compromise and NLTK](https://observablehq.com/@spencermountain/compromise-and-nltk)
diff --git a/src/3-three/sentences/parse/mainClause.js b/src/3-three/sentences/parse/mainClause.js index 609f43d61..af95cae68 100644 --- a/src/3-three/sentences/parse/mainClause.js +++ b/src/3-three/sentences/parse/mainClause.js @@ -28,10 +28,18 @@ const mainClause = function (s) { return m } - m = m.ifNo('(despite|during|before|through|throughout)') + // check for subordinating conjunctions -- must be at the beginning of the clause + m = m.ifNo('(^despite|^during|^before|^through|^throughout)') if (m.length === 1) { return m } + + // check for clauses beginning with Gerund ("Taking ..., ...") + m = m.ifNo('^#Gerund') + if (m.length === 1) { + return m + } + // did we go too far? if (m.length === 0) { m = s diff --git a/tests/three/sentences/svo.test.js b/tests/three/sentences/svo.test.js index 1ed4444f5..a527914f0 100644 --- a/tests/three/sentences/svo.test.js +++ b/tests/three/sentences/svo.test.js @@ -17,9 +17,29 @@ test('svo parser', function (t) { [`every year, we gather in Baltimore`, `we`, `gather`], [`if only i was awake, we could have eaten the breakfast`, `we`, `could have eaten`], ['Every night before I go to bed, I eat bananas.', 'i', 'eat'], - ['Diane decided to plant tomatoes in the back of the yard, where the sun blazed the longest during the day.', 'diane', 'decided to plant'], + [ + 'Diane decided to plant tomatoes in the back of the yard, where the sun blazed the longest during the day.', + 'diane', + 'decided to plant', + ], ['Once Adam smashed the spider, he ran into the bathroom', 'he', 'ran into'], [`We are introducing ourselves to the class.`, 'we', 'are introducing ourselves'], + [ + 'Throughout the day, as the sun gradually set, the temperature dropped significantly, creating a chilly evening.', + 'the temperature', + 'dropped significantly', + ], + [ + 'He collaborated with the university to develop comprehensive academic proposals throughout the entire campus, encompassing academic priorities in every department at the university and course structure typologies for each academic program.', + 'he', + 'collaborated', + ], + ['Despite Susan walking the dog, she was not wearing a coat.', 'she', 'was not wearing'], + [ + 'Taking diligent notes throughout the entire class, the students remained focused during the lecture.', + 'the students', + 'remained', + ], // ['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'],