Upstream spencermountain/compromise state of the touched files before 432068a0f8
This commit is contained in:
1 parent
64db6b2acb
commit
55246252c2
2 files changed
+421
No files matched your search
@@ -0,0 +1,61 @@
|
||||
// import { toPast, toPresent, toGerund, toParticiple } from '../../../../model/models/index.js'
|
||||
import { convert } from 'suffix-thumb'
|
||||
|
||||
// pull-apart phrasal verb 'fall over'
|
||||
const parse = (inf) => {
|
||||
if (/ /.test(inf)) {
|
||||
return inf.split(/ /)
|
||||
}
|
||||
return [inf, '']
|
||||
}
|
||||
|
||||
//we run this on every verb in the lexicon, so please keep it fast
|
||||
//we assume the input word is a proper infinitive
|
||||
const conjugate = function (inf, model) {
|
||||
const { toPast, toPresent, toGerund, toParticiple } = model.two.models
|
||||
// ad-hoc Copula response
|
||||
if (inf === 'be') {
|
||||
return {
|
||||
Infinitive: inf,
|
||||
Gerund: 'being',
|
||||
PastTense: 'was',
|
||||
PresentTense: 'is',
|
||||
}
|
||||
}
|
||||
const [str, particle] = parse(inf)
|
||||
const found = {
|
||||
Infinitive: str,
|
||||
PastTense: convert(str, toPast),
|
||||
PresentTense: convert(str, toPresent),
|
||||
Gerund: convert(str, toGerund),
|
||||
FutureTense: 'will ' + str
|
||||
}
|
||||
// add past-participle if it's interesting
|
||||
// drive -> driven (not drove)
|
||||
let pastPrt = convert(str, toParticiple)
|
||||
if (pastPrt !== inf && pastPrt !== found.PastTense) {
|
||||
// ensure it's a known participle
|
||||
const lex = model.one.lexicon || {}
|
||||
if (lex[pastPrt] === 'Participle' || lex[pastPrt] === 'Adjective') {
|
||||
// one exception
|
||||
if (inf === 'play') {
|
||||
pastPrt = 'played'
|
||||
}
|
||||
found.Participle = pastPrt
|
||||
}
|
||||
}
|
||||
// put phrasal-verbs back together again
|
||||
if (particle) {
|
||||
Object.keys(found).forEach(k => {
|
||||
found[k] += ' ' + particle
|
||||
})
|
||||
}
|
||||
return found
|
||||
}
|
||||
|
||||
|
||||
export default conjugate
|
||||
|
||||
// console.log(toPresent.rules.y)
|
||||
// console.log(convert('buy', toPresent))
|
||||
|
||||
Reference in new issue
Block a user