Upstream spencermountain/compromise state of the touched files before 2b66fef810

This commit is contained in:
upstream committed 2026-09-23 12:38:21 +02:00
1 parent a29ba6095c
commit 6fd03e1913
3 files changed
+432

No files matched your search

@@ -0,0 +1,154 @@
const banList = {
that: true,
there: true,
let: true,
here: true,
everywhere: true,
}
const beforePossessive = {
in: true, //in sunday's
by: true, //by sunday's
for: true, //for sunday's
}
const adjLike = new Set(['too', 'also', 'enough', 'about'])
const nounLike = new Set(['is', 'are', 'did', 'were', 'could', 'should', 'must', 'had', 'have'])
const isPossessive = (terms, i) => {
const term = terms[i]
// these can't be possessive
if (banList.hasOwnProperty(term.machine || term.normal)) {
return false
}
// if we already know it
if (term.tags.has('Possessive')) {
return true
}
// who's
if (term.tags.has('QuestionWord')) {
return false
}
// some pronouns are never possessive
if (term.normal === `he's` || term.normal === `she's`) {
return false
}
//if end of sentence, it is possessive - "was spencer's"
const nextTerm = terms[i + 1]
if (!nextTerm) {
return true
}
// "it's a life" vs "run it's business"
if (term.normal === `it's`) {
if (nextTerm.tags.has('#Noun')) {
return true
}
return false
}
// the sun's setting vs the artist's painting
// gerund = is, noun = possessive
// (we are doing some dupe-work of the switch classifier here)
if (nextTerm.switch == 'Noun|Gerund') {
const next2 = terms[i + 2]
// the artist's painting.
if (!next2) {
if (term.tags.has('Actor') || term.tags.has('ProperNoun')) {
return true
}
return false
}
// the artist's painting is..
if (next2.tags.has('Copula')) {
return true
}
// the cat's sleeping on ..
if (next2.normal === 'on' || next2.normal === 'in') {
return false
}
return false
}
//a gerund suggests 'is walking'
if (nextTerm.tags.has('Verb')) {
//fix 'jamie's bite'
if (nextTerm.tags.has('Infinitive')) {
return true
}
//'jamaica's growing'
if (nextTerm.tags.has('Gerund')) {
return false
}
//fix 'spencer's runs'
if (nextTerm.tags.has('PresentTense')) {
return true
}
return false
}
// john's nuts
if (nextTerm.switch === 'Adj|Noun') {
const twoTerm = terms[i + 2]
if (!twoTerm) {
return false //adj
}
// john's nuts were..
if (nounLike.has(twoTerm.normal)) {
return true
}
// john's nuts about..
if (adjLike.has(twoTerm.normal)) {
return false //adj
}
}
//spencer's house
if (nextTerm.tags.has('Noun')) {
const nextStr = nextTerm.machine || nextTerm.normal
// 'spencer's here'
if (nextStr === 'here' || nextStr === 'there' || nextStr === 'everywhere') {
return false
}
// the chair's his
if (nextTerm.tags.has('Possessive')) {
return false
}
// the captain's John
if (nextTerm.tags.has('ProperNoun') && !term.tags.has('ProperNoun')) {
return false
}
return true
}
// by sunday's final
if (terms[i - 1] && beforePossessive[terms[i - 1].normal] === true) {
return true
}
// spencer's tired
if (nextTerm.tags.has('Adjective')) {
const twoTerm = terms[i + 2]
//the rocket's red
if (!twoTerm) {
return false
}
// rocket's red nozzle
if (twoTerm.tags.has('Noun') && !twoTerm.tags.has('Pronoun')) {
//project's behind schedule
const str = nextTerm.normal
if (str === 'above' || str === 'below' || str === 'behind') {
return false
}
return true
}
// rocket's red glare
if (twoTerm.switch === 'Noun|Verb') {
return true
}
//othwerwise, an adjective suggests 'is good'
return false
}
// baby's first steps
if (nextTerm.tags.has('Value')) {
return true
}
// otherwise not possessive
return false
}
export default isPossessive
@@ -0,0 +1,74 @@
export default [
// amusing his aunt
// { match: '[#Adjective] #Possessive #Noun', group: 0, tag: 'Verb', reason: 'gerund-his-noun' },
// loving you
// { match: '[#Adjective] (us|you)', group: 0, tag: 'Gerund', reason: 'loving-you' },
// slowly stunning
{ match: '(slowly|quickly) [#Adjective]', group: 0, tag: 'Verb', reason: 'slowly-adj' },
// does mean
{ match: 'does (#Adverb|not)? [#Adjective]', group: 0, tag: 'PresentTense', reason: 'does-mean' },
// okay by me
{ match: '[(fine|okay|cool|ok)] by me', group: 0, tag: 'Adjective', reason: 'okay-by-me' },
// i mean
{ match: 'i (#Adverb|do)? not? [mean]', group: 0, tag: 'PresentTense', reason: 'i-mean' },
//will secure our
{ match: 'will #Adjective', tag: 'Auxiliary Infinitive', reason: 'will-adj' },
//he disguised the thing
{ match: '#Pronoun [#Adjective] #Determiner #Adjective? #Noun', group: 0, tag: 'Verb', reason: 'he-adj-the' },
//is eager to go
{ match: '#Copula [%Adj|Present%] to #Verb', group: 0, tag: 'Verb', reason: 'adj-to' },
//is done well
{ match: '#Copula [#Adjective] (well|badly|quickly|slowly)', group: 0, tag: 'Verb', reason: 'done-well' },
// rude and insulting
{ match: '#Adjective and [#Gerund] !#Preposition?', group: 0, tag: 'Adjective', reason: 'rude-and-x' },
// were over cooked
{ match: '#Copula #Adverb? (over|under) [#PastTense]', group: 0, tag: 'Adjective', reason: 'over-cooked' },
// was bland and overcooked
{ match: '#Copula #Adjective+ (and|or) [#PastTense]$', group: 0, tag: 'Adjective', reason: 'bland-and-overcooked' },
// got tired of
{ match: 'got #Adverb? [#PastTense] of', group: 0, tag: 'Adjective', reason: 'got-tired-of' },
//felt loved
{
match:
'(seem|seems|seemed|appear|appeared|appears|feel|feels|felt|sound|sounds|sounded) (#Adverb|#Adjective)? [#PastTense]',
group: 0,
tag: 'Adjective',
reason: 'felt-loved',
},
// seem confused
{ match: '(seem|feel|seemed|felt) [#PastTense #Particle?]', group: 0, tag: 'Adjective', reason: 'seem-confused' },
// a bit confused
{ match: 'a (bit|little|tad) [#PastTense #Particle?]', group: 0, tag: 'Adjective', reason: 'a-bit-confused' },
// do not be embarrassed
{ match: 'not be [%Adj|Past% #Particle?]', group: 0, tag: 'Adjective', reason: 'do-not-be-confused' },
// is just right
{ match: '#Copula just [%Adj|Past% #Particle?]', group: 0, tag: 'Adjective', reason: 'is-just-right' },
// as pale as
{ match: 'as [#Infinitive] as', group: 0, tag: 'Adjective', reason: 'as-pale-as' },
//failed and oppressive
{ match: '[%Adj|Past%] and #Adjective', group: 0, tag: 'Adjective', reason: 'faled-and-oppressive' },
// or heightened emotion
{
match: 'or [#PastTense] #Noun',
group: 0,
tag: 'Adjective',
notIf: '(#Copula|#Pronoun)',
reason: 'or-heightened-emotion',
},
// 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' },
// is he cool
{ match: '#Copula #Pronoun [%Adj|Present%]', group: 0, tag: 'Adjective', reason: 'is-he-cool' },
// is crowded with
{
match: '#Copula [%Adj|Past%] with',
group: 0,
tag: 'Adjective',
notIf: '(associated|worn|baked|aged|armed|bound|fried|loaded|mixed|packed|pumped|filled|sealed)',
reason: 'is-crowded-with',
},
// is empty$
{ match: '#Copula #Adverb? [%Adj|Present%]$', group: 0, tag: 'Adjective', reason: 'was-empty$' },
]