#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;
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);
auto r2 = tf.extract("BTC crashes after hack exploit, regulators crackdown on exchange");
check("en bearish sentiment < 0", r2.sentiment < 0.0);
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);
auto r4 = tf.extract("比特币暴跌 恐慌抛售 监管打压 黑客攻击");
check("cn bearish sentiment < 0", r4.sentiment < 0.0);
auto r5 = tf.extract("URGENT!! SELL NOW!!");
check("urgency high", r5.urgency > 0.5, "urgency>0.5");
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);
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);
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;
}