public static double GetScore(string srcStr, string tarStr, int deleteCost, int insertCost, int replaceCost, int swapCost, int caseChangeCost, bool enhancedFlag, int splitCost) { int cost = EditDistance.GetEditDistance(srcStr, tarStr, deleteCost, insertCost, replaceCost, swapCost, caseChangeCost, enhancedFlag); int penalty = OrthographicUtil.GetSplitPenalty(srcStr, tarStr, splitCost); double score = OrthographicUtil.GetNormScore(cost + penalty, 1000.0); return(score); }
// TBD: read the values from config file public static double GetScore(string srcStr, string tarStr) { /// <summary> /// init value form ensemble /// int deleteCost = 95; /// int insertCost = 95; /// int replaceCost = 100; /// int swapCost = 90; /// /// </summary> // new value int deleteCost = 100; int insertCost = 100; int replaceCost = 100; int swapCost = 100; int caseChangeCost = 10; bool enhancedFlag = false; int splitCost = insertCost; int maxCodeLength = 10; /// <summary> /// Test on different phonetic methods /// String srcM2 = Metaphone2.GetCode(srcStr, maxCodeLength); /// String tarM2 = Metaphone2.GetCode(tarStr, maxCodeLength); /// String srcM2 = RefinedSoundex.GetCode(srcStr); /// String tarM2 = RefinedSoundex.GetCode(tarStr); /// String srcM2 = Caverphone2.GetCaverphone(srcStr); /// String tarM2 = Caverphone2.GetCaverphone(tarStr); /// String srcM2 = Metaphone.GetMetaphone(srcStr, maxCodeLength); /// String tarM2 = Metaphone.GetMetaphone(tarStr, maxCodeLength); /// Metaphone3 m3 = new Metaphone3(); /// m3.SetKeyLength(maxCodeLength); /// String srcM2 = m3.GetMetaphone(srcStr); /// String tarM2 = m3.GetMetaphone(tarStr); /// /// </summary> string srcM2 = Metaphone2.GetCode(srcStr, maxCodeLength); string tarM2 = Metaphone2.GetCode(tarStr, maxCodeLength); int cost = EditDistance.GetEditDistance(srcM2, tarM2, deleteCost, insertCost, replaceCost, swapCost, caseChangeCost, enhancedFlag); int penalty = OrthographicUtil.GetSplitPenalty(srcStr, tarStr, splitCost); double score = OrthographicUtil.GetNormScore(cost + penalty, 1000.0); return(score); }