Ocaml script for strings to rationals