void processInputText()

in text/text.cpp [147:176]


void processInputText(TextModelRuntime* aacs, std::string inputText) {
    AnalyzeTextOptions request;
    std::cout << "  Your input: " << inputText << std::endl;
    request.text = inputText;
    std::cout << "  AnalyzeResult: " << std::endl;
    auto severityThreshold = 3;
    // Run inference
    auto analyzeStart = std::chrono::high_resolution_clock::now();
    auto result = aacs->AnalyzeText(request);
    // Print the result to the console
    for (const auto& categoryAnalysis : result->categoriesAnalysis) {
        if (categoryAnalysis.severity > 0 && categoryAnalysis.severity < severityThreshold) {
            std::cout << "\033[33m";  // Set the text color to yellow
        }
        else if (categoryAnalysis.severity >= severityThreshold) {
            std::cout << "\033[31m";  // Set the text color to red
        }
        else {
            std::cout << "\033[32m";  // Set the text color to green
        }
        std::cout << "    Category: " << getCategoryName(categoryAnalysis.category) << ", Severity: "
            << static_cast<int>(categoryAnalysis.severity) << std::endl;
        std::cout << "\033[0m";  // Reset the text color
    }
    auto analyzeEnd = std::chrono::high_resolution_clock::now();
    auto analyzeTextDuration = std::chrono::duration_cast<std::chrono::milliseconds>(analyzeEnd - analyzeStart);
    std::cout << "AnalyzeText duration: " << analyzeTextDuration.count() << " milliseconds" << std::endl;
    std::cout << "--------------------------------------------------------------------------------------"
        << std::endl;
}