fix(loader): skip incomplete verb tables
Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
parent
07d22a2bd6
commit
7c502f3da0
2 changed files with 21 additions and 0 deletions
|
|
@ -132,6 +132,9 @@ func flattenWithGrammar(prefix string, data map[string]any, out map[string]Messa
|
|||
if gerund, ok := v["gerund"].(string); ok {
|
||||
forms.Gerund = gerund
|
||||
}
|
||||
if forms.Past == "" || forms.Gerund == "" {
|
||||
continue
|
||||
}
|
||||
grammar.Verbs[core.Lower(verbName)] = forms
|
||||
continue
|
||||
}
|
||||
|
|
|
|||
|
|
@ -132,6 +132,12 @@ func TestFlattenWithGrammar(t *testing.T) {
|
|||
"past": "tested",
|
||||
"gerund": "testing",
|
||||
},
|
||||
"partial_past": map[string]any{
|
||||
"past": "partialed",
|
||||
},
|
||||
"partial_gerund": map[string]any{
|
||||
"gerund": "partialing",
|
||||
},
|
||||
"publish_draft": map[string]any{
|
||||
"base": "publish",
|
||||
"past": "published",
|
||||
|
|
@ -201,6 +207,18 @@ func TestFlattenWithGrammar(t *testing.T) {
|
|||
if _, ok := grammar.Verbs["publish_draft"]; ok {
|
||||
t.Error("verb should be stored under explicit base, not JSON key")
|
||||
}
|
||||
if _, ok := grammar.Verbs["partial_past"]; ok {
|
||||
t.Error("incomplete verb entry with only past should be skipped")
|
||||
}
|
||||
if _, ok := grammar.Verbs["partial_gerund"]; ok {
|
||||
t.Error("incomplete verb entry with only gerund should be skipped")
|
||||
}
|
||||
if _, ok := messages["gram.verb.partial_past"]; ok {
|
||||
t.Error("gram.verb.partial_past should not be flattened into messages")
|
||||
}
|
||||
if _, ok := messages["gram.verb.partial_gerund"]; ok {
|
||||
t.Error("gram.verb.partial_gerund should not be flattened into messages")
|
||||
}
|
||||
|
||||
// Noun extracted
|
||||
if n, ok := grammar.Nouns["widget"]; !ok {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue