// 文本特征提取测试:中英文情感/急迫度/新词
#include "text_feature.hpp"
#include <cstdio>
#include <string>

using namespace quant;

static int checks = 0, fails = 0;
static void check(const char* name, bool ok, const char* detail = "") {
    ++checks;
    if (!ok) ++fails;
    std::printf("[%s] %s %s\n", ok ? "PASS" : "FAIL", name, detail);
}

int main() {
    TextFeature tf;

    // 1) 英文利多文本
    auto r1 = tf.extract("Bitcoin surges to new record high! Strong bullish momentum!");
    check("en bullish sentiment > 0", r1.sentiment > 0.0, "sentiment>0");
    check("en bullish ratio > 0", r1.bullish_ratio > 0.0);

    // 2) 英文利空文本
    auto r2 = tf.extract("BTC crashes after hack exploit, regulators crackdown on exchange");
    check("en bearish sentiment < 0", r2.sentiment < 0.0);

    // 3) 中文利多
    auto r3 = tf.extract("比特币突破新高 暴涨 大涨 利好 减半");
    check("cn bullish sentiment > 0", r3.sentiment > 0.0, "cn bull");
    check("cn bullish ratio > 0", r3.bullish_ratio > 0.0);

    // 4) 中文利空
    auto r4 = tf.extract("比特币暴跌 恐慌抛售 监管打压 黑客攻击");
    check("cn bearish sentiment < 0", r4.sentiment < 0.0);

    // 5) 急迫度:感叹号多
    auto r5 = tf.extract("URGENT!! SELL NOW!!");
    check("urgency high", r5.urgency > 0.5, "urgency>0.5");

    // 6) 新词:第一次见 novelty 高,第二次低
    auto r6a = tf.extract("quantum flux capacitor");
    auto r6b = tf.extract("quantum flux capacitor");  // 全见过
    check("novelty first high", r6a.novelty > 0.5);
    check("novelty second low", r6b.novelty < 0.5);

    // 7) 中性文本接近 0
    auto r7 = tf.extract("the price of bitcoin is one of many factors");
    check("neutral sentiment ~0", r7.sentiment > -0.2 && r7.sentiment < 0.2);

    // 8) 空文本
    auto r8 = tf.extract("");
    check("empty text zeros", r8.sentiment == 0.0);

    std::printf("\n==== %d checks, %d fails ====\n", checks, fails);
    return fails ? 1 : 0;
}