/// <exception cref="System.IO.IOException"/> public static IList <Edu.Stanford.Nlp.IE.QE.UnitPrefix> LoadPrefixes(string filename) { Pattern commaPattern = Pattern.Compile("\\s*,\\s*"); BufferedReader br = IOUtils.GetBufferedFileReader(filename); string headerString = br.ReadLine(); string[] header = commaPattern.Split(headerString); IDictionary <string, int> headerIndex = new Dictionary <string, int>(); for (int i = 0; i < header.Length; i++) { headerIndex[header[i]] = i; } int iName = headerIndex["name"]; int iPrefix = headerIndex["prefix"]; int iBase = headerIndex["base"]; int iExp = headerIndex["exp"]; int iSystem = headerIndex["system"]; string line; IList <Edu.Stanford.Nlp.IE.QE.UnitPrefix> list = new List <Edu.Stanford.Nlp.IE.QE.UnitPrefix>(); while ((line = br.ReadLine()) != null) { string[] fields = commaPattern.Split(line); double @base = double.ParseDouble(fields[iBase]); double exp = double.ParseDouble(fields[iExp]); double scale = Math.Pow(@base, exp); Edu.Stanford.Nlp.IE.QE.UnitPrefix unitPrefix = new Edu.Stanford.Nlp.IE.QE.UnitPrefix(fields[iName], fields[iPrefix], scale, fields[iSystem]); list.Add(unitPrefix); } br.Close(); return(list); }
public static void RegisterPrefix(Env env, Edu.Stanford.Nlp.IE.QE.UnitPrefix prefix) { env.Bind(prefix.GetName().ToUpper(), prefix); }