2021-02-13 08:39:05 -08:00
|
|
|
package models
|
|
|
|
|
|
|
|
import (
|
2021-02-20 18:17:12 -08:00
|
|
|
"fmt"
|
2021-02-13 08:39:05 -08:00
|
|
|
"strings"
|
|
|
|
)
|
|
|
|
|
|
|
|
type Noun struct {
|
|
|
|
Id int
|
|
|
|
|
|
|
|
Multiple bool
|
|
|
|
|
|
|
|
Begin bool
|
|
|
|
End bool
|
|
|
|
Alone bool
|
|
|
|
|
|
|
|
Regular bool
|
|
|
|
|
|
|
|
Word string
|
|
|
|
}
|
|
|
|
|
|
|
|
func (n Noun) Plural() string {
|
2021-02-20 18:17:12 -08:00
|
|
|
if !n.Regular {
|
|
|
|
fmt.Println("[noun] Irregular nouns not implemented")
|
|
|
|
return n.Word
|
|
|
|
}
|
|
|
|
|
2021-02-13 08:39:05 -08:00
|
|
|
suffixes := []string{
|
|
|
|
"s",
|
|
|
|
"x",
|
|
|
|
"sh",
|
|
|
|
"ch",
|
|
|
|
"ss",
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, sfx := range suffixes {
|
|
|
|
if strings.HasSuffix(n.Word, sfx) {
|
|
|
|
return n.Word + "es"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if strings.HasSuffix(n.Word, "y") && !strings.ContainsAny(string(n.Word[len(n.Word)-2]), "aeiou") {
|
|
|
|
return n.Word[:len(n.Word)-1] + "ies"
|
|
|
|
}
|
|
|
|
|
|
|
|
return n.Word + "s"
|
|
|
|
}
|
|
|
|
|