spencermountain / compromise

modest natural-language processing
http://compromise.cool
MIT License
11.31k stars 645 forks source link

"Throughout" within a main clause currently doesn't work. #1071

Closed ryancasburn-KAI closed 4 months ago

ryancasburn-KAI commented 6 months ago

This is related to #1035.

https://github.com/spencermountain/compromise/blob/6bf9a6c4828377b59739b6ef3d63cfd5791bd30e/src/3-three/sentences/parse/mainClause.js#L31

It's unclear to me what this list is based on. There are plenty of sentences which have through or throughout in the main clause.

Example: "She worked with the City to prepare detailed recommendations throughout downtown, including priorities on every street in Downtown and street cross sections for each street." -- Main clause should be the first one, with the subject being "She" and the verb being "worked." But because that clause has "throughout" it is rejected, making the verb show up as "including."

I asked chatGPT for an example where throughout would define a clause as subordinate, and it gave me this example: "Throughout the day, as the sun gradually set, the temperature dropped significantly, creating a chilly evening." The clause with throughout is already thrown out by the fact it doesn't have a verb from https://github.com/spencermountain/compromise/blob/6bf9a6c4828377b59739b6ef3d63cfd5791bd30e/src/3-three/sentences/parse/mainClause.js#L12

Another chatGPT example: "The detective solved the case, unraveling the mystery throughout the entire investigation." -- Would still get the right answer without throwing out the second clause, because it would be the first clause at: https://github.com/spencermountain/compromise/blob/6bf9a6c4828377b59739b6ef3d63cfd5791bd30e/src/3-three/sentences/parse/mainClause.js#L40

Are there any examples where the only way to tell a clause is subordinate is with "despite|during|before|through|throughout?"

ryancasburn-KAI commented 6 months ago

Ah, just thought of an example this morning: “Despite Susan walking the dog, she was not wearing a coat.”

Is there a way to match the list in line 31 only if it is the start of the clause?

Is it as simple as:

m = m.ifNo('(^despite|^during|^before|^through|^throughout)') 
ryancasburn-KAI commented 6 months ago

One more example to make it slightly more complex: "Taking diligent notes throughout the entire class, the students remained focused during the lecture."

I believe this should be handled with m = m.ifNo('^#Gerund') I don't think clauses starting with a gerund can be a main clause.