Skip to content

Commit

Permalink
there is some wonky data in the morph possibilities because of some c…
Browse files Browse the repository at this point in the history
…orner cases not caught by the builder; `MorphPossibIntoLexPossib()` needs to handle this
  • Loading branch information
e-gun committed Apr 28, 2024
1 parent 7435b55 commit 6131115
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions internal/db/getlex.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,9 @@ func MorphPossibIntoLexPossib(d string, mpp []str.MorphPossib) []str.DbLexicon {
FLDS = `entry_name, metrical_entry, id_number, pos, translations, html_body`
PSQQ = `SELECT %s FROM %s_dictionary WHERE %s ~* '^%s(|¹|²|³|⁴|1|2)$' ORDER BY id_number ASC`
COLM = "entry_name"
SQLE = "MorphPossibIntoLexPossib() sent a bad query: \n\t%s"
)

var hwm []string
for _, p := range mpp {
if strings.TrimSpace(p.Headwd) != "" {
Expand Down Expand Up @@ -195,9 +197,17 @@ func MorphPossibIntoLexPossib(d string, mpp []str.MorphPossib) []str.DbLexicon {
foundrows, err := dbconn.Query(context.Background(), q)
Msg.EC(err)

_, e := pgx.ForEachRow(foundrows, foreach, rwfnc)
Msg.EC(e)
// nb: there is some wonky data in the morph possibilities because of some corner cases not caught by the builder
// [HGS-DBI] SELECT entry_name, metrical_entry, id_number, pos, translations, html_body FROM greek_dictionary WHERE entry_name ~* '^ὀμβρόω(|¹|²|³|⁴|1|2)$' ORDER BY id_number ASC
// [HGS-DBI] SELECT entry_name, metrical_entry, id_number, pos, translations, html_body FROM greek_dictionary WHERE entry_name ~* '^ό)μβροϲ(|¹|²|³|⁴|1|2)$' ORDER BY id_number ASC
// the second has a ')' that yields an error
// "ERROR: invalid regular expression: parentheses () not balanced (SQLSTATE 2201B)"

_, e := pgx.ForEachRow(foundrows, foreach, rwfnc)
if e != nil {
// you can survive this error... log it
Msg.FYI(fmt.Sprintf(SQLE, q))
}
}
return lexicalfinds
}
Expand Down

0 comments on commit 6131115

Please sign in to comment.