QueryArtificialWords.java 1.5 KB

12345678910111213141516171819202122232425262728293031
  1. import java.sql.*;
  2. public class QueryArtificialWords {
  3. public static void main(String[] a) throws Exception {
  4. Class.forName("com.mysql.cj.jdbc.Driver");
  5. String jdbc = "jdbc:mysql://cq-cdb-8fjmemkb.sql.tencentcdb.com:27220/fs_tenant_cs1"
  6. + "?useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8";
  7. String msg = "\u4f60\u597d\uff0c\u82b9\u83dc\u53ef\u4ee5\u6cbb\u7597\u7cd6\u5c3f\u75c5\u5417\uff1f";
  8. try (Connection c = DriverManager.getConnection(jdbc, "root", "Ylrz_1q2w3e4r5t6y");
  9. Statement st = c.createStatement()) {
  10. System.out.println("message=" + msg);
  11. ResultSet rs = st.executeQuery(
  12. "SELECT id, type, content, status FROM fastgpt_chat_artificial_words WHERE status=0 ORDER BY sort");
  13. while (rs.next()) {
  14. String content = rs.getString("content");
  15. if (content != null && msg.contains(content)) {
  16. System.out.println("MATCH id=" + rs.getLong("id") + " type=" + rs.getLong("type") + " content=" + content);
  17. }
  18. }
  19. System.out.println("\n--- handoff_trigger keywords ---");
  20. rs = st.executeQuery(
  21. "SELECT keyword FROM lobster_tenant_keywords WHERE category='handoff_trigger' AND enabled=1");
  22. while (rs.next()) {
  23. String kw = rs.getString(1);
  24. if (kw != null && msg.contains(kw)) {
  25. System.out.println("handoff MATCH: " + kw);
  26. }
  27. }
  28. }
  29. }
  30. }