From 87acf106bf466aeb7ad77c01cb23dd86211e985a Mon Sep 17 00:00:00 2001 From: Peter McGoron Date: Fri, 13 Aug 2021 17:14:38 -0400 Subject: [PATCH] Use lowercase for all element names and symbols The matching algorithm will work better when all names are normalized. For instance, a search of "iorn" will not list "iron" in the first three matches, but a search of "Iorn" will have "iron" as the first match. --- makedb.ml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/makedb.ml b/makedb.ml index e9adc32..6604f07 100644 --- a/makedb.ml +++ b/makedb.ml @@ -92,11 +92,12 @@ let makedb db json = let open Sqlite3 (* Bind each column name. In SQLite3 the leading ":" is part of the named parameter. *) in let prep i x = - (match colarr.(i) with - | "Symbol" -> symbs := (x,None)::!symbs - | "Name" -> names := (x,None)::!names - | _ -> () - ); + let lcase = String.lowercase_ascii + in let x = (match colarr.(i) with + | "Symbol" -> symbs := (lcase x,None)::!symbs; lcase x + | "Name" -> names := (lcase x,None)::!names; lcase x + | _ -> x + ) in binds stmt colarr.(i) (if x = "" then Data.NULL else Data.TEXT x)