コード例 #1
0
 private void Serialize_Recursive(StringBuilder sb, TextIdMapper classToClassId, TextIdMapper wordToWordId, int depth)
 {
     // If is is a leaf node, ...
     if (TrueBranch == null && FalseBranch == null)
     {
         string path = GetPath(wordToWordId);
         sb.AppendFormat("{0} {1}", path, FeatureVectors.Count);
         double[] distribution = GetDistributionByClass();
         for (int i = 0; i < distribution.Length; i++)
         {
             sb.AppendFormat(" {0} {1}", classToClassId[i], distribution[i]);
         }
         sb.AppendLine();
     }
     // If it is not a leaf node, ...
     else
     {
         if (FalseBranch != null)
         {
             FalseBranch.Serialize_Recursive(sb, classToClassId, wordToWordId, depth + 1);
         }
         if (TrueBranch != null)
         {
             TrueBranch.Serialize_Recursive(sb, classToClassId, wordToWordId, depth + 1);
         }
     }
 }