Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update main clause determination #1072

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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