static void _PrintHelp(DecisionTreePtr dt, FILE *out, int indent) { int i; _PrintSpaces(out, indent); if(dt->nodeType == dtnLeaf) { //fprintf(out, "(leaf: %d)\n", dt->myclass); fprintf(out, "(leaf: %s)\n", ExampleSpecGetClassValueName(dt->spec, dt->myclass)); } else if(dt->nodeType == dtnDiscrete) { fprintf(out, "(split on %s:\n", ExampleSpecGetAttributeName(dt->spec, dt->splitAttribute)); for(i = 0 ; i < VALLength(dt->children) ; i++) { _PrintSpaces(out, indent + 1); fprintf(out, "%s\n", ExampleSpecGetAttributeValueName(dt->spec, dt->splitAttribute, i)); _PrintHelp(VALIndex(dt->children, i), out, indent + 2); } _PrintSpaces(out, indent); fprintf(out, ")\n"); } else if(dt->nodeType == dtnContinuous) { fprintf(out, "(split on %s:\n", ExampleSpecGetAttributeName(dt->spec, dt->splitAttribute)); /* left child */ _PrintSpaces(out, indent + 1); fprintf(out, "< %f\n", dt->splitThreshold); _PrintHelp(VALIndex(dt->children, 0), out, indent + 2); /* right child */ _PrintSpaces(out, indent + 1); fprintf(out, ">= %f\n", dt->splitThreshold); _PrintHelp(VALIndex(dt->children, 1), out, indent + 2); _PrintSpaces(out, indent); fprintf(out, ")\n"); } else if(dt->nodeType == dtnGrowing) { fprintf(out, "(growing)\n"); } }
void Run() { // prepare device modifications if (fDevice->IsReadOnly()) { printf("Device is read-only. Can't change anything.\n"); } else { status_t error = fDevice->PrepareModifications(); fPrepared = (error == B_OK); if (error != B_OK) { printf("Error: Failed to prepare device for modifications: " "%s\n", strerror(error)); } } // main input loop while (true) { BString line; if (!_ReadLine("party> ", line)) return; if (line == "") { // do nothing } else if (line == "h" || line == "help") { _PrintHelp(); } else if (line == "i") { _InitializePartition(); } else if (line == "l") { _PrintPartitionsShort(); } else if (line == "ll") { _PrintPartitionsLong(); } else if (line == "n") { _NewPartition(); } else if (line == "q" || line == "quit") { return; } else if (line == "w") { _WriteChanges(); } else { printf("Invalid command \"%s\", type \"help\" for help\n", line.String()); } } }
int cConsoleApplication::Run() { bool bIsSuccessfulRun = true; bool bIsHandledAlready = false; const size_t n = GetArgumentCount(); if (n == 1) { const string_t sArgument0 = GetArgument(0); if ((sArgument0 == TEXT("-help")) || (sArgument0 == TEXT("--help"))) { bIsHandledAlready = true; _PrintHelp(); } else if ((sArgument0 == TEXT("-version")) || (sArgument0 == TEXT("--version"))) { bIsHandledAlready = true; PrintVersion(); } } if (!bIsHandledAlready) bIsSuccessfulRun = _Run(); return (bIsSuccessfulRun) ? EXIT_SUCCESS : EXIT_FAILURE; }
void DecisionTreePrint(DecisionTreePtr dt, FILE *out) { _PrintHelp(dt, out, 0); }