| 107 | /* ── Configuration ───────────────────────────────────────────────── */ |
| 108 | |
| 109 | cbm_sem_config_t cbm_sem_get_config(void) { |
| 110 | cbm_sem_config_t cfg = { |
| 111 | .w_tfidf = CBM_SEM_W_TFIDF, |
| 112 | .w_ri = CBM_SEM_W_RI, |
| 113 | .w_minhash = CBM_SEM_W_MINHASH, |
| 114 | .w_api = CBM_SEM_W_API, |
| 115 | .w_type = CBM_SEM_W_TYPE, |
| 116 | .w_decorator = CBM_SEM_W_DECORATOR, |
| 117 | .w_struct_profile = CBM_SEM_W_STRUCT_PROFILE, |
| 118 | .w_dataflow = CBM_SEM_W_DATAFLOW, |
| 119 | .threshold = (float)CBM_SEM_EDGE_THRESHOLD, |
| 120 | .max_edges = CBM_SEM_MAX_EDGES, |
| 121 | }; |
| 122 | const char *thresh = getenv("CBM_SEMANTIC_THRESHOLD"); |
| 123 | if (thresh) { |
| 124 | /* strtod reports errors via endptr; reject non-numeric input silently. */ |
| 125 | char *end = NULL; |
| 126 | double parsed = strtod(thresh, &end); |
| 127 | if (end != thresh && parsed > CBM_SEM_THRESHOLD_MIN && parsed <= CBM_SEM_THRESHOLD_MAX) { |
| 128 | cfg.threshold = (float)parsed; |
| 129 | } |
| 130 | } |
| 131 | return cfg; |
| 132 | } |
| 133 | |
| 134 | bool cbm_sem_is_enabled(void) { |
| 135 | const char *val = getenv("CBM_SEMANTIC_ENABLED"); |
no outgoing calls
no test coverage detected