Example #1
0
 public static void PrintTableSize(string tableName, MySqlUtils sqlUtils)
 {
     Logger.DebugWriteLine(string.Format(
         "Table {0} has {1} elements.",
         tableName,
         sqlUtils.ExecuteScalar(string.Format("SELECT COUNT(*) FROM {0}", tableName))));
 }
Example #2
0
 public static object CalculateQuality(MySqlUtils sqlUtils)
 {
     try
     {
         string innerSelect =
             "select a.* from scoredfacts a, " +
             "(SELECT topicid, max(Score) as score FROM scoredfacts group by topicid) b " +
             "where a.topicid = b.topicid and a.score = b.score group by a.topicid";
         string qualityMeasurement = string.Format(
             "select " +
             "(select count(*) from ({0}) d, correctfacts c where c.itemid=d.itemid) / " +
             "(select count(*) from ({0}) e) as Quality", innerSelect
         );
         object qualityRes = sqlUtils.ExecuteScalar(qualityMeasurement);
         Logger.TraceWriteLine(string.Format("The quality of the run is {0}", qualityRes.ToString()));
         return qualityRes;
     }
     catch (Exception)
     {
         Logger.TraceWriteLine("No correct facts");
     }
     return 0;
 }
Example #3
0
 public static void NewNormalizedScoreCalculation(MySqlUtils sqlUtils)
 {
     object obj = sqlUtils.ExecuteScalar(string.Format(
         "select max(NumOfFacts) from {0}", TableConstants.UserScores));
     int maxFactor = (int)obj;
     int minFactor = (int)sqlUtils.ExecuteScalar(string.Format(
         "select min(NumOfFacts) from {0}", TableConstants.UserScores));
     // this works but not converges
     sqlUtils.ExecuteNonQuery(string.Format(
         "UPDATE {0} us " +
         "SET us.Belief=((1-{3})*us.Belief + " +
         "{3}*(SELECT COUNT(*) FROM {1} rk, {2} im " +
         "WHERE rk.FactId=im.ItemId AND im.UserID=us.UserId)/" +
         "us.NumOfFacts*(us.NumOfFacts-{4})/({5}-{4})), us.Version=us.Version+1",
         TableConstants.UserScores,
         TableConstants.RepKeyResults,
         TableConstants.ItemsMentions,
         0.2, minFactor, maxFactor));
 }