Skip to content

Commit

Permalink
Use descriptive explanation for "whom" rule
Browse files Browse the repository at this point in the history
  • Loading branch information
theonlypwner committed Apr 10, 2018
1 parent 66840f6 commit aae6ff6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
13 changes: 11 additions & 2 deletions vendor/parser/rule.go
Expand Up @@ -33,8 +33,17 @@ var why_reason = map[string]string{
"of": "‘of’ is not a verb like ‘have’ is",
"your-are": "‘your’ is a possessive determiner; ‘you’ is a pronoun",
"supposed-to": "‘supposed’ is a participle, not a bare infinitive",
"whom": "unlike ‘whom’, ‘who’ is a subject",
"allot-of": "‘allot’ is a verb; ‘a lot’ is a noun or adverb",

"whom_is": "unlike ‘whom’, ‘who’ is the subject of ‘is’",
"whom_am": "unlike ‘whom’, ‘who’ is the subject of ‘am’",
"whom_are": "unlike ‘whom’, ‘who’ is the subject of ‘are’",
"whom_was": "unlike ‘whom’, ‘who’ is the subject of ‘was’",
"whom_were": "unlike ‘whom’, ‘who’ is the subject of ‘were’",
"whomever_is": "unlike ‘whomever’, ‘whoever’ is the subject of ‘is’",
"whomever_was": "unlike ‘whomever’, ‘whoever’ is the subject of ‘was’",
"whomsoever_is": "unlike ‘whomsoever’, ‘whosoever’ is the subject of ‘is’",
"whomsoever_was": "unlike ‘whomsoever’, ‘whosoever’ is the subject of ‘was’",
}

type word *sequence.Word
Expand All @@ -52,7 +61,7 @@ func (r *ruleMatcher) Matched(reason string) {
return
}
r.matched[reason] = struct{}{}
why := "[ERROR]"
why := "[THERE WAS AN ERROR GENERATING AN EXPLANATION]"
if reasonText, ok := why_reason[reason]; ok {
why = reasonText
}
Expand Down
8 changes: 5 additions & 3 deletions vendor/parser/rule_whomBe.go
Expand Up @@ -30,12 +30,14 @@ func (r *ruleMatcher) rule_whomBe(cur *sequence.Word) {
next1New = "is"
}

switch cur.Lower {
rule := cur.Lower

switch rule {
case "whomever":
cur.ReplaceCap("whoever")
case "whomsoever":
cur.ReplaceCap("whosoever")
default:
default: // "whom"
if r.HasPrevInSentence(1) {
switch r.PrevWord(1).Lower {
case "i", "me", "myself":
Expand Down Expand Up @@ -70,5 +72,5 @@ func (r *ruleMatcher) rule_whomBe(cur *sequence.Word) {
if next1.Lower != next1New {
next1.Replace(next1New)
}
r.Matched("whom")
r.Matched(rule + "_" + next1New)
}

0 comments on commit aae6ff6

Please sign in to comment.