Skip to content

Commit

Permalink
Merge pull request #1072 from ryancasburn-KAI/update-main-clause-dete…
Browse files Browse the repository at this point in the history
…rmination

Update main clause determination
  • Loading branch information
spencermountain committed Jan 3, 2024
2 parents 6bf9a6c + 84ab5ec commit f92b993
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

<!-- spacer -->
<div align="center">
Expand Down
10 changes: 9 additions & 1 deletion src/3-three/sentences/parse/mainClause.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 21 additions & 1 deletion tests/three/sentences/svo.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand Down

0 comments on commit f92b993

Please sign in to comment.