Upstream spencermountain/compromise state of the touched files before c4984cdae1
This commit is contained in:
1 parent
6099cb9020
commit
dfd30c3b15
2 files changed
+48
-15
No files matched your search
@@ -0,0 +1,48 @@
|
||||
import findMain from './mainClause.js'
|
||||
|
||||
const grammar = function (vb) {
|
||||
let tense = null
|
||||
if (vb.has('#PastTense')) {
|
||||
tense = 'PastTense'
|
||||
} else if (vb.has('#FutureTense')) {
|
||||
tense = 'FutureTense'
|
||||
} else if (vb.has('#PresentTense')) {
|
||||
tense = 'PresentTense'
|
||||
}
|
||||
return {
|
||||
tense
|
||||
}
|
||||
}
|
||||
|
||||
const parse = function (s) {
|
||||
const clauses = s.clauses()
|
||||
const main = findMain(clauses)
|
||||
const chunks = main.chunks()
|
||||
let subj = s.none()
|
||||
let verb = s.none()
|
||||
let pred = s.none()
|
||||
chunks.forEach((ch, i) => {
|
||||
if (i === 0 && !ch.has('<Verb>')) {
|
||||
subj = ch
|
||||
return
|
||||
}
|
||||
if (!verb.found && ch.has('<Verb>')) {
|
||||
verb = ch
|
||||
return
|
||||
}
|
||||
if (verb.found) {
|
||||
pred = pred.concat(ch)
|
||||
}
|
||||
})
|
||||
// cleanup a missed parse
|
||||
if (verb.found && !subj.found) {
|
||||
subj = verb.before('<Noun>+').first()
|
||||
}
|
||||
return {
|
||||
subj,
|
||||
verb,
|
||||
pred,
|
||||
grammar: grammar(verb)
|
||||
}
|
||||
}
|
||||
export default parse
|
||||
Reference in new issue
Block a user