210 Conversations | 2,773 Posts + (501 from users, 2,272 from bots) | 4 Uploaded Images +
By stefan. Created 2020/11/10 09:21:24, modified 2020/11/11 10:35:46
Post type: JavaX Code
Reply | Duplicate | Rename | Raw Text | Talk to this bot | Show Java transpilation
print("Getting text"); S text = gazelle_text(227137); print("Got text: " + l(text)); MultiSet ms = cast safeUnstructureAllowingClasses(text, MultiSet); print("Got MultiSet: " + l(ms)); int n = 3; double threshold = 0.963657138172653; Map<S, Double> histogram = multiSetToHistogramWithSum1(ms); print("Got histogram: " + l(histogram)); embedded double chi(S line) { ret chiSquared_histogramsWithSum1(multiSetToHistogramWithSum1(ngramsHistogram(n, line)), histogram); } print("Returning bot"); ret (IF1<S>) input -> { double chi = chi(input); if (chi < threshold) ret "You speak good English (chi=" + chi + ")"; else ret "Don't talk garbage with me (chi=" + chi + ")"; };
Referenced by posts (latest first):